| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 | using System;using System.Collections.Generic;using System.Linq;using System.Threading;using System.Threading.Tasks;using Xamarin.Forms;using InABox.Core;using InABox.Clients;using InABox.Mobile;using Comal.Classes;using comal.timesheets.CustomControls;using PRSSecurity = InABox.Core.Security;using Plugin.LocalNotification;namespace comal.timesheets{    public delegate void MainPageNotificationsChanged();    public delegate void RefreshScreen();    public delegate void RequestUserInputForTask(Guid taskID);    public delegate void TaskTitleChanged(string title);        public static class MainPageUtils    {        public static event MainPageNotificationsChanged OnMainPageNotificationsChanged;        public static event RequestUserInputForTask OnRequestUserInput;        public static event TaskTitleChanged OnTaskTitleChanged;                #region Notifications        // public static Page DetermineCorrectPage(Plugin.LocalNotification.EventArgs.NotificationActionEventArgs e)        // {        //     string data = e.Request.ReturningData;        //     int index = data.IndexOf("$");        //     Guid ID = Guid.Parse(data.Remove(index));        //     string type = data.Substring(index + 1);        //     if (type == "Comal.Classes.Kanban")        //         return new AddEditTask(ID);        //     else if (type == "Comal.Classes.Delivery")        //         return new DeliveryDetails(ID);        //     else        //         return null;        // }        //        // private static void CheckNotificationsPushed(CoreTable table)        // {        //     try        //     {        //         if (!Application.Current.Properties.ContainsKey("LastPushedNotifications"))        //         {        //             Application.Current.Properties.Add("LastPushedNotifications", DateTime.Now);        //         }        //         DateTime lastPushed = DateTime.Parse(Application.Current.Properties["LastPushedNotifications"].ToString());        //         List<NotificationShell> toNotify = new List<NotificationShell>();        //         foreach (CoreRow row in table.Rows)        //         {        //             List<object> list = row.Values;        //             DateTime created = DateTime.Parse(list[3].ToString());        //             if (created > new DateTime(2022, 8, 22)) // prevent spam from buildup of old notifications before this is released        //             {        //                 if (created > lastPushed)        //                 {        //                     if (list[1] == null) list[1] = "";        //                     if (list[2] == null) list[2] = "";        //                     if (list[3] == null) list[3] = DateTime.MinValue;        //                     if (list[4] == null) list[4] = "";        //                     if (list[5] == null) list[5] = "";        //                     if (list[6] == null) list[6] = Guid.Empty;        //        //                     NotificationShell shell = new NotificationShell        //                     {        //                         ID = Guid.Parse(list[0].ToString()),        //                         Sender = list[1].ToString(),        //                         Title = list[2].ToString(),        //                         Created = DateTime.Parse(list[3].ToString()),        //                         EntityType = list[5].ToString(),        //                         EntityID = Guid.Parse(list[6].ToString())        //                     };        //                     toNotify.Add(shell); //add notification to be pushed        //                 }        //             }        //         }        //         if (toNotify.Count > 0)        //             PushNotificationsAsync(toNotify);        //     }        //     catch { }        // }        //        // private static async Task PushNotificationsAsync(string title, )        // {        //     try        //     {        //         int count = 1;        //        //         foreach (NotificationShell shell in shells)        //         {        //             var notification = new NotificationRequest        //             {        //                 BadgeNumber = 1,        //                 Description = title,        //                 Title = "New PRS Notification: ",        //                 ReturningData = shell.EntityID.ToString() + "$" + shell.EntityType,        //                 NotificationId = count,        //             };        //             count++;        //             NotificationImage img = new NotificationImage();        //             img.ResourceName = "icon16.png";        //             notification.Image = img;        //        //             await LocalNotificationCenter.Current.Show(notification);        //         }        //         Application.Current.Properties["LastPushedNotifications"] = DateTime.Now;        //     }        //     catch { }        // }        #endregion            }}
 |