JobITP.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. using System;
  2. using System.Linq.Expressions;
  3. using InABox.Core;
  4. namespace Comal.Classes
  5. {
  6. [UserTracking(typeof(Job))]
  7. public class JobITP : Entity, IRemotable, IPersistent, IOneToMany<Job>, IStringAutoIncrement<JobITP>, ILicense<ProjectManagementLicense>,
  8. IExportable,
  9. IImportable, IMergeable
  10. {
  11. [NullEditor]
  12. [EditorSequence(0)]
  13. public JobLink Job { get; set; }
  14. [CodeEditor(Editable = Editable.Enabled)]
  15. [EditorSequence(1)]
  16. public string Code { get; set; }
  17. [TextBoxEditor]
  18. [EditorSequence(2)]
  19. public string Description { get; set; }
  20. [MemoEditor]
  21. [EditorSequence(3)]
  22. public string Comments { get; set; }
  23. [EditorSequence(4)]
  24. public EmployeeLink Employee { get; set; }
  25. [Obsolete("Replaced by Employee")]
  26. public EmployeeLink EmployeeLink
  27. {
  28. get => Employee;
  29. set { }
  30. }
  31. [DateEditor]
  32. [EditorSequence(5)]
  33. public DateTime DueDate { get; set; }
  34. [Caption("ITP Form Type")]
  35. [EditorSequence(6)]
  36. public DigitalFormLink DigitalForm { get; set; }
  37. private class OpenFormsFormula : ComplexFormulaGenerator<JobITP, int>
  38. {
  39. public override IComplexFormulaNode<JobITP, int> GetFormula() =>
  40. Count<JobITPForm, Guid>(x => x.Property(x => x.ID),
  41. Filter<JobITPForm>.Where(x => x.FormCompleted).IsEqualTo(DateTime.MinValue)
  42. .And(x => x.FormCancelled).IsEqualTo(DateTime.MinValue))
  43. .WithLink(x => x.Parent.ID, x => x.ID);
  44. }
  45. [ComplexFormula(typeof(OpenFormsFormula))]
  46. [EditorSequence(7)]
  47. public int OpenForms { get; set; }
  48. private class ClosedFormsFormula : ComplexFormulaGenerator<JobITP, int>
  49. {
  50. public override IComplexFormulaNode<JobITP, int> GetFormula() =>
  51. Count<JobITPForm, Guid>(x => x.Property(x => x.ID),
  52. Filter<JobITPForm>.Where(x => x.FormCompleted).IsNotEqualTo(DateTime.MinValue)
  53. .And(x => x.FormCancelled).IsEqualTo(DateTime.MinValue))
  54. .WithLink(x => x.Parent.ID, x => x.ID);
  55. }
  56. [ComplexFormula(typeof(ClosedFormsFormula))]
  57. [EditorSequence(7)]
  58. public int ClosedForms { get; set; }
  59. public Expression<Func<JobITP, string>> AutoIncrementField() => x => x.Code;
  60. public Filter<JobITP> AutoIncrementFilter() => null;
  61. public int AutoIncrementDefault() => 1;
  62. public string AutoIncrementPrefix() => "";
  63. public string AutoIncrementFormat() => "{0:D4}";
  64. public override string ToString()
  65. {
  66. return string.Format("{0}: {1}", Code, Description);
  67. }
  68. }
  69. }