EntityForm.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using System;
  2. using System.Linq.Expressions;
  3. namespace InABox.Core
  4. {
  5. // EntityForm no longer is an IOneToMany, so any subclasses must add this if they want to.
  6. public interface IEntityForm
  7. {
  8. }
  9. [Caption("Digital Forms")]
  10. public abstract class EntityForm<TParent, TParentLink, TThis> : Entity, IRemotable, IPersistent, ISequenceable, IStringAutoIncrement<TThis>,
  11. IEntityForm,
  12. IDigitalFormInstance<TParentLink>, ILicense<DigitalFormsLicense>
  13. where TThis : EntityForm<TParent,TParentLink, TThis>
  14. where TParent : Entity
  15. where TParentLink : IEntityLink<TParent>, new()
  16. {
  17. public Expression<Func<TThis, String>> AutoIncrementField() => x => x.Number;
  18. public abstract String AutoIncrementPrefix();
  19. public virtual string AutoIncrementFormat() => "{0:D6}";
  20. public Filter<TThis> AutoIncrementFilter() => null;
  21. [EditorSequence(1)]
  22. [CodeEditor(Editable = Editable.Disabled)]
  23. public String Number { get; set; }
  24. [EditorSequence(2)]
  25. public string Description { get; set; }
  26. [NullEditor]
  27. public TParentLink Parent { get; set; }
  28. [NullEditor]
  29. [Obsolete("Being Replaced by Form")]
  30. public QAFormLink QAForm { get; set; }
  31. [EditorSequence(1)]
  32. public DigitalFormLink Form { get; set; }
  33. [NullEditor]
  34. [Obsolete("Being Replaced by FormData", true)]
  35. public string QAData { get; set; }
  36. [NullEditor]
  37. public string FormData { get; set; }
  38. [NullEditor]
  39. public string? BlobData { get; set; }
  40. [NullEditor]
  41. [Obsolete("Being Replaced by FormCompleted", true)]
  42. public DateTime QACompleted { get; set; }
  43. [EditorSequence(2)]
  44. [Caption("Started")]
  45. [DateTimeEditor]
  46. public DateTime FormStarted { get; set; }
  47. [EditorSequence(3)]
  48. [Caption("Completed")]
  49. [DateTimeEditor]
  50. public DateTime FormCompleted { get; set; }
  51. [EditorSequence(4)]
  52. [Caption("Processed")]
  53. [DateTimeEditor]
  54. public DateTime FormProcessed { get; set; }
  55. [EditorSequence(5)]
  56. [Caption("Cancelled")]
  57. [DateTimeEditor]
  58. public DateTime FormCancelled { get; set; }
  59. [NullEditor]
  60. [Obsolete("Being Replaced by FormCompletedBy")]
  61. public UserLink QACompletedBy { get; set; }
  62. [EditorSequence(3)]
  63. [Caption("User")]
  64. public UserLink FormCompletedBy { get; set; }
  65. [NullEditor]
  66. [Obsolete("Replaced with Status", true)]
  67. public bool Processed { get; set; }
  68. [NullEditor]
  69. public Location Location { get; set; }
  70. public IDigitalFormDataModel CreateDataModel(Entity? parent = null)
  71. {
  72. var t = typeof(DigitalFormDataModel<,,>).MakeGenericType(typeof(TParent), typeof(TParentLink), GetType());
  73. if (parent != null)
  74. return (Activator.CreateInstance(t, parent, this) as IDigitalFormDataModel)!;
  75. return (Activator.CreateInstance(t, Parent.ID, ID) as IDigitalFormDataModel)!;
  76. }
  77. public Guid ParentID()
  78. {
  79. return Parent.ID;
  80. }
  81. [DurationEditor(Visible=Visible.Optional, Editable = Editable.Hidden)]
  82. public TimeSpan FormOpen { get; set; }
  83. [NullEditor]
  84. public long Sequence { get; set; }
  85. protected override void Init()
  86. {
  87. base.Init();
  88. Parent = new TParentLink();
  89. Form = new DigitalFormLink();
  90. FormCompletedBy = new UserLink();
  91. QAForm = new QAFormLink();
  92. QACompletedBy = new UserLink();
  93. Location = new Location();
  94. Description = "";
  95. FormStarted = DateTime.MinValue;
  96. FormOpen = TimeSpan.Zero;
  97. CoreUtils.SetPropertyValue(this, "Processed", false);
  98. }
  99. }
  100. }