JobDocumentSetMileStone.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq.Expressions;
  4. using InABox.Core;
  5. namespace Comal.Classes
  6. {
  7. public class JobDocumentSetMileStoneKanbanCount : CoreAggregate<JobDocumentSetMileStone, JobDocumentSetMileStoneKanban, Guid>
  8. {
  9. public override Expression<Func<JobDocumentSetMileStoneKanban, Guid>> Aggregate => x => x.ID;
  10. public override AggregateCalculation Calculation => AggregateCalculation.Count;
  11. public override Dictionary<Expression<Func<JobDocumentSetMileStoneKanban, object>>, Expression<Func<JobDocumentSetMileStone, object>>> Links =>
  12. new Dictionary<Expression<Func<JobDocumentSetMileStoneKanban, object>>, Expression<Func<JobDocumentSetMileStone, object>>>()
  13. {
  14. { JobDocumentSetMileStoneFile => JobDocumentSetMileStoneFile.Entity.ID, JobDocumentSetMileStone => JobDocumentSetMileStone.ID }
  15. };
  16. public override Filter<JobDocumentSetMileStoneKanban>? Filter =>
  17. new Filter<JobDocumentSetMileStoneKanban>(x => x.Kanban.Completed).IsEqualTo(DateTime.MinValue);
  18. }
  19. public class JobDocumentSetMileStoneFileCount : CoreAggregate<JobDocumentSetMileStone, JobDocumentSetMileStoneFile, Guid>
  20. {
  21. public override Expression<Func<JobDocumentSetMileStoneFile, Guid>> Aggregate => x => x.ID;
  22. public override AggregateCalculation Calculation => AggregateCalculation.Count;
  23. public override Dictionary<Expression<Func<JobDocumentSetMileStoneFile, object>>, Expression<Func<JobDocumentSetMileStone, object>>> Links =>
  24. new Dictionary<Expression<Func<JobDocumentSetMileStoneFile, object>>, Expression<Func<JobDocumentSetMileStone, object>>>()
  25. {
  26. { JobDocumentSetMileStoneFile => JobDocumentSetMileStoneFile.EntityLink.ID, JobDocumentSetMileStone => JobDocumentSetMileStone.ID }
  27. };
  28. }
  29. [Caption("Milestones")]
  30. public class JobDocumentSetMileStone : Entity, IRemotable, IPersistent,
  31. IOneToMany<JobDocumentSet>,
  32. IJobDocumentSetMileStone,
  33. ILicense<ProjectManagementLicense>
  34. {
  35. [EntityRelationship(DeleteAction.Cascade)]
  36. [Editable(Editable.Disabled)]
  37. [EditorSequence(0)]
  38. public JobDocumentSetLink DocumentSet { get; set; }
  39. [EntityRelationship(DeleteAction.Cascade)]
  40. [Editable(Editable.Disabled)]
  41. [EditorSequence(1)]
  42. public JobDocumentSetMileStoneTypelink Type { get; set; }
  43. [CodeEditor(Visible = Visible.Default, Editable = Editable.Enabled)]
  44. [EditorSequence(2)]
  45. public string Revision { get; set; }
  46. [EditorSequence(3)]
  47. public EmployeeLink Employee { get; set; }
  48. [EnumLookupEditor(typeof(JobDocumentSetMileStoneStatus))]
  49. [EditorSequence(4)]
  50. public JobDocumentSetMileStoneStatus Status { get; set; } = JobDocumentSetMileStoneStatus.NotStarted;
  51. [NotesEditor]
  52. [EditorSequence(5)]
  53. public String[] Notes { get; set; }
  54. [TextBoxEditor]
  55. [EditorSequence(6)]
  56. public String Watermark { get; set; }
  57. [DateTimeEditor(Editable = Editable.Enabled)]
  58. [EditorSequence(7)]
  59. public DateTime Due { get; set; }
  60. [Obsolete("Replaced with Submitted", true)]
  61. public DateTime Issued { get; set; }
  62. [DateTimeEditor(Editable = Editable.Disabled)]
  63. [EditorSequence(8)]
  64. public DateTime Submitted { get; set; }
  65. [DateTimeEditor(Editable = Editable.Enabled)]
  66. [EditorSequence(9)]
  67. public DateTime Expected { get; set; }
  68. [DateTimeEditor(Editable = Editable.Disabled)]
  69. [EditorSequence(10)]
  70. public DateTime Closed { get; set; }
  71. [NullEditor]
  72. [Aggregate(typeof(JobDocumentSetMileStoneFileCount))]
  73. public int Attachments { get; set; }
  74. [NullEditor]
  75. [Aggregate(typeof(JobDocumentSetMileStoneKanbanCount))]
  76. public int Kanbans { get; set; }
  77. [NullEditor]
  78. public DateTime DataEntered { get; set; }
  79. protected override void DoPropertyChanged(string name, object? before, object? after)
  80. {
  81. base.DoPropertyChanged(name, before, after);
  82. if (String.Equals(name, "Status"))
  83. {
  84. JobDocumentSetMileStoneStatus status = (JobDocumentSetMileStoneStatus)(after ?? default(JobDocumentSetMileStoneStatus));
  85. switch (status)
  86. {
  87. case JobDocumentSetMileStoneStatus.InProgress:
  88. case JobDocumentSetMileStoneStatus.OnHold:
  89. case JobDocumentSetMileStoneStatus.InfoRequired:
  90. Submitted = DateTime.MinValue;
  91. Closed = DateTime.MinValue;
  92. break;
  93. case JobDocumentSetMileStoneStatus.Submitted:
  94. Submitted = Submitted.IsEmpty() ? DateTime.Now : Submitted;
  95. Closed = DateTime.MinValue;
  96. break;
  97. case JobDocumentSetMileStoneStatus.Approved:
  98. case JobDocumentSetMileStoneStatus.Rejected:
  99. case JobDocumentSetMileStoneStatus.Cancelled:
  100. Submitted = Submitted.IsEmpty() ? DateTime.Now : Submitted;
  101. Closed = Closed.IsEmpty() ? DateTime.Now : Closed;
  102. break;
  103. }
  104. }
  105. }
  106. }
  107. }