Browse Source

DESKTOP - update to mobile credentials link for PRS Site app

Nick-PRSDigital@bitbucket.org 2 years ago
parent
commit
2f327f847e
1 changed files with 26 additions and 11 deletions
  1. 26 11
      prs.desktop/Panels/Users/UserGrid.cs

+ 26 - 11
prs.desktop/Panels/Users/UserGrid.cs

@@ -11,6 +11,7 @@ using InABox.Core;
 using InABox.DynamicGrid;
 using InABox.DynamicGrid;
 using InABox.Mail;
 using InABox.Mail;
 using InABox.WPF;
 using InABox.WPF;
+using NPOI.SS.Formula.Functions;
 using PRS.Shared;
 using PRS.Shared;
 using PRSDesktop.Panels.Users;
 using PRSDesktop.Panels.Users;
 using Syncfusion.Windows.Shared;
 using Syncfusion.Windows.Shared;
@@ -43,24 +44,40 @@ namespace PRSDesktop
 
 
         private bool SendEmail(CoreRow? row)
         private bool SendEmail(CoreRow? row)
         {
         {
-            if (row is null) return false;
+            if (row is null) 
+                return false;
 
 
             User user = row.ToObject<User>();
             User user = row.ToObject<User>();
 
 
-            string ioslink = @"prsmobile://open/";
-            string androidlink = @"http://www.prsmobile.com/open/";
+            var menu = new ContextMenu();
+            menu.AddItem("PRS Site App", null, () =>
+            {
+                CreateLink(user, @"prssite://open/", @"http://www.prssite.com/open/", CreateURLs(new string[] { "remote.com-al.com.au:8050" }));
+            });
+
+            menu.AddItem("PRS Timebench", null, () =>
+            {
+                CreateLink(user, @"prsmobile://open/", @"http://www.prsmobile.com/open/", CreateURLs(App.DatabaseSettings.URLs));
+            });
+            menu.IsOpen = true;    
+            return true;
+        }
+
+        private void CreateLink(User user, string ioslink, string androidlink, string URLs)
+        {
+            if (string.IsNullOrWhiteSpace(ioslink))
+                return;
 
 
-            int expiry = 10;
             var edt = new NumberEdit("Enter link expiry time in minutes", 10, 300, 10);
             var edt = new NumberEdit("Enter link expiry time in minutes", 10, 300, 10);
-            var result = edt.ShowDialog();
-            if (result == true)
-                expiry = edt.Value;
+            bool result = (bool)edt.ShowDialog();
+            if (!result)
+                return;
 
 
-            string URLs = CreateURLs(App.DatabaseSettings.URLs);
+            var expiry = edt.Value;
 
 
             string toEncrypt = URLs + "," + user.UserID + "," + user.Password + "," + DateTime.Now.AddMinutes(expiry);
             string toEncrypt = URLs + "," + user.UserID + "," + user.Password + "," + DateTime.Now.AddMinutes(expiry);
             string encrypted = Encryption.Encrypt(toEncrypt, "logindetailslink", true);
             string encrypted = Encryption.Encrypt(toEncrypt, "logindetailslink", true);
-            
+
             ioslink = ioslink + encrypted;
             ioslink = ioslink + encrypted;
             androidlink = androidlink + encrypted;
             androidlink = androidlink + encrypted;
 
 
@@ -71,8 +88,6 @@ namespace PRSDesktop
                 "These links will expire after " + expiry + " minutes.";
                 "These links will expire after " + expiry + " minutes.";
 
 
             EmailUtils.CreateEMLFile(user.EmailAddress, "PRS Mobile Configuration Links", emailcontent);
             EmailUtils.CreateEMLFile(user.EmailAddress, "PRS Mobile Configuration Links", emailcontent);
-
-            return true;
         }
         }
 
 
         private string CreateURLs(string[] urls)
         private string CreateURLs(string[] urls)