Просмотр исходного кода

PRS MOBILE - view delivery from Notification

Nick-PRSDigital@bitbucket.org 2 лет назад
Родитель
Сommit
162d0048c8

+ 59 - 0
prs.mobile/comal.timesheets/Data Classes/NotifyChanges.cs

@@ -0,0 +1,59 @@
+using InABox.Mobile;
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Xamarin.Forms;
+
+namespace comal.timesheets
+{
+    public static class NotifyMobileChanges
+    {
+        public static string Notifiy()
+        {
+            RemoveOldProperties();
+
+            string latestChanges = "";
+            List<string> changes = new List<string>
+                {
+                "- Improvement to Site Manufacturing search",
+                "- Improve speed + fixes to Store Requis"
+                };
+            foreach (string s in changes)
+            {
+                latestChanges = s + System.Environment.NewLine + latestChanges;
+            }
+            if (App.Current.Properties.ContainsKey("NotifiedOfChanges" + MobileUtils.AppVersion.InstalledVersionNumber))
+                return "";
+            else
+            {
+                App.Current.Properties.Add("NotifiedOfChanges" + MobileUtils.AppVersion.InstalledVersionNumber, "True");
+                return latestChanges;
+            }
+            
+        }
+
+        private static void RemoveOldProperties()
+        {
+            if (App.Current.Properties.Count > 0)
+            {
+                List<string> toDelete = new List<string>();
+                foreach (string s in App.Current.Properties.Keys)
+                {
+                    if (s.Contains("NotifiedOfChanges"))
+                    {
+                        if (!s.Equals("NotifiedOfChanges" + MobileUtils.AppVersion.InstalledVersionNumber))
+                        {
+                            toDelete.Add(s);
+                        }
+                    }
+                }
+                foreach (string s in toDelete)
+                {
+                    App.Current.Properties.Remove(s);
+                }
+            }
+        }
+    }
+}

+ 15 - 40
prs.mobile/comal.timesheets/Main/MainPage.xaml.cs

@@ -106,47 +106,14 @@ namespace comal.timesheets
 
         private void NotifyChanges()
         {
-            string latestChanges = "";
-            List<string> changes = new List<string>
+            Task.Run(() => 
             {
-                "- Improvement to Site Manufacturing search",
-                "- Improve speed + fixes to Store Requis"
-            };
-            foreach (string s in changes)
-            {
-                latestChanges = s + System.Environment.NewLine + latestChanges;
-            }
-
-            Task.Run(() =>
-            {
-                if (App.Current.Properties.Count > 0)
-                {
-                    List<string> toDelete = new List<string>();
-                    foreach (string s in App.Current.Properties.Keys)
-                    {
-                        if (s.Contains("NotifiedOfChanges"))
-                        {
-                            if (!s.Equals("NotifiedOfChanges" + MobileUtils.AppVersion.InstalledVersionNumber))
-                            {
-                                toDelete.Add(s);
-                            }
-                        }
-                    }
-                    foreach (string s in toDelete)
+                string changes = NotifyMobileChanges.Notifiy();
+                if (!string.IsNullOrWhiteSpace(changes))
+                    Device.BeginInvokeOnMainThread(() => 
                     {
-                        App.Current.Properties.Remove(s);
-                    }
-                }
-                if (!App.Current.Properties.ContainsKey("NotifiedOfChanges" + MobileUtils.AppVersion.InstalledVersionNumber))
-                {
-                    App.Current.Properties.Add("NotifiedOfChanges" + MobileUtils.AppVersion.InstalledVersionNumber, "True");
-                    Thread.Sleep(7500);
-                    Device.BeginInvokeOnMainThread(() =>
-                    {
-                        DisplayAlert("Latest Changes", latestChanges
-                            , "OK");
+                        DisplayAlert("Latest changes", changes, "OK");
                     });
-                }
             });
         }
         #endregion
@@ -684,8 +651,16 @@ namespace comal.timesheets
                     {
                         Device.BeginInvokeOnMainThread(() =>
                         {
-                            AddEditTask taskPage = new AddEditTask(ID);
-                            Navigation.PushAsync(taskPage);
+                            AddEditTask page = new AddEditTask(ID);
+                            Navigation.PushAsync(page);
+                        });
+                    }
+                    else if (type == "Comal.Classes.Delivery")
+                    {
+                        Device.BeginInvokeOnMainThread(() =>
+                        {
+                            DeliveryDetails page = new DeliveryDetails(ID);
+                            Navigation.PushAsync(page);
                         });
                     }
                 };

+ 25 - 15
prs.mobile/comal.timesheets/NotificationsManager/NotificationList.xaml.cs

@@ -104,11 +104,11 @@ namespace comal.timesheets
         #endregion
 
         #region Buttons / Taps
-        private void NotificationListView_Tapped(object sender, EventArgs e)
+        private async void NotificationListView_Tapped(object sender, EventArgs e)
         {
             NotificationShell shell = notificationListView.SelectedItem as NotificationShell;
             string extra = CreateOption(shell);
-            string chosenOption = ChooseOption(extra, shell).Result;
+            string chosenOption = await DisplayActionSheet(shell.Description, "Cancel", null, "View / Reply Message", "Dismiss Message", extra);
             ProcessOption(chosenOption, shell);
         }
 
@@ -124,20 +124,29 @@ namespace comal.timesheets
                 case "Dismiss Message":
                     DismissNotification(shell);
                     break;
-                case "View Task":
+                case VIEWTASK:
                     ViewTask(shell);
                     break;
-                case "View Leave":
+                case VIEWLEAVE:
                     OpenLeaveList();
                     break;
-                case "View Request Form":
+                case VIEWLEAVEFORM:
                     ViewRequestForm(shell);
                     break;
+                case VIEWDELIVERY:
+                    ViewDelivery(shell);
+                    break;
                 default:
                     return;
             }
         }
 
+        private void ViewDelivery(NotificationShell shell)
+        {
+            DeliveryDetails page = new DeliveryDetails(shell.EntityID);
+            Navigation.PushAsync(page);
+        }
+
         private void ViewRequestForm(NotificationShell shell)
         {
             DigitalFormHostModel<LeaveRequest, LeaveRequestLink, LeaveRequestForm> model = new DigitalFormHostModel<LeaveRequest, LeaveRequestLink, LeaveRequestForm>();
@@ -168,25 +177,26 @@ namespace comal.timesheets
             Navigation.PushAsync(leaveRequestList);
         }
 
+        const string VIEWTASK = "View Task";
+        const string VIEWLEAVE = "View Leave";
+        const string VIEWLEAVEFORM = "View Leave Request Form";
+        const string VIEWDELIVERY = "View Delivery";
+
         private string CreateOption(NotificationShell shell)
         {
-            if (!string.IsNullOrWhiteSpace(shell.EntityType))
+            if (string.IsNullOrWhiteSpace(shell.EntityType))
                 return "";
             if (shell.EntityType == "Comal.Classes.Kanban")
-                return "View Task";
+                return VIEWTASK;
             if (shell.EntityType == "Comal.Classes.LeaveRequest")
-                return "View Leave";
+                return VIEWLEAVE;
             if (shell.EntityType == "Comal.Classes.LeaveRequestLink")
-                return "View Request Form";
+                return VIEWLEAVEFORM;
+            if (shell.EntityType == "Comal.Classes.Delivery")
+                return VIEWDELIVERY;
             else
                 return "";
         }
-
-        private async Task<string> ChooseOption(string extra, NotificationShell shell)
-        {
-            string chosenOption = await DisplayActionSheet(shell.Description, "Cancel", null, "View / Reply Message", "Dismiss Message", extra);
-            return chosenOption;
-        }
         protected override void OnDisappearing()
         {
             NotificationsClosed?.Invoke(notificationShells.Count());

+ 1 - 0
prs.mobile/comal.timesheets/comal.timesheets.projitems

@@ -160,6 +160,7 @@
     <Compile Include="$(MSBuildThisFileDirectory)Assignments\DataModels\Lookups\AssignmentLookupDataModel.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)Assignments\IAssignmentPage.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)CacheLoader.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)Data Classes\NotifyChanges.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)DigitalFormsHelper.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)DigitalForms\CustomUserControls\DigitalFormsHeader.xaml.cs">
       <DependentUpon>DigitalFormsHeader.xaml</DependentUpon>