MainPageUtils.cs 25 KB

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