Browse Source

PRS MOBILE - removed com-al specific connection settings

Nick-PRSDigital@bitbucket.org 2 years ago
parent
commit
8b5eaf3ae0
1 changed files with 20 additions and 24 deletions
  1. 20 24
      prs.mobile/comal.timesheets/Main/App.xaml.cs

+ 20 - 24
prs.mobile/comal.timesheets/Main/App.xaml.cs

@@ -58,8 +58,6 @@ namespace comal.timesheets
 
                 LoadSettings();
 
-                ApplyComalSettings();
-
                 SaveSettings();
 
                 SetupClient();
@@ -93,24 +91,37 @@ namespace comal.timesheets
                 return;
 
             string result = "";
+
+            while (string.IsNullOrWhiteSpace(result))
+                result = TryPing();
+
+            TrySetClientType(result);
+        }
+
+        private void TrySetClientType(string result)
+        {
             try
             {
-                result = JsonClient<User>.Ping(App.DBSettings.URLs, out DatabaseInfo info);
+                ClientFactory.SetClientType(typeof(JsonClient<>), "TimeBench", MobileUtils.AppVersion.InstalledVersionNumber + App.DeviceString, result, true);
             }
             catch (Exception ex)
             {
-                var log = new MobileLogging(LogType.BackgroundProcess, "JsonClient.Ping()", ex.Message + ex.StackTrace, this.GetType().Name);
-                if (App.DBSettings.URLs[0].ToUpper().Contains("COM-AL"))
-                    result = "remote.com-al.com.au:8000";
+                var log = new MobileLogging(LogType.BackgroundProcess, "Client Factory SetClientType", ex.Message + ex.StackTrace, this.GetType().Name);
+                TrySetClientType(result);
             }
-            try
+        }
+
+        private string TryPing()
+        {         
+            try 
             {
-                ClientFactory.SetClientType(typeof(JsonClient<>), "TimeBench", MobileUtils.AppVersion.InstalledVersionNumber + App.DeviceString, result, true);
+                return JsonClient<User>.Ping(App.DBSettings.URLs, out DatabaseInfo info);
             }
             catch (Exception ex)
             {
-                var log = new MobileLogging(LogType.BackgroundProcess, "Client Factory SetClientType", ex.Message + ex.StackTrace, this.GetType().Name);
+                var log = new MobileLogging(LogType.BackgroundProcess, "JsonClient.Ping()", ex.Message + ex.StackTrace, this.GetType().Name);
             }
+            return "";
         }
 
         private bool CheckLoadFromLink()
@@ -133,21 +144,6 @@ namespace comal.timesheets
             catch { }
         }
 
-        private void ApplyComalSettings() //temporary fix
-        {
-            try
-            {
-                List<string> list = new List<string>
-            {
-                "remote.com-al.com.au:8000",
-                "remote2.com-al.com.au:8000",
-                "remote3.com-al.com.au:8000"
-            };
-
-                DBSettings.URLs = list.ToArray();
-            }
-            catch { }
-        }
 
         private void LoadSettings()
         {