JobITP.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 EmployeeLink { get; set; }
  25. [DateEditor]
  26. [EditorSequence(5)]
  27. public DateTime DueDate { get; set; }
  28. [Caption("ITP Form Type")]
  29. [EditorSequence(6)]
  30. public DigitalFormLink DigitalForm { get; set; }
  31. private class OpenFormsFormula : ComplexFormulaGenerator<JobITP, int>
  32. {
  33. public override IComplexFormulaNode<JobITP, int> GetFormula() =>
  34. Count<JobITPForm, Guid>(x => x.Property(x => x.ID),
  35. Filter<JobITPForm>.Where(x => x.FormCompleted).IsEqualTo(DateTime.MinValue)
  36. .And(x => x.FormCancelled).IsEqualTo(DateTime.MinValue))
  37. .WithLink(x => x.Parent.ID, x => x.ID);
  38. }
  39. [ComplexFormula(typeof(OpenFormsFormula))]
  40. [EditorSequence(7)]
  41. public int OpenForms { get; set; }
  42. private class ClosedFormsFormula : ComplexFormulaGenerator<JobITP, int>
  43. {
  44. public override IComplexFormulaNode<JobITP, int> GetFormula() =>
  45. Count<JobITPForm, Guid>(x => x.Property(x => x.ID),
  46. Filter<JobITPForm>.Where(x => x.FormCompleted).IsNotEqualTo(DateTime.MinValue)
  47. .And(x => x.FormCancelled).IsEqualTo(DateTime.MinValue))
  48. .WithLink(x => x.Parent.ID, x => x.ID);
  49. }
  50. [ComplexFormula(typeof(ClosedFormsFormula))]
  51. [EditorSequence(7)]
  52. public int ClosedForms { get; set; }
  53. public Expression<Func<JobITP, string>> AutoIncrementField() => x => x.Code;
  54. public Filter<JobITP> AutoIncrementFilter() => null;
  55. public int AutoIncrementDefault() => 1;
  56. public string AutoIncrementPrefix() => "";
  57. public string AutoIncrementFormat() => "{0:D4}";
  58. public override string ToString()
  59. {
  60. return string.Format("{0}: {1}", Code, Description);
  61. }
  62. }
  63. }