EntityForm.cs 3.4 KB

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