123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- using System;
- using System.Collections.Generic;
- using System.Linq.Expressions;
- using InABox.Core;
- namespace Comal.Classes
- {
-
- public class JobDocumentSetMileStoneKanbanCount : CoreAggregate<JobDocumentSetMileStone, JobDocumentSetMileStoneKanban, Guid>
- {
- public override Expression<Func<JobDocumentSetMileStoneKanban, Guid>> Aggregate => x => x.ID;
- public override AggregateCalculation Calculation => AggregateCalculation.Count;
- public override Dictionary<Expression<Func<JobDocumentSetMileStoneKanban, object>>, Expression<Func<JobDocumentSetMileStone, object>>> Links =>
- new Dictionary<Expression<Func<JobDocumentSetMileStoneKanban, object>>, Expression<Func<JobDocumentSetMileStone, object>>>()
- {
- { JobDocumentSetMileStoneFile => JobDocumentSetMileStoneFile.Entity.ID, JobDocumentSetMileStone => JobDocumentSetMileStone.ID }
- };
- public override Filter<JobDocumentSetMileStoneKanban>? Filter =>
- new Filter<JobDocumentSetMileStoneKanban>(x => x.Kanban.Completed).IsEqualTo(DateTime.MinValue);
- }
-
- public class JobDocumentSetMileStoneFileCount : CoreAggregate<JobDocumentSetMileStone, JobDocumentSetMileStoneFile, Guid>
- {
- public override Expression<Func<JobDocumentSetMileStoneFile, Guid>> Aggregate => x => x.ID;
- public override AggregateCalculation Calculation => AggregateCalculation.Count;
- public override Dictionary<Expression<Func<JobDocumentSetMileStoneFile, object>>, Expression<Func<JobDocumentSetMileStone, object>>> Links =>
- new Dictionary<Expression<Func<JobDocumentSetMileStoneFile, object>>, Expression<Func<JobDocumentSetMileStone, object>>>()
- {
- { JobDocumentSetMileStoneFile => JobDocumentSetMileStoneFile.EntityLink.ID, JobDocumentSetMileStone => JobDocumentSetMileStone.ID }
- };
- }
-
- [Caption("Milestones")]
- public class JobDocumentSetMileStone : Entity, IRemotable, IPersistent,
- IOneToMany<JobDocumentSet>,
- IJobDocumentSetMileStone,
- ILicense<ProjectManagementLicense>
- {
- [EntityRelationship(DeleteAction.Cascade)]
- [Editable(Editable.Disabled)]
- [EditorSequence(0)]
- public JobDocumentSetLink DocumentSet { get; set; }
-
- [EntityRelationship(DeleteAction.Cascade)]
- [Editable(Editable.Disabled)]
- [EditorSequence(1)]
- public JobDocumentSetMileStoneTypelink Type { get; set; }
- [CodeEditor(Visible = Visible.Default, Editable = Editable.Enabled)]
- [EditorSequence(2)]
- public string Revision { get; set; }
-
- [EditorSequence(3)]
- public EmployeeLink Employee { get; set; }
-
- [EnumLookupEditor(typeof(JobDocumentSetMileStoneStatus))]
- [EditorSequence(4)]
- public JobDocumentSetMileStoneStatus Status { get; set; } = JobDocumentSetMileStoneStatus.NotStarted;
- [NotesEditor]
- [EditorSequence(5)]
- public String[] Notes { get; set; }
-
- [TextBoxEditor]
- [EditorSequence(6)]
- public String Watermark { get; set; }
-
- [DateTimeEditor(Editable = Editable.Enabled)]
- [EditorSequence(7)]
- public DateTime Due { get; set; }
-
- [Obsolete("Replaced with Submitted", true)]
- public DateTime Issued { get; set; }
-
- [DateTimeEditor(Editable = Editable.Disabled)]
- [EditorSequence(8)]
- public DateTime Submitted { get; set; }
-
- [DateTimeEditor(Editable = Editable.Enabled)]
- [EditorSequence(9)]
- public DateTime Expected { get; set; }
-
- [DateTimeEditor(Editable = Editable.Disabled)]
- [EditorSequence(10)]
- public DateTime Closed { get; set; }
-
- [NullEditor]
- [Aggregate(typeof(JobDocumentSetMileStoneFileCount))]
- public int Attachments { get; set; }
-
- [NullEditor]
- [Aggregate(typeof(JobDocumentSetMileStoneKanbanCount))]
- public int Kanbans { get; set; }
-
- [NullEditor]
- public DateTime DataEntered { get; set; }
- protected override void DoPropertyChanged(string name, object? before, object? after)
- {
- base.DoPropertyChanged(name, before, after);
- if (String.Equals(name, "Status"))
- {
- JobDocumentSetMileStoneStatus status = (JobDocumentSetMileStoneStatus)(after ?? default(JobDocumentSetMileStoneStatus));
- switch (status)
- {
- case JobDocumentSetMileStoneStatus.InProgress:
- case JobDocumentSetMileStoneStatus.OnHold:
- case JobDocumentSetMileStoneStatus.InfoRequired:
- Submitted = DateTime.MinValue;
- Closed = DateTime.MinValue;
- break;
- case JobDocumentSetMileStoneStatus.Submitted:
- Submitted = Submitted.IsEmpty() ? DateTime.Now : Submitted;
- Closed = DateTime.MinValue;
- break;
- case JobDocumentSetMileStoneStatus.Approved:
- case JobDocumentSetMileStoneStatus.Rejected:
- case JobDocumentSetMileStoneStatus.Cancelled:
- Submitted = Submitted.IsEmpty() ? DateTime.Now : Submitted;
- Closed = Closed.IsEmpty() ? DateTime.Now : Closed;
- break;
- }
- }
- }
- }
- }
|