JobDocumentSetMileStone.cs 4.4 KB

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