MainPageUtils.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System;
  2. using PRSSecurity = InABox.Core.Security;
  3. namespace PRS.Mobile
  4. {
  5. public delegate void MainPageNotificationsChanged();
  6. public delegate void RefreshScreen();
  7. public delegate void RequestUserInputForTask(Guid taskID);
  8. public delegate void TaskTitleChanged(string title);
  9. public static class MainPageUtils
  10. {
  11. //public static event MainPageNotificationsChanged OnMainPageNotificationsChanged;
  12. //public static event RequestUserInputForTask OnRequestUserInput;
  13. //public static event TaskTitleChanged OnTaskTitleChanged;
  14. #region Notifications
  15. // public static Page DetermineCorrectPage(Plugin.LocalNotification.EventArgs.NotificationActionEventArgs e)
  16. // {
  17. // string data = e.Request.ReturningData;
  18. // int index = data.IndexOf("$");
  19. // Guid ID = Guid.Parse(data.Remove(index));
  20. // string type = data.Substring(index + 1);
  21. // if (type == "Comal.Classes.Kanban")
  22. // return new AddEditTask(ID);
  23. // else if (type == "Comal.Classes.Delivery")
  24. // return new DeliveryDetails(ID);
  25. // else
  26. // return null;
  27. // }
  28. //
  29. // private static void CheckNotificationsPushed(CoreTable table)
  30. // {
  31. // try
  32. // {
  33. // if (!Application.Current.Properties.ContainsKey("LastPushedNotifications"))
  34. // {
  35. // Application.Current.Properties.Add("LastPushedNotifications", DateTime.Now);
  36. // }
  37. // DateTime lastPushed = DateTime.Parse(Application.Current.Properties["LastPushedNotifications"].ToString());
  38. // List<NotificationShell> toNotify = new List<NotificationShell>();
  39. // foreach (CoreRow row in table.Rows)
  40. // {
  41. // List<object> list = row.Values;
  42. // DateTime created = DateTime.Parse(list[3].ToString());
  43. // if (created > new DateTime(2022, 8, 22)) // prevent spam from buildup of old notifications before this is released
  44. // {
  45. // if (created > lastPushed)
  46. // {
  47. // if (list[1] == null) list[1] = "";
  48. // if (list[2] == null) list[2] = "";
  49. // if (list[3] == null) list[3] = DateTime.MinValue;
  50. // if (list[4] == null) list[4] = "";
  51. // if (list[5] == null) list[5] = "";
  52. // if (list[6] == null) list[6] = Guid.Empty;
  53. //
  54. // NotificationShell shell = new NotificationShell
  55. // {
  56. // ID = Guid.Parse(list[0].ToString()),
  57. // Sender = list[1].ToString(),
  58. // Title = list[2].ToString(),
  59. // Created = DateTime.Parse(list[3].ToString()),
  60. // EntityType = list[5].ToString(),
  61. // EntityID = Guid.Parse(list[6].ToString())
  62. // };
  63. // toNotify.Add(shell); //add notification to be pushed
  64. // }
  65. // }
  66. // }
  67. // if (toNotify.Count > 0)
  68. // PushNotificationsAsync(toNotify);
  69. // }
  70. // catch { }
  71. // }
  72. //
  73. // private static async Task PushNotificationsAsync(string title, )
  74. // {
  75. // try
  76. // {
  77. // int count = 1;
  78. //
  79. // foreach (NotificationShell shell in shells)
  80. // {
  81. // var notification = new NotificationRequest
  82. // {
  83. // BadgeNumber = 1,
  84. // Description = title,
  85. // Title = "New PRS Notification: ",
  86. // ReturningData = shell.EntityID.ToString() + "$" + shell.EntityType,
  87. // NotificationId = count,
  88. // };
  89. // count++;
  90. // NotificationImage img = new NotificationImage();
  91. // img.ResourceName = "icon16;
  92. // notification.Image = img;
  93. //
  94. // await LocalNotificationCenter.Current.Show(notification);
  95. // }
  96. // Application.Current.Properties["LastPushedNotifications"] = DateTime.Now;
  97. // }
  98. // catch { }
  99. // }
  100. #endregion
  101. }
  102. }