From 126f59cbba2e1505c191b22c9794d810cdedb4c3 Mon Sep 17 00:00:00 2001
From: JLChen <551775569@qq.com>
Date: 星期五, 24 四月 2020 15:39:05 +0800
Subject: [PATCH] 2020-04-24 1.优化远程连接和控制,增加远程连接让用户等待的Loading提示。

---
 Crabtree/SmartHome/UI/SimpleControl/EquipmentPublicClass.cs |   23 +++++++----
 Crabtree/ON.Ios/AppDelegate.cs                              |    8 ++--
 Crabtree/ON.Ios/ViewController.cs                           |    2 +
 Crabtree/ON/Properties/AndroidManifest.xml                  |    2 
 Crabtree/.vs/SmartHome/xs/UserPrefs.xml                     |   23 ++++++++---
 Crabtree/.vs/SmartHome/xs/sqlite3/storage.ide               |    0 
 Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs           |    2 
 Crabtree/SmartHome/UI/SimpleControl/MainPage.cs             |    2 
 8 files changed, 40 insertions(+), 22 deletions(-)

diff --git a/Crabtree/.vs/SmartHome/xs/UserPrefs.xml b/Crabtree/.vs/SmartHome/xs/UserPrefs.xml
index 7a5ad9e..a3070ea 100644
--- a/Crabtree/.vs/SmartHome/xs/UserPrefs.xml
+++ b/Crabtree/.vs/SmartHome/xs/UserPrefs.xml
@@ -1,26 +1,35 @@
 锘�<Properties StartupConfiguration="{1D83BF28-BA88-4152-BA41-D7EFE90A5437}|Default">
   <MonoDevelop.Ide.ItemProperties.ON.Droid PreferredExecutionTarget="Android.364c4b3158493098" />
-  <MonoDevelop.Ide.Workbench ActiveDocument="SmartHome/UI/SimpleControl/MqttCommon.cs">
+  <MonoDevelop.Ide.Workbench>
     <Files>
       <File FileName="SmartHome/UI/SimpleControl/Phone/Register/AccountLogin.cs" Line="84" Column="50" IsPinned="True" />
       <File FileName="../../../2020/娴嬭瘯/SmartHome/SmartHome/UI/SimpleControl/Phone/Room/UserRoom.cs" />
-      <File FileName="SmartHome/UI/SimpleControl/EquipmentPublicClass.cs" Line="35" Column="33" />
-      <File FileName="SmartHome/UI/SimpleControl/MainPage.cs" />
+      <File FileName="SmartHome/UI/SimpleControl/EquipmentPublicClass.cs" Line="51" Column="1" />
+      <File FileName="SmartHome/UI/SimpleControl/MainPage.cs" Line="41" Column="56" />
       <File FileName="SmartHome/UI/SimpleControl/Phone/User/UserMiddle.cs" />
-      <File FileName="SmartHome/UI/SimpleControl/MqttCommon.cs" Line="1" Column="1" />
+      <File FileName="SmartHome/UI/SimpleControl/MqttCommon.cs" Line="241" Column="64" />
+      <File FileName="SmartHome/HDL/Operation/Utlis.cs" />
+      <File FileName="ON/Properties/AndroidManifest.xml" />
+      <File FileName="ON.Ios/AppDelegate.cs" Line="294" Column="22" />
+      <File FileName="ON.Ios/ViewController.cs" Line="39" Column="77" />
     </Files>
     <Pads>
       <Pad Id="ProjectPad">
         <State name="__root__">
           <Node name="SmartHome" expanded="True">
-            <Node name="ON.Droid" expanded="True" />
+            <Node name="ON.Droid" expanded="True" selected="True">
+              <Node name="Properties" expanded="True" />
+            </Node>
+            <Node name="ON.Ios" expanded="True" />
             <Node name="Shared" expanded="True">
+              <Node name="HDL" expanded="True">
+                <Node name="Operation" expanded="True" />
+              </Node>
               <Node name="UI" expanded="True">
                 <Node name="SimpleControl" expanded="True">
                   <Node name="Phone" expanded="True">
                     <Node name="Register" expanded="True" />
                   </Node>
-                  <Node name="MqttCommon.cs" selected="True" />
                 </Node>
               </Node>
             </Node>
@@ -36,7 +45,7 @@
     <String>Shared.IOS/Shared.IOS.csproj</String>
     <String>DroidLib/DroidLib.csproj</String>
   </DisabledProjects>
-  <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug|iPhone" />
+  <MonoDevelop.Ide.Workspace ActiveConfiguration="Release|iPhone" />
   <MonoDevelop.Ide.ItemProperties.ON.Ios automaticSigning="False" PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneDeviceTarget.254b82433419c7ca1850b1dfb524c79b7aeb0640" />
   <MonoDevelop.Ide.DebuggingService.Breakpoints>
     <BreakpointStore />
diff --git a/Crabtree/.vs/SmartHome/xs/sqlite3/storage.ide b/Crabtree/.vs/SmartHome/xs/sqlite3/storage.ide
index 891009e..b8d8f20 100644
--- a/Crabtree/.vs/SmartHome/xs/sqlite3/storage.ide
+++ b/Crabtree/.vs/SmartHome/xs/sqlite3/storage.ide
Binary files differ
diff --git a/Crabtree/ON.Ios/AppDelegate.cs b/Crabtree/ON.Ios/AppDelegate.cs
index 6942a4c..813897b 100644
--- a/Crabtree/ON.Ios/AppDelegate.cs
+++ b/Crabtree/ON.Ios/AppDelegate.cs
@@ -192,14 +192,14 @@
         {
             Utlis.WriteLine ("OnResignActivation");
             //Shared.BusSocket.Stop ();
-            BusSocketStop ();
+            //BusSocketStop ();
         }
 
         public override void DidEnterBackground (UIApplication application)
         {
             SharedMethod.SharedMethod.IsBackground = true;
             Utlis.WriteLine ("DidEnterBackground");
-            //BusSocketStop ();
+            BusSocketStop ();
         }
 
         public override void WillEnterForeground (UIApplication application)
@@ -211,7 +211,7 @@
             UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
             // Called as part of the transiton from background to active state.
             // Here you can undo many of the changes made on entering the background.
-            //BusSocketStart ();
+            BusSocketStart ();
         }
 
         public override void WillTerminate (UIApplication application)
@@ -225,7 +225,7 @@
             Utlis.WriteLine ("OnActivated");
             base.OnActivated (application);
 
-            BusSocketStart ();
+            //BusSocketStart ();
             ////鏈変簺绯荤粺鐗堟湰杩欓噷鍚姩姣旇鍥炬帶鍒跺櫒蹇�
             //if (!Shared.SimpleControl.MainPage.Showed) {
             //    System.Threading.Tasks.Task.Run (() => {
diff --git a/Crabtree/ON.Ios/ViewController.cs b/Crabtree/ON.Ios/ViewController.cs
index f5f5f26..1edd592 100644
--- a/Crabtree/ON.Ios/ViewController.cs
+++ b/Crabtree/ON.Ios/ViewController.cs
@@ -36,6 +36,8 @@
             //渚︽祴缃戠粶鍙樺寲
             Reachability.ReachabilityChanged += UpdateStatus;
 
+            Shared.SimpleControl.EquipmentPublicClass.CheckLinkRemote ((int)internetStatus, false);
+
             UITapGestureRecognizer oTapRecognizer = new UITapGestureRecognizer ();
             oTapRecognizer.CancelsTouchesInView = false;
             oTapRecognizer.AddTarget (
diff --git a/Crabtree/ON/Properties/AndroidManifest.xml b/Crabtree/ON/Properties/AndroidManifest.xml
index e0bd6ab..a02a790 100644
--- a/Crabtree/ON/Properties/AndroidManifest.xml
+++ b/Crabtree/ON/Properties/AndroidManifest.xml
@@ -1,5 +1,5 @@
 锘�<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hdl.crabtreenew" android:versionName="2.504232" android:versionCode="202004232">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.hdl.crabtreenew" android:versionName="2.504241" android:versionCode="202004241">
 	<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="28" />
 	<!-- 鍦ㄥ畨鍗揚鐗堟湰涔嬪悗锛屽繀椤昏鎺堜簣FOREGROUND_SERVICE鏉冮檺锛屾墠鑳藉浣跨敤鍓嶅彴鏈嶅姟 -->
 	<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
diff --git a/Crabtree/SmartHome/UI/SimpleControl/EquipmentPublicClass.cs b/Crabtree/SmartHome/UI/SimpleControl/EquipmentPublicClass.cs
index 0d8deb3..6fa3122 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/EquipmentPublicClass.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/EquipmentPublicClass.cs
@@ -46,6 +46,9 @@
             }
 
             new System.Threading.Thread (async () => {
+
+                bool IsRemoteLoadingShow = false;
+
                 try {
                     if (status == 0) {
                         Application.RunOnMainThread (() => {
@@ -75,6 +78,7 @@
                         });
                         bool canRemote = false;
                       
+
 
                         //1.濡傛灉鏈湴娌$綉鍏虫暟鎹紝鎻愮ずWiFiOffline锛屽苟涓斿垽鏂槸鍚﹂渶瑕佹柇寮�杩滅▼
                         if (gateWayList == null || gateWayList.Count == 0) {
@@ -112,7 +116,7 @@
                                         //var result = Control.ControlBytesSendHasReturn (Command.ReadGateway, common.SubnetID, common.DeviceID, new byte [] { (byte)new Random ().Next (255), (byte)new Random ().Next (255) });
                                         #region
                                         //寮�濮嬫湰鍦版悳绱㈢綉鍏�...
-                                        MainPage.AddTip ("Searching local gateway...");
+                                        MainPage.LoadingStart ("Searching local gateway...");
 
                                         var control = new Control ();
                                         control.Send (new Target () {
@@ -165,12 +169,13 @@
                                 if (UserConfig.Instance.CheckHomeGateways ()) {
                                     if (!string.IsNullOrEmpty (UserConfig.Instance.CurrentRegion.HomeGateways [0].GatewayUniqueId)) {
                                         // 5.1鑳借繙绋�,鏄剧ずCloudUnlink鐘舵�侊紝IsRemote璁句负true寮�濮嬭繙绋�
-                                        MainPage.AddTip ("Please wait, starting remote connection...");
-
-                                        Utlis.ShowAppLinkStatus (AppLinkStatus.CloudUnlink);
+                                        //MainPage.AddTip ("Please wait, starting remote connection...");
+                                        MainPage.LoadingStart ("Please wait, starting remote connection...");
                                         CommonPage.IsRemote = true;
+                                        IsRemoteLoadingShow = true;
                                         //閲嶇疆鍙傛暟鐘舵��
                                         SmartHome.MqttCommon.InitState ();
+                                        Utlis.ShowAppLinkStatus (AppLinkStatus.CloudUnlink);
 
                                     }
                                 }
@@ -196,14 +201,16 @@
                     Utlis.WriteLine ("CheckLinkRemote : " + ex.ToString ());
                 } finally {
                     isConnectiong = false;
-                    Application.RunOnMainThread (() => {
-                        MainPage.Loading.Hide ();
-                    });
+                    if (!IsRemoteLoadingShow) {
+                        Application.RunOnMainThread (() => {
+                            MainPage.Loading.Hide ();
+                        });
+                    }
                 }
             }) { IsBackground = true }.Start ();
         }
 
-
+        //static bool IsRemoteLoadingShow = false;
 
         /// <summary>
         /// 鍏抽棴杩滅▼杩炴帴妯″紡锛屽苟鏂紑MQTT
diff --git a/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs b/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs
index fbed817..08b2494 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/MainPage.cs
@@ -38,7 +38,7 @@
         //public static Button LogoButton = new Button ();
   
 
-        public static string RequestVersion = "20200423";
+        public static string RequestVersion = "20200424";
         public static UserInfo LoginUser;
         /// <summary>
         /// 鏄惁鏄鐞嗗憳鏉冮檺(鍙樻洿浜�,鎴愬憳鐨勬椂鍊�,杩欎釜涔熶负ture銆備负浠�涔堜細澹版槑杩欐牱鍙橀噺,鍥犱负鏈変簺鎺ュ彛蹇呴』浣跨敤鍘熸潵鐨凾oken)
diff --git a/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs b/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs
index a2f8a98..8b013e7 100644
--- a/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs
+++ b/Crabtree/SmartHome/UI/SimpleControl/MqttCommon.cs
@@ -78,7 +78,7 @@
             IfNeedReadAllDeviceStatus = true;
             bNeedStartTip = true;
             IsGatewayOnline = false;
-
+            StartCloudMqtt ();
         }
 
 

--
Gitblit v1.8.0