MainPageUtils.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading;
  5. using System.Threading.Tasks;
  6. using Xamarin.Forms;
  7. using InABox.Core;
  8. using InABox.Configuration;
  9. using InABox.Clients;
  10. using InABox.Mobile;
  11. using Comal.Classes;
  12. using XF.Material.Forms.UI.Dialogs;
  13. using comal.timesheets.CustomControls;
  14. using comal.timesheets.StoreRequis;
  15. using PRSSecurity = InABox.Core.Security;
  16. using Plugin.LocalNotification;
  17. using comal.timesheets.Tasks;
  18. using System.IO;
  19. using static comal.timesheets.CustomControls.JobShell;
  20. using static InABox.Mobile.LocationServices;
  21. using iText.Kernel.XMP.Impl;
  22. namespace comal.timesheets
  23. {
  24. public delegate void MainPageNotificationsChanged();
  25. public delegate void RefreshScreen();
  26. public delegate void RequestUserInputForTask(Guid taskID);
  27. public delegate void TaskTitleChanged(string title);
  28. public static class MainPageUtils
  29. {
  30. public static event MainPageNotificationsChanged OnMainPageNotificationsChanged;
  31. public static event RefreshScreen OnRefreshScreen;
  32. public static event RequestUserInputForTask OnRequestUserInput;
  33. public static event TaskTitleChanged OnTaskTitleChanged;
  34. public static Assignment CurrentAssignment = null;
  35. public static JobShell Job = new JobShell();
  36. public static int NumberOfNotifications = 0;
  37. public static string matchedDeviceName = "";
  38. public static string deviceName = "";
  39. public static bool bRecentlyUpdatedTiles = false;
  40. public static TimeSheet _timesheet = null;
  41. public static Employee _employee = null;
  42. public static CoreTable _jobs = null;
  43. public static bool firstLoad = true;
  44. public static bool recentlyAskedToUpdate = true;
  45. public static int updateCounter;
  46. public static Kanban CurrentTask = null;
  47. public static void Init()
  48. {
  49. InitEvents();
  50. InitData();
  51. InitTimers();
  52. CheckJobOnlyEmployee();
  53. }
  54. private static void CheckJobOnlyEmployee()
  55. {
  56. try
  57. {
  58. GlobalVariables.EmployeeJobs = new List<JobShell>();
  59. if (!PRSSecurity.IsAllowed<IsJobOnlyEmployee>())
  60. return;
  61. CoreTable table = new Client<JobEmployee>().Query(new Filter<JobEmployee>(x => x.EmployeeLink.ID).IsEqualTo(GlobalVariables.EmpID));
  62. if (!table.Rows.Any())
  63. return;
  64. foreach (CoreRow row in table.Rows)
  65. GlobalVariables.EmployeeJobs.Add(CreateJobShell(row));
  66. }
  67. catch { }
  68. }
  69. private static JobShell CreateJobShell(CoreRow row)
  70. {
  71. JobShell job = new JobShell();
  72. job.ID = row.Get<JobEmployee, Guid>(x => x.JobLink.ID);
  73. job.JobNumber = row.Get<JobEmployee, string>(x => x.JobLink.JobNumber);
  74. job.Name = row.Get<JobEmployee, string>(x => x.JobLink.Name);
  75. return job;
  76. }
  77. private static void InitEvents()
  78. {
  79. try
  80. {
  81. App.GPS.OnLocationFound += LocationFound;
  82. App.GPS.OnLocationError += LocationError;
  83. App.Bluetooth.OnScanFinished += ScanFinished;
  84. App.Data.DataChanged += (s, t) => { OnRefreshScreen?.Invoke(); };
  85. App.Data.DataRefreshed += () => { OnRefreshScreen?.Invoke(); };
  86. }
  87. catch { }
  88. }
  89. private static void InitData()
  90. {
  91. try
  92. {
  93. GlobalVariables.EmpID = GlobalVariables.GetEmployeeID();
  94. GlobalVariables.EmpName = GlobalVariables.GetEmployeeName();
  95. App.Data.Employee.ID = GlobalVariables.EmpID;
  96. App.Data.Employee.Name = GlobalVariables.EmpName;
  97. }
  98. catch { }
  99. try
  100. {
  101. bool deliveryteam = new Client<EmployeeTeam>().Query(new Filter<EmployeeTeam>(x => x.EmployeeLink.ID).IsEqualTo(GlobalVariables.EmpID)
  102. .And(x => x.TeamLink.ID).IsEqualTo(Guid.Parse("b7871075-4768-411f-b4f0-30874d5e6db6"))).Rows.Any()? true : false;
  103. if (deliveryteam || GlobalVariables.EmpID == Guid.Parse("ec88c8cc-9c05-4da8-89d8-060519ea1b70"))
  104. GlobalVariables.IsDeliveryDriver = true;
  105. else
  106. GlobalVariables.IsDeliveryDriver = false;
  107. _timesheet = App.Data.TimeSheets?.Rows.FirstOrDefault()?.ToObject<TimeSheet>();
  108. _employee = App.Data.Employee;
  109. _jobs = App.Data.Jobs;
  110. deviceName = MobileUtils.GetDeviceID();
  111. firstLoad = false;
  112. }
  113. catch { }
  114. }
  115. private static void InitTimers()
  116. {
  117. Timer t = new Timer(RecentlyAskedToUpdateTimer, null, 600000, 600000); //user is reminded to update when opening screen after timer of 10 minutes
  118. updateCounter = 1; //user is forced to update after 3rd reminder
  119. Timer t1 = new Timer(RecentlyUpdatedTilesTimer, null, 30000, 30000);
  120. //bluetooth data is allowed to upload once every minute, notifications refreshing is piggybacked to this too
  121. }
  122. private static void RecentlyAskedToUpdateTimer(object o)
  123. {
  124. recentlyAskedToUpdate = false;
  125. }
  126. private static void RecentlyUpdatedTilesTimer(object o)
  127. {
  128. bRecentlyUpdatedTiles = false;
  129. App.Data.Refresh(true);
  130. SearchForNewNotifications();
  131. }
  132. #region Assignments
  133. public static Assignment CheckCurrentAssignment()
  134. {
  135. Thread.Sleep(5000);
  136. StartAssignmentTimer();
  137. CoreTable table = new Client<Assignment>().Query(
  138. new Filter<Assignment>(x => x.EmployeeLink.ID).IsEqualTo(GlobalVariables.EmpID)
  139. .And(x => x.Date).IsEqualTo(DateTime.Today.Date)
  140. .And(x => x.Completed).IsEqualTo(null)
  141. .And(x => x.Booked.Finish).IsEqualTo(null),
  142. null,
  143. new SortOrder<Assignment>(x => x.Actual.Start, SortDirection.Ascending));
  144. if (!table.Rows.Any())
  145. {
  146. Job.OnJobIDChanged += OnJobIDChanged;
  147. return null;
  148. }
  149. else
  150. return table.Rows.LastOrDefault().ToObject<Assignment>();
  151. }
  152. private static void StartAssignmentTimer()
  153. {
  154. Timer t = new Timer(AssignmentTimerCallback, null, 300000, 300000);
  155. }
  156. private static void AssignmentTimerCallback(object state)
  157. {
  158. try
  159. {
  160. if (CurrentAssignment != null)
  161. SaveCurrentAssignment("PRS Mobile main screen - Saving assignment on 5 minute timer");
  162. }
  163. catch
  164. { }
  165. }
  166. public static void SaveCurrentAssignment(string auditnote, bool complete = false)
  167. {
  168. if (!complete)
  169. CurrentAssignment.Booked.Finish = RoundToNearestInterval(DateTime.Now, new TimeSpan(0, 5, 0)).TimeOfDay;
  170. else
  171. {
  172. CurrentAssignment.Actual.Finish = RoundToNearestInterval(DateTime.Now, new TimeSpan(0, 5, 0)).TimeOfDay;
  173. CurrentAssignment.Completed = DateTime.Now;
  174. }
  175. new Client<Assignment>().Save(CurrentAssignment, auditnote);
  176. }
  177. static DateTime RoundToNearestInterval(DateTime dt, TimeSpan d)
  178. {
  179. int f = 0;
  180. double m = (double)(dt.Ticks % d.Ticks) / d.Ticks;
  181. if (m >= 0.5)
  182. f = 1;
  183. return new DateTime(((dt.Ticks / d.Ticks) + f) * d.Ticks);
  184. }
  185. public static void UseCurrentAssignment(Assignment assgn)
  186. {
  187. try
  188. {
  189. CurrentAssignment = assgn;
  190. SaveCurrentAssignment("PRS Mobile main screen - saving assignment on re-login to App");
  191. if (CurrentAssignment.JobLink.ID != Guid.Empty)
  192. {
  193. Job.ID = CurrentAssignment.JobLink.ID;
  194. var job = new Client<Job>().Query(new Filter<Job>(x => x.ID).IsEqualTo(Job.ID)).Rows.FirstOrDefault().ToObject<Job>();
  195. Job.JobNumber = job.JobNumber;
  196. Job.Name = job.Name;
  197. Job.OnJobIDChanged += OnJobIDChanged;
  198. }
  199. if (CurrentAssignment.Task.ID != Guid.Empty)
  200. {
  201. var task = new Client<Kanban>().Query(new Filter<Kanban>(x => x.ID).IsEqualTo(CurrentAssignment.Task.ID)).Rows.FirstOrDefault().ToObject<Kanban>();
  202. OnTaskTitleChanged?.Invoke(task.Title);
  203. }
  204. }
  205. catch { }
  206. }
  207. public static void OnJobIDChanged(Guid jobid)
  208. {
  209. if (CurrentAssignment == null)
  210. CreateNewAssignment(jobid, Guid.Empty);
  211. else
  212. {
  213. SaveCurrentAssignment("PRS Mobile main screen - saving assignment on job change", true);
  214. CreateNewAssignment(jobid, Guid.Empty);
  215. }
  216. }
  217. public static void CreateNewAssignment(Guid jobid, Guid taskID)
  218. {
  219. CurrentAssignment = new Assignment { Date = DateTime.Now.Date };
  220. CurrentAssignment.EmployeeLink.ID = GlobalVariables.EmpID;
  221. CurrentAssignment.Actual.Start = RoundToNearestInterval(DateTime.Now, new TimeSpan(0, 5, 0)).TimeOfDay;
  222. CurrentAssignment.Booked.Start = CurrentAssignment.Actual.Start;
  223. CurrentAssignment.Booked.Finish = RoundToNearestInterval(DateTime.Now, new TimeSpan(0, 5, 0)).TimeOfDay.Add(new TimeSpan(0, 5, 0));
  224. if (jobid != Guid.Empty)
  225. AddJobDetails(jobid);
  226. if (taskID != Guid.Empty)
  227. AddTaskDetails(taskID);
  228. }
  229. private static void AddJobDetails(Guid jobid)
  230. {
  231. CurrentAssignment.JobLink.ID = jobid;
  232. var job = new Client<Job>().Query(new Filter<Job>(x => x.ID).IsEqualTo(jobid)).Rows.FirstOrDefault().ToObject<Job>();
  233. CurrentAssignment.Title = "Clocking on to job " + job.Name + " (" + job.JobNumber + ") on PRS Mobile";
  234. OnTaskTitleChanged?.Invoke("Task");
  235. new Client<Assignment>().Save(CurrentAssignment, "Changed job on mobile - creating new assignment");
  236. }
  237. private static void AddTaskDetails(Guid taskID)
  238. {
  239. CurrentAssignment.Task.ID = taskID;
  240. var task = new Client<Kanban>().Query(new Filter<Kanban>(x => x.ID).IsEqualTo(taskID)).Rows.FirstOrDefault().ToObject<Kanban>();
  241. CurrentAssignment.Title = "Clocking on to task " + task.Title + " on PRS Mobile";
  242. OnTaskTitleChanged?.Invoke(task.Title);
  243. if (!string.IsNullOrWhiteSpace(task.JobLink.JobNumber))
  244. Job.JobNumber = task.JobLink.JobNumber;
  245. new Client<Assignment>().Save(CurrentAssignment, "Changed task on mobile - creating new assignment");
  246. }
  247. #endregion
  248. #region Notifications
  249. public static Page DetermineCorrectPage(Plugin.LocalNotification.EventArgs.NotificationActionEventArgs e)
  250. {
  251. string data = e.Request.ReturningData;
  252. int index = data.IndexOf("$");
  253. Guid ID = Guid.Parse(data.Remove(index));
  254. string type = data.Substring(index + 1);
  255. if (type == "Comal.Classes.Kanban")
  256. return new AddEditTask(ID);
  257. else if (type == "Comal.Classes.Delivery")
  258. return new DeliveryDetails(ID);
  259. else
  260. return null;
  261. }
  262. public static void SearchForNewNotifications()
  263. {
  264. //notifications poll reliably in the background for Anroid, unreliable for iOS due to difficulty with cross-platform plugins for notifications
  265. Task.Run(() =>
  266. {
  267. try
  268. {
  269. if (ClientFactory.UserGuid != Guid.Empty)
  270. {
  271. CoreTable table = new Client<Notification>().Query
  272. (new Filter<Notification>(x => x.Employee.UserLink.ID).IsEqualTo(ClientFactory.UserGuid).And(X => X.Closed).IsEqualTo(DateTime.MinValue),
  273. new Columns<Notification>(
  274. x => x.ID, //0
  275. x => x.Sender.Name, //1
  276. x => x.Title, //2
  277. x => x.Created, //3
  278. x => x.Description, //4
  279. x => x.EntityType, //5
  280. x => x.EntityID //6
  281. )
  282. );
  283. if (NumberOfNotifications == table.Rows.Count()) //no new notifications or none present at all
  284. return;
  285. else //new notifications or previous notifications have now been dismissed
  286. {
  287. NumberOfNotifications = table.Rows.Count();
  288. OnMainPageNotificationsChanged?.Invoke();
  289. CheckNotificationsPushed(table);
  290. }
  291. }
  292. }
  293. catch { }
  294. });
  295. }
  296. private static void CheckNotificationsPushed(CoreTable table)
  297. {
  298. try
  299. {
  300. if (!Application.Current.Properties.ContainsKey("LastPushedNotifications"))
  301. {
  302. Application.Current.Properties.Add("LastPushedNotifications", DateTime.Now);
  303. }
  304. DateTime lastPushed = DateTime.Parse(Application.Current.Properties["LastPushedNotifications"].ToString());
  305. List<NotificationShell> toNotify = new List<NotificationShell>();
  306. foreach (CoreRow row in table.Rows)
  307. {
  308. List<object> list = row.Values;
  309. DateTime created = DateTime.Parse(list[3].ToString());
  310. if (created > new DateTime(2022, 8, 22)) // prevent spam from buildup of old notifications before this is released
  311. {
  312. if (created > lastPushed)
  313. {
  314. if (list[1] == null) list[1] = "";
  315. if (list[2] == null) list[2] = "";
  316. if (list[3] == null) list[3] = DateTime.MinValue;
  317. if (list[4] == null) list[4] = "";
  318. if (list[5] == null) list[5] = "";
  319. if (list[6] == null) list[6] = Guid.Empty;
  320. NotificationShell shell = new NotificationShell
  321. {
  322. ID = Guid.Parse(list[0].ToString()),
  323. Sender = list[1].ToString(),
  324. Title = list[2].ToString(),
  325. Created = DateTime.Parse(list[3].ToString()),
  326. EntityType = list[5].ToString(),
  327. EntityID = Guid.Parse(list[6].ToString())
  328. };
  329. toNotify.Add(shell); //add notification to be pushed
  330. }
  331. }
  332. }
  333. if (toNotify.Count > 0)
  334. PushNotificationsAsync(toNotify);
  335. }
  336. catch { }
  337. }
  338. private static async Task PushNotificationsAsync(List<NotificationShell> shells)
  339. {
  340. try
  341. {
  342. int count = 1;
  343. foreach (NotificationShell shell in shells)
  344. {
  345. var notification = new NotificationRequest
  346. {
  347. BadgeNumber = 1,
  348. Description = shell.Title,
  349. Title = "New PRS Notification: ",
  350. ReturningData = shell.EntityID.ToString() + "$" + shell.EntityType,
  351. NotificationId = count,
  352. };
  353. count++;
  354. NotificationImage img = new NotificationImage();
  355. img.ResourceName = "icon16.png";
  356. notification.Image = img;
  357. await LocalNotificationCenter.Current.Show(notification);
  358. }
  359. Application.Current.Properties["LastPushedNotifications"] = DateTime.Now;
  360. }
  361. catch { }
  362. }
  363. #endregion
  364. #region Location / Bluetooth
  365. private static void LocationFound(LocationServices sender)
  366. {
  367. //if (bSharedDevice)
  368. // return;
  369. if (App.Bluetooth.RecentlyScanned)
  370. UploadTiles();
  371. try
  372. {
  373. TimeSheet timesheet = App.Data.TimeSheets?.Rows.FirstOrDefault()?.ToObject<TimeSheet>();
  374. if (timesheet != null)
  375. {
  376. if (timesheet.StartLocation.Latitude.Equals(0.0F) && timesheet.StartLocation.Longitude.Equals(0.0F))
  377. {
  378. timesheet.StartLocation.Latitude = sender.Latitude;
  379. timesheet.StartLocation.Longitude = sender.Longitude;
  380. timesheet.StartLocation.Timestamp = sender.TimeStamp;
  381. timesheet.Address = sender.Address;
  382. new Client<TimeSheet>().Save(timesheet, "Updating Timesheet with GPS Coordinates", (o, e) => { });
  383. }
  384. }
  385. if (!string.IsNullOrWhiteSpace(matchedDeviceName))
  386. {
  387. InABox.Core.Location curlocation = new InABox.Core.Location() { Latitude = App.GPS.Latitude, Longitude = App.GPS.Longitude };
  388. curlocation.Timestamp = DateTime.Now;
  389. GPSTrackerLocation gpsTrackerLocation = new GPSTrackerLocation();
  390. gpsTrackerLocation.DeviceID = matchedDeviceName;
  391. gpsTrackerLocation.Location.Timestamp = curlocation.Timestamp;
  392. gpsTrackerLocation.Location = curlocation;
  393. new Client<GPSTrackerLocation>().Save(gpsTrackerLocation, "Updated company device location from Timebench");
  394. }
  395. OnRefreshScreen?.Invoke();
  396. }
  397. catch { }
  398. }
  399. private static async void UploadTiles()
  400. {
  401. try
  402. {
  403. if (App.GPS.Latitude.Equals(0.0F) && App.GPS.Longitude.Equals(0.0F))
  404. return;
  405. if (App.Bluetooth.DetectedBlueToothMACAddresses.Count == 0)
  406. return;
  407. if (bRecentlyUpdatedTiles)
  408. return;
  409. bRecentlyUpdatedTiles = true;
  410. await Task.Run(() =>
  411. {
  412. InABox.Core.Location curlocation = new InABox.Core.Location() { Latitude = App.GPS.Latitude, Longitude = App.GPS.Longitude };
  413. curlocation.Timestamp = DateTime.Now;
  414. List<GPSTrackerLocation> trackersToUpdate = new List<GPSTrackerLocation>();
  415. foreach (String id in App.Bluetooth.DetectedBlueToothMACAddresses)
  416. {
  417. GPSTracker tracker = GlobalVariables.GPSTrackerCache.Find(x => x.DeviceID.Equals(id));
  418. bool stale = tracker.Location.Timestamp < DateTime.Now.Subtract(new TimeSpan(0, 5, 0));
  419. bool moved = tracker.Location.DistanceTo(curlocation, UnitOfLength.Kilometers) > 0.1;
  420. if (stale || moved)
  421. {
  422. GlobalVariables.GPSTrackerCache.Remove(tracker);
  423. tracker.Location = curlocation;
  424. GlobalVariables.GPSTrackerCache.Add(tracker);
  425. //cache is updated
  426. GPSTrackerLocation gpsTrackerLocation = new GPSTrackerLocation();
  427. gpsTrackerLocation.DeviceID = tracker.DeviceID;
  428. gpsTrackerLocation.Location.Timestamp = tracker.Location.Timestamp;
  429. gpsTrackerLocation.Location = curlocation;
  430. trackersToUpdate.Add(gpsTrackerLocation);
  431. }
  432. }
  433. if (trackersToUpdate.Any())
  434. {
  435. if (ClientFactory.UserGuid != Guid.Empty)
  436. new Client<GPSTrackerLocation>().Save(trackersToUpdate, "Updating Bluetooth Device Locations");
  437. }
  438. App.Bluetooth.DetectedBlueToothMACAddresses.Clear();
  439. }
  440. );
  441. }
  442. catch (Exception e)
  443. {
  444. }
  445. //if ((master != null) && (master.Location.Timestamp < DateTime.Now.Subtract(new TimeSpan(0, 15, 0))))
  446. //{
  447. // GPSTrackerLocation device = new GPSTrackerLocation();
  448. // device.DeviceID = MobileUtils.GetDeviceID();
  449. // device.Location.Latitude = App.GPS.Latitude;
  450. // device.Location.Longitude = App.GPS.Longitude;
  451. // device.Location.Timestamp = DateTime.Now;
  452. // locations.Add(device);
  453. // //device.BatteryLevel = ((double)CrossBattery.Current.RemainingChargePercent);
  454. // //new Client<GPSTrackerLocation>().Save(device, "Updating Device Location"); //, SaveTrackerCallback);
  455. //}
  456. #region OLD
  457. //for (int i = 0; i < App.Bluetooth.Devices.Length; i++)
  458. //{
  459. // String id = App.Bluetooth.Devices[i];
  460. // int level = App.Bluetooth.BatteryLevels[i];
  461. // var btmaster = trackers.FirstOrDefault(x => x.DeviceID.Equals(id));
  462. // if ((btmaster != null) && (!locations.Any(x => x.DeviceID.Equals(btmaster.DeviceID))))
  463. // {
  464. // bool stale = btmaster.Location.Timestamp < DateTime.Now.Subtract(new TimeSpan(0, 15, 0));
  465. // bool moved = btmaster.Location.DistanceTo(curlocation, UnitOfLength.Kilometers) > 0.1;
  466. // if (stale || moved)
  467. // {
  468. // GPSTrackerLocation location = new GPSTrackerLocation();
  469. // location.DeviceID = id;
  470. // location.Location.Latitude = App.GPS.Latitude;
  471. // location.Location.Longitude = App.GPS.Longitude;
  472. // location.Location.Timestamp = DateTime.Now;
  473. // location.BatteryLevel = level;
  474. // locations.Add(location);
  475. // }
  476. // }
  477. // //new Client<GPSTrackerLocation>().Save(location, "Found Kontakt Device"); //, SaveTrackerCallback);
  478. //}
  479. //if (locations.Any())
  480. // new Client<GPSTrackerLocation>().Save(locations, "Updating Bluetooth Device Locations", (o, e) => { });
  481. #endregion
  482. }
  483. private static void LocationError(LocationServices sebder, Exception error)
  484. {
  485. }
  486. private static void ScanFinished(Bluetooth sender)
  487. {
  488. try
  489. {
  490. OnRefreshScreen?.Invoke();
  491. if (App.GPS.RecentlyLocated)
  492. UploadTiles();
  493. }
  494. catch { }
  495. }
  496. #endregion
  497. public static Dictionary<Guid, string> GetTasks()
  498. {
  499. Dictionary<Guid, string> dict = new Dictionary<Guid, string>();
  500. CoreTable table = new Client<Kanban>().Query(
  501. new Filter<Kanban>(x => x.EmployeeLink.ID).IsEqualTo(GlobalVariables.EmpID)
  502. .And(x => x.Category).IsNotEqualTo("Complete"),
  503. new Columns<Kanban>(x => x.ID, x => x.Title)
  504. );
  505. foreach (CoreRow row in table.Rows)
  506. {
  507. dict.Add
  508. (
  509. row.Get<Kanban, Guid>(x => x.ID),
  510. row.Get<Kanban, string>(x => x.Title)
  511. );
  512. }
  513. return dict;
  514. }
  515. public static void OnTaskSelected(Guid ID, string title)
  516. {
  517. if (CurrentAssignment != null)
  518. OnRequestUserInput?.Invoke(ID);
  519. else
  520. CreateNewAssignment(Guid.Empty, ID);
  521. }
  522. public static void ChangeAssignmentTask(Guid taskID)
  523. {
  524. AddTaskDetails(taskID);
  525. }
  526. }
  527. }