Browse Source

Support for PRS MOBILE new login system

Nick-PRSDigital@bitbucket.org 2 years ago
parent
commit
e69810ae2d

+ 25 - 11
InABox.Mobile/Shared/MobileUtils.cs

@@ -18,6 +18,7 @@ using PermissionStatus = Plugin.Permissions.Abstractions.PermissionStatus;
 using InABox.Core;
 using InABox.Clients;
 using InABox.Configuration;
+using Comal.Classes;
 
 namespace InABox.Mobile
 {
@@ -65,10 +66,20 @@ namespace InABox.Mobile
         {
             try
             {
-                SecureStorage.SetAsync(GlobalVariables.CacheURLString, App.Settings.URL);
-                SecureStorage.SetAsync(GlobalVariables.CachePortString, App.Settings.Port.ToString());
-                SecureStorage.SetAsync(GlobalVariables.CacheUserIDString, App.Settings.UserID);
-                SecureStorage.SetAsync(GlobalVariables.CachePasswordString, App.Settings.Password);
+                if (!string.IsNullOrWhiteSpace(App.Settings.UserID))
+                    SecureStorage.SetAsync(GlobalVariables.CacheUserIDString, App.Settings.UserID);
+
+                if (!string.IsNullOrWhiteSpace(App.Settings.Password))
+                    SecureStorage.SetAsync(GlobalVariables.CachePasswordString, App.Settings.Password);
+
+                if (App.DBSettings.URLs.Count() > 0)
+                    SecureStorage.SetAsync(GlobalVariables.CacheSettingsURL1, App.DBSettings.URLs[0]);
+
+                if (App.DBSettings.URLs.Count() > 1)
+                    SecureStorage.SetAsync(GlobalVariables.CacheSettingsURL2, App.DBSettings.URLs[1]);
+
+                if (App.DBSettings.URLs.Count() > 2)
+                    SecureStorage.SetAsync(GlobalVariables.CacheSettingsURL3, App.DBSettings.URLs[2]);
             }
             catch { }
         }
@@ -100,14 +111,17 @@ namespace InABox.Mobile
             catch (Exception e)
             {
                 if (String.IsNullOrWhiteSpace(App.Settings.URL))
-                    LoadDemoSettings(App.Settings);
+                    LoadDemoSettings(App.DBSettings);
             }
         }
 
-        public static void LoadDemoSettings(ConnectionSettings settings)
+        public static void LoadDemoSettings(DatabaseSettings settings)
         {
-            settings.URL = "http://demo.prsdigital.com.au";
-            settings.Port = 8003;
+            List<string> list = new List<string>();
+            list.Add("http://demo.prsdigital.com.au:8003");
+            list.Add("http://demo2.prsdigital.com.au:8003");
+            list.Add("http://demo3.prsdigital.com.au:8003");
+            settings.URLs = list.ToArray();
             settings.UserID = "GUEST";
             settings.Password = "guest";
         }
@@ -161,7 +175,7 @@ namespace InABox.Mobile
             catch (System.Threading.Tasks.TaskCanceledException ex)
             {
                 return false;
-            }            
+            }
 
             //request.Wait();
             //var statuses = request.Result;
@@ -196,7 +210,7 @@ namespace InABox.Mobile
             bool request = false;
             if (permissionStatus == PermissionStatus.Denied)
             {
-                if (String.Equals(Device.RuntimePlatform,Device.iOS))
+                if (String.Equals(Device.RuntimePlatform, Device.iOS))
                 {
 
                     var title = $"{permission} Permission";
@@ -244,6 +258,6 @@ namespace InABox.Mobile
 
             return true;
         }
-    
+
     }
 }

+ 2 - 2
inabox.client.websocket/WebSocketClient.cs

@@ -22,8 +22,8 @@ namespace InABox.Client.WebSocket
         public WebSocketClient(string url, int port, Guid session)
         {
             Session = session;
-
-            Socket = new Socket($"ws://{url}:{port}/notify");
+            Uri uri = new Uri("http://" + url);
+            Socket = new Socket($"ws://{uri.Host}:{port}/notify");
             Socket.OnOpen += Socket_OnOpen;
             Socket.OnError += Socket_OnError;
             Socket.OnClose += Socket_OnClose;

+ 9 - 17
inabox.wpf/DigitalForms/Designer/Controls/Fields/DFVideoControl.cs

@@ -28,7 +28,7 @@ namespace InABox.DynamicGrid
 
             grid.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
             grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
-            
+
 
             PlayButton = new Button
             {
@@ -50,7 +50,7 @@ namespace InABox.DynamicGrid
                 Height = 25,
                 Margin = new Thickness(5),
                 Visibility = Visibility.Hidden
-            }; 
+            };
             PauseButton.Content = new Image
             {
                 Source = Wpf.Resources.pause_button.AsBitmapImage()
@@ -62,7 +62,6 @@ namespace InABox.DynamicGrid
             Player.Stretch = System.Windows.Media.Stretch.Fill;
             Player.Visibility = Visibility.Visible;
             Player.SetGridPosition(1, 0, 1, 2);
-            
 
             grid.Children.Add(PlayButton);
             grid.Children.Add(PauseButton);
@@ -73,20 +72,13 @@ namespace InABox.DynamicGrid
 
         private void PlayButton_Click(object sender, RoutedEventArgs e)
         {
-            //if(firstPlay) 
-            //{
-                var path = System.IO.Path.GetTempFileName();
-                path = path.Substring(0, path.Length - 4) + ".mp4";
-
-                System.IO.File.WriteAllBytes(path, GetValue());
-                Player.Source = new Uri(path);
-
-                firstPlay = false;
-            //}
-            //else
-            //    Player.Play();
-            //PlayButton.Visibility = Visibility.Hidden;
-            //PauseButton.Visibility = Visibility.Visible;
+            var path = System.IO.Path.GetTempFileName();
+            path = path.Substring(0, path.Length - 4) + ".mp4";
+
+            System.IO.File.WriteAllBytes(path, GetValue());
+            Player.Source = new Uri(path);
+
+            firstPlay = false;
         }
 
         private void PauseButton_Click(object sender, RoutedEventArgs e)