From 7e863a33397f317ffc3ffd9288496d0e4f16aa66 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 12 十二月 2019 14:58:20 +0800
Subject: [PATCH] 合并了新代码

---
 ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs |   35 ++++++++++++++++++++++++++++-------
 1 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs b/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs
index dffdf80..6c9d52c 100755
--- a/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs
+++ b/ZigbeeApp/Shared/Phone/ZigBee/Device/ZbGateway.cs
@@ -60,6 +60,12 @@
         /// <value><c>true</c> if is remote; otherwise, <c>false</c>.</value>
         public static bool IsRemote;
 
+        /// <summary>
+        /// 鏄惁鎷ユ湁杩滅▼杩炴帴鐨勬潈闄�
+        /// </summary>
+        [Newtonsoft.Json.JsonIgnore]
+        public static bool AllowRemoteCtrl = true;
+
         /// <summary>
         /// 缃戝叧淇濆瓨璺緞
         /// </summary>
@@ -3229,6 +3235,11 @@
         /// <returns></returns>
         static async System.Threading.Tasks.Task initGateWayBaseInfomation()
         {
+            if (AllowRemoteCtrl == false)
+            {
+                //娌℃湁杩滅▼杩炴帴鐨勬潈闄�
+                return;
+            }
             string loginToken = Config.Instance.Token;
             if (Config.Instance.Home.IsOthreShare == true)
             {
@@ -3271,11 +3282,13 @@
                     var statuCode = jobject["StateCode"].ToString();
                     if (statuCode != "Success")
                     {
-                        //Log鍑哄姏
-                        Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(-1, "鎺ュ彛璁块棶澶辫触鈽咃細App/GetSingleHomeGatewayPagger " + statuCode);
                         //搴忓垪鍖栧璞�
                         var requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(pra2);
-                        Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(-1, "鍙傛暟锛歕r\n" + requestJson);
+                        //Log鍑哄姏
+                        string errorMsg = "鎺ュ彛璁块棶澶辫触鈽咃細App/GetSingleHomeGatewayPagger " + statuCode + "\r\n";
+                        errorMsg += "鍙傛暟锛歕r\n" + requestJson;
+                        Shared.Phone.UserCenter.HdlLogLogic.Current.WriteLog(-1, errorMsg);
+                        return;
                     }
 
                     var responseData = jobject["ResponseData"];
@@ -3323,10 +3336,12 @@
         /// <param name="brokerName">Broker name.</param>
         public static async System.Threading.Tasks.Task StartRemoteMqtt()
         {
-            if (remoteMqttIsConnecting
-                       || !Shared.Common.Config.Instance.IsLogin
-                       || Shared.Common.Config.Instance.HomeId == ""
-                       || remoteIsConnected)
+            //杩藉姞锛氭病鏈夎繙绋嬭繛鎺ョ殑鏉冮檺
+            if (AllowRemoteCtrl == false
+               || remoteMqttIsConnecting
+               || !Shared.Common.Config.Instance.IsLogin
+               || Shared.Common.Config.Instance.HomeId == ""
+               || remoteIsConnected)
             {
                 return;
             }
@@ -3444,6 +3459,12 @@
                         if (result != null)
                         {
                             var jobject = Newtonsoft.Json.Linq.JObject.Parse(Encoding.UTF8.GetString(result));
+                            if (jobject["StateCode"].ToString() == "NotAllowRemoteCtrl")
+                            {
+                                //娌℃湁杩滅▼杩炴帴鐨勬潈闄�
+                                AllowRemoteCtrl = false;
+                                return;
+                            }
                             var responseData = jobject["ResponseData"];
                             if (responseData != null)
                             {

--
Gitblit v1.8.0