EntityForm.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using System;
  2. namespace InABox.Core
  3. {
  4. // EntityForm no longer is an IOneToMany, so any subclasses must add this if they want to.
  5. [Caption("Digital Forms")]
  6. public abstract class EntityForm<TParent, TParentLink> : Entity, IRemotable, IPersistent, ISequenceable,
  7. IDigitalFormInstance<TParentLink>, ILicense<DigitalFormsLicense>
  8. where TParent : Entity
  9. where TParentLink : IEntityLink<TParent>, new()
  10. {
  11. [EditorSequence(2)]
  12. public string Description { get; set; }
  13. [NullEditor]
  14. public TParentLink Parent { get; set; }
  15. [NullEditor]
  16. [Obsolete("Being Replaced by Form")]
  17. public QAFormLink QAForm { get; set; }
  18. [EditorSequence(1)]
  19. public DigitalFormLink Form { get; set; }
  20. [NullEditor]
  21. [Obsolete("Being Replaced by FormData", true)]
  22. public string QAData { get; set; }
  23. [NullEditor]
  24. public string FormData { get; set; }
  25. [NullEditor]
  26. public string? BlobData { get; set; }
  27. [NullEditor]
  28. [Obsolete("Being Replaced by FormCompleted", true)]
  29. public DateTime QACompleted { get; set; }
  30. [EditorSequence(2)]
  31. [Caption("Completed")]
  32. [DateTimeEditor]
  33. public DateTime FormCompleted { get; set; }
  34. [NullEditor]
  35. [Obsolete("Being Replaced by FormCompletedBy")]
  36. public UserLink QACompletedBy { get; set; }
  37. [EditorSequence(3)]
  38. [Caption("User")]
  39. public UserLink FormCompletedBy { get; set; }
  40. [EditorSequence(4)]
  41. [CheckBoxEditor]
  42. public bool Processed { get; set; }
  43. [NullEditor]
  44. public Location Location { get; set; }
  45. public IDigitalFormDataModel CreateDataModel(Entity? parent = null)
  46. {
  47. var t = typeof(DigitalFormDataModel<,,>).MakeGenericType(typeof(TParent), typeof(TParentLink), GetType());
  48. if (parent != null)
  49. return (Activator.CreateInstance(t, parent, this) as IDigitalFormDataModel)!;
  50. return (Activator.CreateInstance(t, Parent.ID, ID) as IDigitalFormDataModel)!;
  51. }
  52. public Guid ParentID()
  53. {
  54. return Parent.ID;
  55. }
  56. public DateTime FormStarted { get; set; }
  57. public TimeSpan FormOpen { get; set; }
  58. [NullEditor]
  59. public long Sequence { get; set; }
  60. protected override void Init()
  61. {
  62. base.Init();
  63. Parent = new TParentLink();
  64. Form = new DigitalFormLink();
  65. FormCompletedBy = new UserLink();
  66. QAForm = new QAFormLink();
  67. QACompletedBy = new UserLink();
  68. Location = new Location();
  69. Description = "";
  70. FormStarted = DateTime.MinValue;
  71. FormOpen = TimeSpan.Zero;
  72. Processed = false;
  73. }
  74. }
  75. }