TaskModel.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using System;
  2. using System.Windows.Media;
  3. using System.Windows.Media.Imaging;
  4. using Comal.Classes;
  5. using InABox.Core;
  6. using PropertyChanged;
  7. using Syncfusion.UI.Xaml.Kanban;
  8. namespace PRSDesktop;
  9. [DoNotNotify]
  10. public class TaskModel
  11. {
  12. public string Title { get; set; }
  13. public Guid ID { get; set; }
  14. public string Description { get; set; }
  15. public BitmapImage? Image { get; set; }
  16. public Color Color { get; set; }
  17. public bool Attachments { get; set; }
  18. public DateTime DueDate { get; set; }
  19. public DateTime CompletedDate { get; set; }
  20. public Guid EmployeeID { get; set; }
  21. public string AssignedTo { get; set; }
  22. public string Manager { get; set; }
  23. public Guid ManagerID { get; set; }
  24. public Guid JobID { get; set; }
  25. public string JobNumber { get; set; }
  26. public string JobName { get; set; }
  27. public bool Checked { get; set; }
  28. public KanbanStatus Status { get; set; }
  29. public Guid EmployeeCategory { get; set; }
  30. public KanbanType Type { get; set; }
  31. public int Number { get; set; }
  32. public bool Locked { get; set; }
  33. public TimeSpan EstimatedTime { get; set; }
  34. private string _tags;
  35. public string Tags
  36. {
  37. get => _tags;
  38. set
  39. {
  40. _tags = value;
  41. _tagDisplay = null;
  42. }
  43. }
  44. private static TagsEditor? _tagsEditor;
  45. private string? _tagDisplay;
  46. public string TagDisplay
  47. {
  48. get
  49. {
  50. _tagsEditor ??= DatabaseSchema.Property<Kanban>(x => x.Tags)?.Editor as TagsEditor;
  51. _tagDisplay ??= string.Join(',', _tagsEditor?.ReadTags(Tags) ?? []);
  52. return _tagDisplay;
  53. }
  54. set
  55. {
  56. }
  57. }
  58. public bool ShowEmployeeImage { get; set; }
  59. /// <summary>
  60. /// A string representation of the Notes field of Kanban.
  61. /// </summary>
  62. public string Notes { get; set; }
  63. public bool IsAssignee => EmployeeID != Guid.Empty && EmployeeCategory == EmployeeID;
  64. public bool IsManager => ManagerID != Guid.Empty && EmployeeCategory == ManagerID;
  65. public bool Search(string[] searches)
  66. {
  67. foreach (var search in searches)
  68. {
  69. var bFound = JobNumber?.ToUpper().Contains(search.ToUpper()) == true
  70. || JobName?.ToUpper().Contains(search.ToUpper()) == true
  71. || Title?.ToUpper().Contains(search.ToUpper()) == true
  72. || Description?.ToUpper().Contains(search.ToUpper()) == true
  73. || Manager?.ToUpper().Contains(search.ToUpper()) == true
  74. || AssignedTo?.ToUpper().Contains(search.ToUpper()) == true
  75. || Number.ToString().Contains(search.ToUpper()) == true;
  76. if (!bFound)
  77. return false;
  78. }
  79. return true;
  80. }
  81. public bool JobSearch(Guid id)
  82. {
  83. return JobID == id;
  84. }
  85. public static System.Drawing.Color KanbanColor(DateTime duedate, DateTime completed)
  86. {
  87. var compareDate = completed == DateTime.MinValue ? DateTime.Today : completed.Date;
  88. var color = System.Drawing.Color.LightGreen;
  89. if (duedate < compareDate)
  90. color = System.Drawing.Color.Salmon;
  91. else if (duedate.Date == compareDate)
  92. color = System.Drawing.Color.Orange;
  93. else if (duedate < compareDate.AddDays(7))
  94. color = System.Drawing.Color.LightYellow;
  95. return color;
  96. }
  97. }