Browse Source

PRS MOBILE - version 7.14.6, connection test changes

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

+ 14 - 0
prs.mobile/ConnectionTestApp/ConnectionTest.sln

@@ -33,6 +33,8 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "InABox.Remote.Shared", "..\
 EndProject
 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InABox.WebSocket.Shared", "..\..\..\inabox\inabox.websocket.shared\InABox.WebSocket.Shared.csproj", "{4057A462-4A28-46D6-BF75-12E1D494F3ED}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PRSClasses", "..\..\prs.classes\PRSClasses.csproj", "{21814563-A9B8-483D-A635-FE9EC7BB1ACB}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -153,6 +155,18 @@ Global
 		{4057A462-4A28-46D6-BF75-12E1D494F3ED}.Release|iPhone.Build.0 = Release|Any CPU
 		{4057A462-4A28-46D6-BF75-12E1D494F3ED}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
 		{4057A462-4A28-46D6-BF75-12E1D494F3ED}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
+		{21814563-A9B8-483D-A635-FE9EC7BB1ACB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{21814563-A9B8-483D-A635-FE9EC7BB1ACB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{21814563-A9B8-483D-A635-FE9EC7BB1ACB}.Debug|iPhone.ActiveCfg = Debug|Any CPU
+		{21814563-A9B8-483D-A635-FE9EC7BB1ACB}.Debug|iPhone.Build.0 = Debug|Any CPU
+		{21814563-A9B8-483D-A635-FE9EC7BB1ACB}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
+		{21814563-A9B8-483D-A635-FE9EC7BB1ACB}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
+		{21814563-A9B8-483D-A635-FE9EC7BB1ACB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{21814563-A9B8-483D-A635-FE9EC7BB1ACB}.Release|Any CPU.Build.0 = Release|Any CPU
+		{21814563-A9B8-483D-A635-FE9EC7BB1ACB}.Release|iPhone.ActiveCfg = Release|Any CPU
+		{21814563-A9B8-483D-A635-FE9EC7BB1ACB}.Release|iPhone.Build.0 = Release|Any CPU
+		{21814563-A9B8-483D-A635-FE9EC7BB1ACB}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
+		{21814563-A9B8-483D-A635-FE9EC7BB1ACB}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 6 - 2
prs.mobile/ConnectionTestApp/ConnectionTest/ConnectionTest.Android/ConnectionTest.Android.csproj

@@ -58,8 +58,8 @@
     <Reference Include="System.Numerics.Vectors" />
   </ItemGroup>
   <ItemGroup>
-    <PackageReference Include="Xamarin.Forms" Version="5.0.0.2196" />
-    <PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
+    <PackageReference Include="Xamarin.Forms" Version="5.0.0.2578" />
+    <PackageReference Include="Xamarin.Essentials" Version="1.7.5" />
   </ItemGroup>
   <ItemGroup>
     <Compile Include="MainActivity.cs" />
@@ -119,6 +119,10 @@
       <Project>{7FF8B7BA-16F4-4BD4-AA39-FC766952DEA6}</Project>
       <Name>ConnectionTest</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\..\..\prs.classes\PRSClasses.csproj">
+      <Project>{21814563-A9B8-483D-A635-FE9EC7BB1ACB}</Project>
+      <Name>PRSClasses</Name>
+    </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
 </Project>

+ 1 - 0
prs.mobile/ConnectionTestApp/ConnectionTest/ConnectionTest.Android/Resources/Resource.designer.cs

@@ -2,6 +2,7 @@
 //------------------------------------------------------------------------------
 // <auto-generated>
 //     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
 //     the code is regenerated.

+ 1 - 0
prs.mobile/ConnectionTestApp/ConnectionTest/ConnectionTest.iOS/AppDelegate.cs

@@ -23,6 +23,7 @@ namespace ConnectionTest.iOS
         public override bool FinishedLaunching(UIApplication app, NSDictionary options)
         {
             global::Xamarin.Forms.Forms.Init();
+
             LoadApplication(new App());
 
             return base.FinishedLaunching(app, options);

+ 6 - 4
prs.mobile/ConnectionTestApp/ConnectionTest/ConnectionTest.iOS/ConnectionTest.iOS.csproj

@@ -125,16 +125,18 @@
     <Reference Include="System.Net.Http" />
   </ItemGroup>
   <ItemGroup>
-    <PackageReference Include="Xamarin.Forms" Version="5.0.0.2196" />
-    <PackageReference Include="Xamarin.Essentials" Version="1.7.0" />
+    <PackageReference Include="Xamarin.Forms" Version="5.0.0.2578" />
+    <PackageReference Include="Xamarin.Essentials" Version="1.7.5" />
   </ItemGroup>
-  <Import Project="..\..\..\inabox\InABox.Remote.Shared\InABox.Remote.Shared.projitems" Label="Shared" Condition="Exists('..\..\..\inabox\InABox.Remote.Shared\InABox.Remote.Shared.projitems')" />
-  <Import Project="..\..\..\inabox\InABox.Client.Remote.Shared\InABox.Client.Remote.Shared.projitems" Label="Shared" Condition="Exists('..\..\..\inabox\InABox.Client.Remote.Shared\InABox.Client.Remote.Shared.projitems')" />
   <Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
   <ItemGroup>
     <ProjectReference Include="..\ConnectionTest\ConnectionTest.csproj">
       <Project>{7FF8B7BA-16F4-4BD4-AA39-FC766952DEA6}</Project>
       <Name>ConnectionTest</Name>
     </ProjectReference>
+    <ProjectReference Include="..\..\..\..\prs.classes\PRSClasses.csproj">
+      <Project>{21814563-A9B8-483D-A635-FE9EC7BB1ACB}</Project>
+      <Name>PRSClasses</Name>
+    </ProjectReference>
   </ItemGroup>
 </Project>

+ 1 - 2
prs.mobile/ConnectionTestApp/ConnectionTest/ConnectionTest/ConnectionTest.csproj

@@ -22,12 +22,11 @@
     <ProjectReference Include="..\..\..\..\..\inabox\InABox.Core\InABox.Core.csproj" />
     <ProjectReference Include="..\..\..\..\..\inabox\inabox.logging.shared\InABox.Logging.Shared.csproj" />
     <ProjectReference Include="..\..\..\..\..\inabox\inabox.websocket.shared\InABox.WebSocket.Shared.csproj" />
+    <ProjectReference Include="..\..\..\..\prs.classes\PRSClasses.csproj" />
   </ItemGroup>
   <ItemGroup>
     <EmbeddedResource Update="ConnectionTestUnit.xaml">
       <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
     </EmbeddedResource>
   </ItemGroup>
-  <Import Project="..\..\..\inabox\InABox.Remote.Shared\InABox.Remote.Shared.projitems" Label="Shared" Condition="Exists('..\..\..\inabox\InABox.Remote.Shared\InABox.Remote.Shared.projitems')" />
-  <Import Project="..\..\..\inabox\InABox.Client.Remote.Shared\InABox.Client.Remote.Shared.projitems" Label="Shared" Condition="Exists('..\..\..\inabox\InABox.Client.Remote.Shared\InABox.Client.Remote.Shared.projitems')" />
 </Project>

+ 9 - 4
prs.mobile/ConnectionTestApp/ConnectionTest/ConnectionTest/ConnectionTestUnit.xaml

@@ -5,7 +5,8 @@
     <ContentView.Content>
         <Frame Padding="2" CornerRadius="5" Margin="2" BorderColor="DarkGray" HasShadow="False" >
             <StackLayout>
-                <Label x:Name="urlLbl" Grid.Column="0" HorizontalOptions="Center" FontAttributes="Bold" FontSize="24" TextColor="DimGray"/>
+                <Label x:Name="urlLbl"  HorizontalOptions="Center" FontAttributes="Bold" FontSize="24" TextColor="DimGray"/>
+                <Label x:Name="intervalLbl" HorizontalOptions="Center"/>
                 <Grid>
                     <Grid.ColumnDefinitions>
                         <ColumnDefinition Width="*"/>
@@ -24,10 +25,14 @@
                 <Grid>
                     <Grid.ColumnDefinitions>
                         <ColumnDefinition Width="*"/>
-                        <ColumnDefinition Width="auto"/>
+                        <ColumnDefinition Width="*"/>
+                        <ColumnDefinition Width="*"/>
+                        <ColumnDefinition Width="*"/>
                     </Grid.ColumnDefinitions>
-                    <Button Grid.Column="0" x:Name="emailBtn" Text="Email logs" Clicked="EmailBtn_Clicked"/>
-                    <Button Grid.Column="1" Text="Close" Clicked="CloseButton_Clicked" HorizontalOptions="End"/>
+                    <Button Grid.Column="0" Text="-" Clicked="MinusBtn_Clicked" BackgroundColor="DarkGray" HorizontalOptions="FillAndExpand" Margin="5"/>
+                    <Button Grid.Column="1" Text="+" Clicked="PlusButton_Clicked" HorizontalOptions="FillAndExpand" BackgroundColor="DarkGray" Margin="5"/>
+                    <Button Grid.Column="2" x:Name="emailBtn" Text="Email logs" Clicked="EmailBtn_Clicked" BackgroundColor="DarkGray" HorizontalOptions="FillAndExpand" Margin="5"/>
+                    <Button Grid.Column="3" Text="Close" Clicked="CloseButton_Clicked" HorizontalOptions="FillAndExpand" BackgroundColor="DarkGray" Margin="5"/>
                 </Grid>
             </StackLayout>
         </Frame>

+ 73 - 7
prs.mobile/ConnectionTestApp/ConnectionTest/ConnectionTest/ConnectionTestUnit.xaml.cs

@@ -10,6 +10,8 @@ using Xamarin.Forms;
 using Xamarin.Forms.Xaml;
 using System.Net;
 using InABox.Core;
+using Comal.Classes;
+using Email = Xamarin.Essentials.Email;
 
 namespace ConnectionTest
 {
@@ -20,6 +22,8 @@ namespace ConnectionTest
         public event RemoveURL OnRemoveURL;
         string URL = "";
         string log = "";
+        double interval = 1000;
+        static JsonClient<User> client;
         public ConnectionTestUnit(string url)
         {
             InitializeComponent();
@@ -32,6 +36,7 @@ namespace ConnectionTest
             });
             Resolve();
             ResolveTimer();
+            UpdateInterval();
         }
 
         private void ResolveTimer()
@@ -97,20 +102,45 @@ namespace ConnectionTest
 
         private void StartTest()
         {
-            int count = 1;
+            int count = 0;
             int crashcount = 0;
             while (true)
             {
                 try
                 {
-                    Thread.Sleep(500);
-                    var client = new JsonClient<User>(URL, false, false, BinarySerializationSettings.Latest);
-                    var result = client.Validate("TAN", "nictan", Guid.Empty);
+                    
+                    Thread.Sleep((int)interval);
+
+                    if(client == null)
+                        client = new JsonClient<User>(URL, false, true, BinarySerializationSettings.Latest);
+
+                    if(ClientFactory.ClientType == null)
+                        ClientFactory.SetClientType(typeof(JsonClient<>), "Test connection App", "1.0", URL, true);
+                    var result = ClientFactory.Validate("TAN", "nictan");
+
+                    //var request = WebRequest.Create("http://" + URL);
+                    //var response = request.GetResponse();
+                    //var cmd = string.Format(
+                    //    "{0}{1}?format={2}&responseFormat={3}&serializationVersion={4}",
+                    //    "validate",
+                    //    "User",
+                    //    "Json",
+                    //    "Json",
+                    //    "1.0"
+                    //    );
 
                     Device.BeginInvokeOnMainThread(() =>
                     {
-                        attemptNoLbl.Text = "Attempt: " + count;
                         count++;
+                        attemptNoLbl.Text = "Attempt: " + count;                       
+                    });
+
+                    CoreTable table = new Client<Product>().Query();
+
+                    Device.BeginInvokeOnMainThread(() =>
+                    {
+                        count++;
+                        attemptNoLbl.Text = "Attempt: " + count;
                     });
                 }
                 catch (Exception ex)
@@ -123,8 +153,11 @@ namespace ConnectionTest
                         + ex.Message + ex.StackTrace;
                     crashcount++;
                     count++;
-                    Device.BeginInvokeOnMainThread(() => { crashNoLbl.Text = "Crash Count: " + crashcount; });
-
+                    Device.BeginInvokeOnMainThread(() =>
+                    {
+                        attemptNoLbl.Text = "Attempt: " + count;
+                        crashNoLbl.Text = "Crash Count: " + crashcount;
+                    });
                 }
             }
         }
@@ -133,5 +166,38 @@ namespace ConnectionTest
         {
             OnRemoveURL?.Invoke(this);
         }
+
+        void MinusBtn_Clicked(System.Object sender, System.EventArgs e)
+        {
+            if (interval > 500)
+            {
+                interval = interval - 500;
+                UpdateInterval();
+            }
+            else if(interval == 500)
+            {
+                interval = 100;
+                UpdateInterval();
+            }
+        }
+
+        void PlusButton_Clicked(System.Object sender, System.EventArgs e)
+        {
+            if (interval >= 500)
+            {
+                interval = interval + 500;
+                UpdateInterval();
+            }
+            else if(interval == 100)
+            {
+                interval = 500;
+                UpdateInterval();
+            }
+        }
+
+        private void UpdateInterval()
+        {
+            intervalLbl.Text = "Interval: " + (interval / 1000) + "s";
+        }
     }
 }

+ 4 - 0
prs.mobile/ConnectionTestApp/ConnectionTest/ConnectionTest/MainPage.xaml.cs

@@ -8,6 +8,8 @@ using Xamarin.Forms;
 using InABox.Clients;
 using System.Threading;
 using Xamarin.Essentials;
+using Comal.Classes;
+using InABox.Core;
 
 namespace ConnectionTest
 {
@@ -24,6 +26,8 @@ namespace ConnectionTest
         public MainPage()
         {
             InitializeComponent();
+            CoreUtils.RegisterClasses();
+            ComalUtils.RegisterClasses();
             foreach (var url in urls) 
             {
                 var test = new ConnectionTestUnit(url);

+ 1 - 1
prs.mobile/comal.timesheets.iOS/Info.plist

@@ -9,7 +9,7 @@
 	<key>CFBundleName</key>
 	<string>TimeBench</string>
 	<key>CFBundleShortVersionString</key>
-	<string>7.14.5</string>
+	<string>7.14.6</string>
 	<key>CFBundleVersion</key>
 	<string>7.14.5</string>
 	<key>NSBluetoothAlwaysUsageDescription</key>

+ 20 - 22
prs.mobile/comal.timesheets/Grids/EquipmentGrid.cs

@@ -27,37 +27,35 @@ namespace comal.timesheets
 
         private void LoadItems(DataGridSaveType savetype)
         {
-            Task.Run(async () =>
+            Task.Run(() =>
             {
-                using (await MaterialDialog.Instance.LoadingDialogAsync(message: "Loading"))
+
+                try
                 {
-                    try
-                    {
-                        var table = DoQuery();
-                        while (table == null)
-                            table = DoQuery();
+                    var table = DoQuery();
+                    while (table == null)
+                        table = DoQuery();
 
-                        List<DataGridViewModelItem> shells = new List<DataGridViewModelItem>();
-                        foreach (CoreRow row in table.Rows)
-                        {
-                            List<Tuple<string, string>> tuples = new List<Tuple<string, string>>
+                    List<DataGridViewModelItem> shells = new List<DataGridViewModelItem>();
+                    foreach (CoreRow row in table.Rows)
+                    {
+                        List<Tuple<string, string>> tuples = new List<Tuple<string, string>>
                         {
                             new Tuple<string, string>("Name", row.Get<Equipment, string>(x => x.Description)),
                             new Tuple<string, string>("Group", row.Get<Equipment, string>(x => x.GroupLink.Description)),
                             new Tuple<string, string>("Battery", row.Get<Equipment, double>(x => x.TrackerLink.BatteryLevel).ToString())
                         };
-                            shells.Add(new DataGridViewModelItem
-                                            (
-                                                id: row.Get<Equipment, Guid>(x => x.ID),
-                                                data: tuples
-                                            ));
-                        }
-                        Setup(shells, typeof(Equipment), savetype);
-                    }
-                    catch (Exception ex)
-                    {
-                        var log = new MobileLogging(LogType.Query, "Equipment", ex.Message + ex.StackTrace, this.GetType().Name);
+                        shells.Add(new DataGridViewModelItem
+                                        (
+                                            id: row.Get<Equipment, Guid>(x => x.ID),
+                                            data: tuples
+                                        ));
                     }
+                    Setup(shells, typeof(Equipment), savetype);
+                }
+                catch (Exception ex)
+                {
+                    var log = new MobileLogging(LogType.Query, "Equipment", ex.Message + ex.StackTrace, this.GetType().Name);
                 }
             });
         }

+ 30 - 14
prs.mobile/comal.timesheets/Warehousing/Receivals/PurchaseOrderPage.xaml.cs

@@ -44,20 +44,10 @@ namespace comal.timesheets
                 filterOptions.Clear();
                 filterOptions.Add("All");
 
-                CoreTable table = new Client<PurchaseOrder>().Query
-                    (
-                    new Filter<PurchaseOrder>(x => x.ClosedDate).IsEqualTo(DateTime.MinValue),
-                    new Columns<PurchaseOrder>(
-                        x => x.ID, //0
-                        x => x.PONumber, //1
-                        x => x.DueDate, //2
-                        x => x.Status, //3
-                        x => x.SupplierLink.ID, //4
-                        x => x.SupplierName, //5
-                        x => x.Notes //6
-                        ),
-                    new SortOrder<PurchaseOrder>(x => x.DueDate, SortDirection.Descending)
-                    );
+                CoreTable table = QueryTable();
+                while (table == null)
+                    table = QueryTable();
+
                 if (table.Rows.Any())
                 {
                     foreach (CoreRow row in table.Rows)
@@ -105,6 +95,32 @@ namespace comal.timesheets
             });
         }
 
+        private CoreTable QueryTable()
+        {
+            try
+            {
+                return new Client<PurchaseOrder>().Query
+                        (
+                        new Filter<PurchaseOrder>(x => x.ClosedDate).IsEqualTo(DateTime.MinValue),
+                        new Columns<PurchaseOrder>(
+                            x => x.ID, //0
+                            x => x.PONumber, //1
+                            x => x.DueDate, //2
+                            x => x.Status, //3
+                            x => x.SupplierLink.ID, //4
+                            x => x.SupplierName, //5
+                            x => x.Notes //6
+                            ),
+                        new SortOrder<PurchaseOrder>(x => x.DueDate, SortDirection.Descending)
+                        );
+            }
+            catch (Exception ex)
+            {
+                var log = new MobileLogging(LogType.Query, "QueryTable()", ex.Message + ex.StackTrace, this.GetType().Name);
+                return null;
+            }
+        }
+
         private void UpdateListWithNumberOfItems()
         {
             Task.Run(() =>