EntityForm.cs 2.9 KB

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