CompletedAssignmentDashboard.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using System.ComponentModel;
  3. using System.Threading;
  4. using System.Windows.Media;
  5. using Comal.Classes;
  6. using InABox.Configuration;
  7. using InABox.Core;
  8. using InABox.DynamicGrid;
  9. using PRSDesktop.WidgetGroups;
  10. namespace PRSDesktop.Dashboards
  11. {
  12. public class CompletedAssignmentDashboardProperties : IUserConfigurationSettings, IDashboardProperties
  13. {
  14. }
  15. public class CompletedAssignmentDashboardElement : DashboardElement<CompletedAssignmentDashboard, HumanResources,
  16. CompletedAssignmentDashboardProperties>
  17. {
  18. }
  19. public class CompletedAssignmentDashboard : DynamicDataGrid<Assignment>,
  20. IDashboardWidget<HumanResources, CompletedAssignmentDashboardProperties>
  21. {
  22. public void Setup()
  23. {
  24. ActionColumns.Add(new DynamicMenuColumn(CreateMenu, GetStatus));
  25. ColumnsTag = GetType().Name;
  26. Refresh(true,false);
  27. }
  28. protected override void DoReconfigure(DynamicGridOptions options)
  29. {
  30. base.DoReconfigure(options);
  31. options.Clear();
  32. options.SelectColumns = true;
  33. }
  34. private DynamicMenuStatus GetStatus(CoreRow row)
  35. {
  36. return DynamicMenuStatus.Enabled;
  37. }
  38. private void CreateMenu(DynamicMenuColumn menu, CoreRow? row)
  39. {
  40. menu.AddItem("View Forms", null, ViewFormsClick);
  41. menu.AddItem("Open Job", null, OpenJobClick);
  42. menu.AddSeparator();
  43. menu.AddItem("Create Quote", null, CreateQuoteClick);
  44. menu.AddSeparator();
  45. menu.AddItem("Mark as Processed", null, MarkAsProcessedClick);
  46. }
  47. private void ViewFormsClick(CoreRow obj)
  48. {
  49. }
  50. private void OpenJobClick(CoreRow obj)
  51. {
  52. }
  53. private void CreateQuoteClick(CoreRow obj)
  54. {
  55. }
  56. private void MarkAsProcessedClick(CoreRow obj)
  57. {
  58. }
  59. public void Shutdown(CancelEventArgs? cancel)
  60. {
  61. }
  62. public void Refresh()
  63. {
  64. Refresh(false, true);
  65. }
  66. protected override void Reload(
  67. Filters<Assignment> criteria, Columns<Assignment> columns, ref SortOrder<Assignment>? sort,
  68. CancellationToken token, Action<CoreTable?, Exception?> action)
  69. {
  70. criteria.Add(
  71. new Filter<Assignment>(x => x.Completed).IsNotEqualTo(DateTime.MinValue)
  72. .And(x => x.Processed).IsEqualTo(DateTime.MinValue)
  73. );
  74. base.Reload(criteria, columns, ref sort, token, action);
  75. }
  76. protected override DynamicGridStyle GetRowStyle(CoreRow row, DynamicGridStyle style)
  77. {
  78. var result = base.GetRowStyle(row, style);
  79. var completed = row.Get<Assignment, DateTime>(c => c.Completed);
  80. if (completed < DateTime.Today.AddDays(-2))
  81. result.Background = new SolidColorBrush(Colors.LightSalmon);
  82. else if (completed < DateTime.Today)
  83. result.Background = new SolidColorBrush(Colors.Wheat);
  84. else
  85. result.Background = new SolidColorBrush(Colors.LightGreen);
  86. return result;
  87. }
  88. public CompletedAssignmentDashboardProperties Properties { get; set; }
  89. public event LoadSettings<CompletedAssignmentDashboardProperties>? LoadSettings;
  90. public event SaveSettings<CompletedAssignmentDashboardProperties>? SaveSettings;
  91. }
  92. }