浏览代码

PRS MOBILE - update to RestSharp v11 and RestClient required changes

Nick-PRSDigital@bitbucket.org 2 年之前
父节点
当前提交
d73a0c691e

+ 56 - 0
prs.mobile/comal.timesheet.sln

@@ -38,6 +38,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InABox.Client.Remote.Json",
 EndProject
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PdfiumAndroid", "..\..\3rdpartylibs\pdfium-android\PdfiumAndroid\PdfiumAndroid\PdfiumAndroid.csproj", "{63845795-416F-4848-9DC1-63E992803D29}"
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PdfiumAndroid", "..\..\3rdpartylibs\pdfium-android\PdfiumAndroid\PdfiumAndroid\PdfiumAndroid.csproj", "{63845795-416F-4848-9DC1-63E992803D29}"
 EndProject
 EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InABox.Client.Rest", "..\..\inabox\inabox.client.rest\InABox.Client.Rest\InABox.Client.Rest.csproj", "{9C7FF90A-062F-4C26-9D29-D25E405BCB65}"
+EndProject
 Global
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
 		Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
@@ -701,6 +703,60 @@ Global
 		{63845795-416F-4848-9DC1-63E992803D29}.STATIC_ONLY NO_EXPRESSIONS|iPhone.Build.0 = Debug|Any CPU
 		{63845795-416F-4848-9DC1-63E992803D29}.STATIC_ONLY NO_EXPRESSIONS|iPhone.Build.0 = Debug|Any CPU
 		{63845795-416F-4848-9DC1-63E992803D29}.STATIC_ONLY NO_EXPRESSIONS|iPhoneSimulator.ActiveCfg = Debug|Any CPU
 		{63845795-416F-4848-9DC1-63E992803D29}.STATIC_ONLY NO_EXPRESSIONS|iPhoneSimulator.ActiveCfg = Debug|Any CPU
 		{63845795-416F-4848-9DC1-63E992803D29}.STATIC_ONLY NO_EXPRESSIONS|iPhoneSimulator.Build.0 = Debug|Any CPU
 		{63845795-416F-4848-9DC1-63E992803D29}.STATIC_ONLY NO_EXPRESSIONS|iPhoneSimulator.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.AppStore|Any CPU.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.AppStore|iPhone.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.CodeAnalysis|Any CPU.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.CodeAnalysis|Any CPU.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.CodeAnalysis|iPhone.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.CodeAnalysis|iPhone.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.CodeAnalysis|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.CodeAnalysis|iPhoneSimulator.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Debug|iPhone.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Instrument|Any CPU.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Instrument|Any CPU.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Instrument|iPhone.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Instrument|iPhone.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Instrument|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Instrument|iPhoneSimulator.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.MonoTouch|Any CPU.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.MonoTouch|Any CPU.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.MonoTouch|iPhone.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.MonoTouch|iPhone.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.MonoTouch|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.MonoTouch|iPhoneSimulator.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.PerformanceTest|Any CPU.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.PerformanceTest|Any CPU.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.PerformanceTest|iPhone.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.PerformanceTest|iPhone.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.PerformanceTest|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.PerformanceTest|iPhoneSimulator.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Release|Any CPU.Build.0 = Release|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Release|iPhone.ActiveCfg = Release|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Release|iPhone.Build.0 = Release|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.STATIC_ONLY NO_EXPRESSIONS|Any CPU.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.STATIC_ONLY NO_EXPRESSIONS|iPhone.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.STATIC_ONLY NO_EXPRESSIONS|iPhone.Build.0 = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.STATIC_ONLY NO_EXPRESSIONS|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+		{9C7FF90A-062F-4C26-9D29-D25E405BCB65}.STATIC_ONLY NO_EXPRESSIONS|iPhoneSimulator.Build.0 = Debug|Any CPU
 	EndGlobalSection
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 		HideSolutionNode = FALSE

+ 0 - 1
prs.mobile/comal.timesheets.Android/Resources/Resource.designer.cs

@@ -2,7 +2,6 @@
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 // <auto-generated>
 // <auto-generated>
 //     This code was generated by a tool.
 //     This code was generated by a tool.
-//     Runtime Version:4.0.30319.42000
 //
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     Changes to this file may cause incorrect behavior and will be lost if
 //     the code is regenerated.
 //     the code is regenerated.

+ 4 - 0
prs.mobile/comal.timesheets.Android/comal.timesheets.Android.csproj

@@ -724,6 +724,10 @@
       <Project>{67b6cae5-188b-42a0-ae5d-0e5c6049a910}</Project>
       <Project>{67b6cae5-188b-42a0-ae5d-0e5c6049a910}</Project>
       <Name>InABox.Client.Remote.Json</Name>
       <Name>InABox.Client.Remote.Json</Name>
     </ProjectReference>
     </ProjectReference>
+    <ProjectReference Include="..\..\..\inabox\inabox.client.rest\InABox.Client.Rest\InABox.Client.Rest.csproj">
+      <Project>{9c7ff90a-062f-4c26-9d29-d25e405bcb65}</Project>
+      <Name>InABox.Client.Rest</Name>
+    </ProjectReference>
     <ProjectReference Include="..\..\..\inabox\inabox.client.websocket\InABox.Client.WebSocket.csproj">
     <ProjectReference Include="..\..\..\inabox\inabox.client.websocket\InABox.Client.WebSocket.csproj">
       <Project>{2a9b17ee-ee09-4b7f-8d14-3745c2449005}</Project>
       <Project>{2a9b17ee-ee09-4b7f-8d14-3745c2449005}</Project>
       <Name>InABox.Client.WebSocket</Name>
       <Name>InABox.Client.WebSocket</Name>

+ 45 - 8
prs.mobile/comal.timesheets/Main/App.xaml.cs

@@ -16,6 +16,7 @@ using SkiaSharp;
 using System.Threading;
 using System.Threading;
 using System.Linq;
 using System.Linq;
 using System.Collections.Generic;
 using System.Collections.Generic;
+using InABox.Clients;
 
 
 //[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
 //[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
 namespace comal.timesheets
 namespace comal.timesheets
@@ -90,10 +91,7 @@ namespace comal.timesheets
             if (CheckLoadFromLink())
             if (CheckLoadFromLink())
                 return;
                 return;
 
 
-            string result = "";
-
-            while (string.IsNullOrWhiteSpace(result))
-                result = TryPing();
+            string result = RestClient<User>.Ping(App.DBSettings.URLs, out DatabaseInfo info);
 
 
             TrySetClientType(result);
             TrySetClientType(result);
         }
         }
@@ -102,7 +100,7 @@ namespace comal.timesheets
         {
         {
             try
             try
             {
             {
-                ClientFactory.SetClientType(typeof(JsonClient<>), "TimeBench", MobileUtils.AppVersion.InstalledVersionNumber + App.DeviceString, result, true);
+                ClientFactory.SetClientType(typeof(RestClient<>), InABox.Core.Platform.Mobile, MobileUtils.AppVersion.InstalledVersionNumber + App.DeviceString, result, true);
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
@@ -112,10 +110,10 @@ namespace comal.timesheets
         }
         }
 
 
         private string TryPing()
         private string TryPing()
-        {         
-            try 
+        {
+            try
             {
             {
-                return JsonClient<User>.Ping(App.DBSettings.URLs, out DatabaseInfo info);
+                return RestClient<User>.Ping(App.DBSettings.URLs, out DatabaseInfo info);
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
@@ -149,6 +147,8 @@ namespace comal.timesheets
         {
         {
             try
             try
             {
             {
+                DBSettings = new DatabaseSettings();
+
                 Settings = new LocalConfiguration<ConnectionSettings>().Load();
                 Settings = new LocalConfiguration<ConnectionSettings>().Load();
 
 
                 DBSettings = new LocalConfiguration<DatabaseSettings>().Load();
                 DBSettings = new LocalConfiguration<DatabaseSettings>().Load();
@@ -157,10 +157,47 @@ namespace comal.timesheets
                     DBSettings.UserID = Settings.UserID;
                     DBSettings.UserID = Settings.UserID;
                 if (!string.IsNullOrWhiteSpace(Settings.Password) && string.IsNullOrWhiteSpace(DBSettings.Password))
                 if (!string.IsNullOrWhiteSpace(Settings.Password) && string.IsNullOrWhiteSpace(DBSettings.Password))
                     DBSettings.Password = Settings.Password;
                     DBSettings.Password = Settings.Password;
+
+                //ApplyTestSettings();
+
+                if (string.IsNullOrWhiteSpace(DBSettings.UserID)
+                    && string.IsNullOrWhiteSpace(DBSettings.Password)
+                    && DBUrlsBlank())
+                    ApplyDemoSettings();
+                if (DBUrlsBlank())
+                    ApplyDemoURLS();
             }
             }
             catch { }
             catch { }
         }
         }
 
 
+        private void ApplyTestSettings()
+        {
+            DBSettings.UserID = "TAN";
+            DBSettings.Password = "nictan";
+            DBSettings.URLs[0] = "remote.com-al.com.au:8000";
+        }
+
+        private void ApplyDemoURLS()
+        {
+            DBSettings.URLs[0] = "demo.prsdigital.com.au:8003";
+            DBSettings.URLs[1] = "demo2.prsdigital.com.au:8003";
+            DBSettings.URLs[2] = "demo3.prsdigital.com.au:8003";
+        }
+
+        private void ApplyDemoSettings()
+        {
+            DBSettings.UserID = "GUEST";
+            DBSettings.Password = "guest";
+            ApplyDemoURLS();
+        }
+
+        private bool DBUrlsBlank()
+        {
+            if (DBSettings.URLs.Count() == 0 || string.IsNullOrWhiteSpace(DBSettings.URLs[0]))
+                return true;
+            else return false;
+        }
+
         private void InitAndRegister()
         private void InitAndRegister()
         {
         {
             try
             try

+ 3 - 3
prs.mobile/comal.timesheets/Main/PINLoginPage.xaml.cs

@@ -204,17 +204,17 @@ namespace comal.timesheets
                     string result = "";
                     string result = "";
                     try
                     try
                     {
                     {
-                        result = JsonClient<User>.Ping(App.DBSettings.URLs, out DatabaseInfo info);
+                        result = RestClient<User>.Ping(App.DBSettings.URLs, out DatabaseInfo info);
                     }
                     }
                     catch (Exception ex)
                     catch (Exception ex)
                     {
                     {
-                        var log = new MobileLogging(LogType.BackgroundProcess, "JsonClient.Ping()", ex.Message + ex.StackTrace, this.GetType().Name);
+                        var log = new MobileLogging(LogType.BackgroundProcess, "RestClient.Ping()", ex.Message + ex.StackTrace, this.GetType().Name);
                         if (App.DBSettings.URLs[0].ToUpper().Contains("COM-AL"))
                         if (App.DBSettings.URLs[0].ToUpper().Contains("COM-AL"))
                             result = "remote.com-al.com.au:8000";
                             result = "remote.com-al.com.au:8000";
                     }
                     }
                     try
                     try
                     {
                     {
-                        ClientFactory.SetClientType(typeof(JsonClient<>), "TimeBench", MobileUtils.AppVersion.InstalledVersionNumber + App.DeviceString, result, true);
+                        ClientFactory.SetClientType(typeof(RestClient<>), InABox.Core.Platform.Mobile, MobileUtils.AppVersion.InstalledVersionNumber + App.DeviceString, result, true);
                     }
                     }
                     catch (Exception ex)
                     catch (Exception ex)
                     {
                     {

+ 1 - 1
prs.mobile/comal.timesheets/Main/Settings.xaml.cs

@@ -82,7 +82,7 @@ namespace comal.timesheets
                     new LocalConfiguration<ConnectionSettings>().Delete();
                     new LocalConfiguration<ConnectionSettings>().Delete();
                     new LocalConfiguration<ConnectionSettings>().Save(App.Settings);
                     new LocalConfiguration<ConnectionSettings>().Save(App.Settings);
                     App.Settings = new LocalConfiguration<ConnectionSettings>().Load();
                     App.Settings = new LocalConfiguration<ConnectionSettings>().Load();
-                    ClientFactory.SetClientType(typeof(JsonClient<>), "TimeBench", MobileUtils.AppVersion.InstalledVersionNumber + GlobalVariables.DeviceString, new object[] { App.Settings.URL, App.Settings.Port, true });
+                    ClientFactory.SetClientType(typeof(RestClient<>), InABox.Core.Platform.Mobile, MobileUtils.AppVersion.InstalledVersionNumber + GlobalVariables.DeviceString, new object[] { App.Settings.URL, App.Settings.Port, true });
 
 
                     GlobalVariables.ChangeUser = true;
                     GlobalVariables.ChangeUser = true;
                     GlobalVariables.InternalOnAppearing = true;
                     GlobalVariables.InternalOnAppearing = true;

+ 2 - 2
prs.mobile/comal.timesheets/SettingsPage.xaml.cs

@@ -72,9 +72,9 @@ namespace comal.timesheets
                     if (App.Current.Properties.ContainsKey("SessionID"))
                     if (App.Current.Properties.ContainsKey("SessionID"))
                         App.Current.Properties.Remove("SessionID");
                         App.Current.Properties.Remove("SessionID");
 
 
-                    var result = JsonClient<User>.Ping(App.DBSettings.URLs, out DatabaseInfo info);
+                    var result = RestClient<User>.Ping(App.DBSettings.URLs, out DatabaseInfo info);
 
 
-                    ClientFactory.SetClientType(typeof(JsonClient<>), "TimeBench", MobileUtils.AppVersion.InstalledVersionNumber + GlobalVariables.DeviceString, result, true);
+                    ClientFactory.SetClientType(typeof(RestClient<>), InABox.Core.Platform.Mobile, MobileUtils.AppVersion.InstalledVersionNumber + GlobalVariables.DeviceString, result, true);
 
 
                     GlobalVariables.ChangeUser = true;
                     GlobalVariables.ChangeUser = true;
                     GlobalVariables.InternalOnAppearing = true;
                     GlobalVariables.InternalOnAppearing = true;