From ecba45c93391066bc30c7bd602c3a7683fbb99a7 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期五, 31 七月 2020 10:56:12 +0800
Subject: [PATCH] 临时备份

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs |  273 +++++++++++++++++++++---------------------------------
 1 files changed, 105 insertions(+), 168 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs
index e9a6550..fc831b0 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs
@@ -82,7 +82,7 @@
             GatewayResourse.AppOldSelectGatewayId = string.Empty;
 
             //浠庢枃浠朵腑鑾峰彇涓婁竴娆¢�夋嫨鐨勭綉鍏砳d
-            byte[] data = Global.ReadFileByDirectory(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AppOldSelectGatewayFile);
+            byte[] data = HdlFileLogic.Current.ReadFileByteContent(DirNameResourse.AppOldSelectGatewayFile);
             if (data != null)
             {
                 string strvalue = System.Text.Encoding.UTF8.GetString(data);
@@ -118,7 +118,7 @@
             }
 
             List<string> listBackupGwId = new List<string>();
-            var fileData = Global.ReadFileByDirectory(DirNameResourse.LocalMemoryDirectory, DirNameResourse.BackupGatewayIdFile);
+            var fileData = HdlFileLogic.Current.ReadFileByteContent(DirNameResourse.BackupGatewayIdFile);
             if (fileData != null)
             {
                 //鏂板锛氳櫧鐒舵鐜囦綆锛屼絾鏄‘瀹炲彂鐢熶簡銆傚鏋滄湁缃戠粶鏃讹紝App閲嶆柊缁戝畾璁板綍鐨勭綉鍏冲け璐ョ殑璇�
@@ -149,26 +149,10 @@
                 //鍒犻櫎缃戝叧鏂囦欢
                 this.DeleteGatewayFile(gatewayId);
             }
-            //LOG杈撳嚭
-            if (listDelete.Count > 0)
+            //濡傛灉缃戝叧閮芥病浜嗙殑璇�,鎶婂満鏅叏閮ㄥ垹浜�
+            if (listDelete.Count > 0 && this.GetAllLocalGateway().Count == 0)
             {
-                string msg = "鏈湴鎷ユ湁鐨勭綉鍏筹細";
-                foreach (var gatewayId in this.dicGateway.Keys)
-                {
-                    msg += gatewayId + ",";
-                }
-                msg += "\r\n琚垹闄ょ殑缃戝叧锛�";
-                foreach (var gatewayId in listDelete)
-                {
-                    msg += gatewayId + ",";
-                }
-                msg += "\r\n姝ゆ椂浜戠杩斿洖褰撳墠璐﹀彿鎵�缁戝畾鏈夌殑缃戝叧锛�";
-                foreach (var gatewayId in result.Keys)
-                {
-                    msg += gatewayId + ",";
-                }
-                var bytes = System.Text.Encoding.UTF8.GetBytes(msg);
-                Common.Global.WriteFileByBytesByHomeId("GatewayDeleteLog.txt", bytes);
+                HdlSceneLogic.Current.DeleteAllLocalScene();
             }
         }
 
@@ -242,7 +226,7 @@
                 return false;
             }
             //娣诲姞缃戝叧鐨勮瘽,寮哄埗涓婚〉鍒锋柊
-            UserView.UserPage.Instance.RefreshForm = true;
+            UserView.UserPage.Instance.RefreshAllForm = true;
 
             return true;
         }
@@ -279,18 +263,7 @@
                 return -1;
             }
             //鑾峰彇缃戝叧鐨勪俊鎭�
-            var result = await zbGateway.GetZbGwInfoAsync();
-            //妫�娴嬬綉鍏宠繑鍥炵殑鍏遍�氶敊璇姸鎬佺爜
-            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
-            if (error != null)
-            {
-                if (mode == ShowErrorMode.YES)
-                {
-                    this.ShowTipMsg(error);
-                }
-                return -1;
-            }
-
+            var result = this.GetGatewayInfo(zbGateway, true, mode);
             if (result == null)
             {
                 if (mode == ShowErrorMode.YES)
@@ -302,28 +275,20 @@
                 return -1;
             }
 
-            if (result.getGwData == null)
-            {
-                if (mode == ShowErrorMode.YES)
-                {
-                    //鑾峰彇缃戝叧淇℃伅澶辫触
-                    string msg = Language.StringByID(R.MyInternationalizationString.uGetGatewayInfoFail);
-                    this.ShowTipMsg(msg);
-                }
-                return -1;
-            }
-
             //璁剧疆浣忓畢ID鍒扮綉鍏�
-            bool flage2 = await this.SetHomeIdToGateway(zbGateway, Common.Config.Instance.HomeId, mode);
-            if (flage2 == false)
+            if (result.HomeId != Common.Config.Instance.HomeId)
             {
-                if (mode == ShowErrorMode.YES)
+                bool flage2 = await this.SetHomeIdToGateway(zbGateway, Common.Config.Instance.HomeId, mode);
+                if (flage2 == false)
                 {
-                    //鍚戠綉鍏宠缃綇瀹匢D澶辫触
-                    string msg = Language.StringByID(R.MyInternationalizationString.uSetHomeIdToGatewayFail);
-                    this.ShowTipMsg(msg);
+                    if (mode == ShowErrorMode.YES)
+                    {
+                        //鍚戠綉鍏宠缃綇瀹匢D澶辫触
+                        string msg = Language.StringByID(R.MyInternationalizationString.uSetHomeIdToGatewayFail);
+                        this.ShowTipMsg(msg);
+                    }
+                    return -1;
                 }
-                return -1;
             }
 
             //鏇存柊浜戠鏁版嵁搴�
@@ -353,9 +318,9 @@
             //鍒锋柊鐨勬槸缂撳瓨,涓嶅埛鏂扮湡瀹炵墿鐞嗙綉鍏�
             this.dicGateway[gwID].GatewayOnlineFlage = zbGateway.GatewayOnlineFlage;
             //灏嗙綉鍏崇殑鏁版嵁璁剧疆鍒版湰鍦扮紦瀛樹腑
-            this.SetGatewayDataToLocalMemmory(this.dicGateway[gwID], result.getGwData);
+            this.SetGatewayDataToLocalMemmory(this.dicGateway[gwID], result);
             //椤轰究杩欎釜鍙橀噺涔熻缃竴涓�
-            this.SetGatewayDataToLocalMemmory(zbGateway, result.getGwData, false);
+            this.SetGatewayDataToLocalMemmory(zbGateway, result, false);
 
             if (isEsist == false)
             {
@@ -407,7 +372,7 @@
             //鑾峰彇鎺у埗涓讳汉璐﹀彿鐨凾oken
             bindGateway.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
 
-            var result = UserCenterLogic.GetResultCodeByRequestHttps("App/BindGatewayToHome", true, bindGateway);
+            var result = UserCenterLogic.GetResultCodeByRequestHttps("App/BindGatewayToHome", true, bindGateway, new List<string> { "NotCheck" });
             if (result == "Error")
             {
                 return -1;
@@ -508,12 +473,12 @@
             await Task.Delay(8000);
 
             //鑾峰彇缃戝叧鐨勪俊鎭�
-            ZbGatewayData.GetGwAllData result = null;
+            ZbGatewayData.GetGwData result = null;
             int count = 5;
             while (count >= 0)
             {
-                result = await zbGateway.GetZbGwInfoAsync();
-                if (result != null && result.getGwData != null)
+                result = this.GetGatewayInfo(zbGateway, true, ShowErrorMode.NO);
+                if (result != null)
                 {
                     break;
                 }
@@ -521,15 +486,7 @@
                 //鏈�澶氬啀绛�20绉�
                 await Task.Delay(4000);
             }
-            //妫�娴嬬綉鍏宠繑鍥炵殑鍏遍�氶敊璇姸鎬佺爜
-            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
-            if (error != null)
-            {
-                this.ShowTipMsg(error);
-                return -1;
-            }
-
-            if (result == null || result.getGwData == null)
+            if (result == null)
             {
                 //鑾峰彇缃戝叧淇℃伅澶辫触
                 string msg = Language.StringByID(R.MyInternationalizationString.uGetGatewayInfoFail);
@@ -551,9 +508,9 @@
             //鍒锋柊鐨勬槸缂撳瓨,涓嶅埛鏂扮湡瀹炵墿鐞嗙綉鍏�
             this.dicGateway[gwID].GatewayOnlineFlage = zbGateway.GatewayOnlineFlage;
             //灏嗙綉鍏崇殑鏁版嵁璁剧疆鍒版湰鍦扮紦瀛樹腑
-            this.SetGatewayDataToLocalMemmory(this.dicGateway[gwID], result.getGwData);
+            this.SetGatewayDataToLocalMemmory(this.dicGateway[gwID], result);
             //椤轰究杩欎釜鍙橀噺涔熻缃竴涓�
-            this.SetGatewayDataToLocalMemmory(zbGateway, result.getGwData, false);
+            this.SetGatewayDataToLocalMemmory(zbGateway, result, false);
 
             if (isEsist == false)
             {
@@ -562,7 +519,7 @@
             }
 
             //娣诲姞缃戝叧鐨勮瘽,寮哄埗涓婚〉鍒锋柊
-            UserView.UserPage.Instance.RefreshForm = true;
+            UserView.UserPage.Instance.RefreshAllForm = true;
 
             return 1;
         }
@@ -576,42 +533,30 @@
         /// </summary>
         /// <param name="zbGateway">缃戝叧瀵硅薄</param>
         /// <param name="gatewayName">缃戝叧鍚�</param>
-        public async Task<bool> ReName(ZbGateway zbGateway, string gatewayName)
+        public bool ReName(ZbGateway zbGateway, string gatewayName)
         {
-            ZbGateway realWay = null;
-            if (this.GetRealGateway(ref realWay, zbGateway) == false)
+            //鍙彇32涓猙yte
+            var bytes = new byte[32];
+            var reamarkGwBytes = System.Text.Encoding.UTF8.GetBytes(gatewayName);
+            System.Array.Copy(reamarkGwBytes, 0, bytes, 0, 32 < reamarkGwBytes.Length ? 32 : reamarkGwBytes.Length);
+            gatewayName = System.Text.Encoding.UTF8.GetString(bytes);
+
+            var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 91 } };
+            var data = new Newtonsoft.Json.Linq.JObject { { "GwName", gatewayName } };
+            jObject.Add("Data", data);
+            var result = this.SendJobjectDataToGateway(zbGateway, "GwReName", jObject.ToString(), "GwReName_Respon");
+            if (result.ErrorMsg != null)
             {
-                //鑾峰彇缃戝叧瀵硅薄澶辫触
-                string msg = Language.StringByID(R.MyInternationalizationString.uGetGatewayTagartFail);
-                this.ShowErrorMsg(msg);
+                this.ShowTipMsg(result.ErrorMsg);
                 return false;
             }
-
-            var result = await realWay.GwReNameAsync(gatewayName);
-            //妫�娴嬬綉鍏宠繑鍥炵殑鍏遍�氶敊璇姸鎬佺爜
-            string error = HdlCheckLogic.Current.CheckCommonErrorCode(result);
-            if (error != null)
-            {
-                this.ShowErrorMsg(error);
-                return false;
-            }
-
-            if (result == null)
+            if (result.ErrorMsgDiv == 0)
             {
                 //缃戝叧鍚嶇О淇敼澶辫触
                 string msg = Language.StringByID(R.MyInternationalizationString.uGatewayReNameFail);
-
-                this.ShowErrorMsg(msg);
-                return false;
-            }
-
-            //缃戝叧淇敼澶辫触
-            if (result.gwReNameData == null)
-            {
-                //缃戝叧鍚嶇О淇敼澶辫触
-                string msg = Language.StringByID(R.MyInternationalizationString.uGatewayReNameFail);
-
-                this.ShowErrorMsg(msg);
+                //缃戝叧鍥炲瓒呮椂
+                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂");
+                this.ShowTipMsg(msg);
                 return false;
             }
 
@@ -637,19 +582,18 @@
         public async Task<bool> DoSwitchGateway(string gatewayId)
         {
             var zbGateway = this.GetLocalGateway(gatewayId);
-            if (this.CheckGatewayOnlineByFlag(zbGateway) == true)
+
+            //閲嶆柊鑾峰彇鍦ㄧ嚎缃戝叧鐨勪俊鎭�
+            var result = await this.GetOnlineGatewayInfo(gatewayId);
+            if (result == false)
             {
-                //閲嶆柊鑾峰彇鍦ㄧ嚎缃戝叧鐨勪俊鎭�
-                var result = await this.GetOnlineGatewayInfo(gatewayId);
-                if (result == false)
-                {
-                    return false;
-                }
+                return false;
             }
+
             //鍒囨崲缃戝叧,淇濆瓨缂撳瓨
             this.SaveGatewayIdToLocation(gatewayId);
             //鍒囨崲缃戝叧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
-            UserView.UserPage.Instance.RefreshForm = true;
+            UserView.UserPage.Instance.RefreshAllForm = true;
 
             return true;
         }
@@ -694,7 +638,7 @@
             if (getGatewayInfo == true)
             {
                 //鑾峰彇缃戝叧淇℃伅
-                var info = this.GetGatewayInfo(realWay);
+                var info = this.GetGatewayInfo(realWay, false);
                 if (info == null)
                 {
                     //鍏抽棴杩涘害鏉�
@@ -704,7 +648,7 @@
             }
 
             //鑾峰彇鍏ㄩ儴璁惧
-            int result = LocalDevice.Current.SetDeviceToMemmoryByGateway(realWay);
+            int result = LocalDevice.Current.SetDeviceToMemmoryByGateway(realWay, false);
             //鍏抽棴杩涘害鏉�
             ProgressBar.Close();
             if (result == -1)
@@ -721,8 +665,7 @@
         public void SaveGatewayIdToLocation(string gatewayId)
         {
             GatewayResourse.AppOldSelectGatewayId = gatewayId;
-            byte[] data = System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(GatewayResourse.AppOldSelectGatewayId));
-            Global.WriteFileToDirectoryByBytes(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AppOldSelectGatewayFile, data);
+            HdlFileLogic.Current.SaveFileContent(DirNameResourse.AppOldSelectGatewayFile, GatewayResourse.AppOldSelectGatewayId);
         }
 
         #endregion
@@ -746,20 +689,11 @@
         public async Task<bool> DeleteGateway(string zbGatewayID)
         {
             ZbGateway realWay = null;
-            bool hadReal = this.GetRealGateway(ref realWay, zbGatewayID);
-
-            //鏆備笉鏀寔鍒嗕韩
-            if (hadReal == true && realWay.GatewayOnlineFlage == true)
+            this.GetRealGateway(ref realWay, zbGatewayID);
+            //娓呯┖缃戝叧鐨勪綇瀹匢D 缃戝叧瑙g粦澶辫触  涓嶇悊瀹�,鍥犱负缃戝叧鍙互鎸夋寜閿己鍒舵悳绱㈠緱鍒�
+            if (realWay != null)
             {
-                //娓呯┖缃戝叧鐨勪綇瀹匢D
-                bool result = await this.SetHomeIdToGateway(realWay, string.Empty, ShowErrorMode.YES);
-                if (result == false)
-                {
-                    //缃戝叧瑙g粦澶辫触  涓嶇悊瀹�,鍥犱负缃戝叧鍙互鎸夋寜閿己鍒舵悳绱㈠緱鍒�
-                    string msg = Language.StringByID(R.MyInternationalizationString.uGatewayUnBindFail);
-                    //this.ShowErrorMsg(msg);
-                    //return false;
-                }
+                await this.SetHomeIdToGateway(realWay, string.Empty, ShowErrorMode.NO);
             }
 
             //鍒犻櫎浜戠鐨勭綉鍏�
@@ -771,7 +705,10 @@
             //绉婚櫎
             ZbGateway.GateWayList.RemoveAll((obj) => obj.GwId == zbGatewayID);
             //鏂紑mqtt杩炴帴
-            realWay.DisConnectLocalMqttClient("GD");
+            if (realWay != null)
+            {
+                realWay.DisConnectLocalMqttClient("GD");
+            }
 
             return true;
         }
@@ -1012,7 +949,7 @@
         public List<string> GetAllGatewayFile()
         {
             List<string> list = new List<string>();
-            List<string> listFile = Global.FileListByHomeId();
+            List<string> listFile = HdlFileLogic.Current.GetRootPathListFile();
             foreach (string file in listFile)
             {
                 //鍙幏鍙栫綉鍏宠澶�
@@ -1334,10 +1271,11 @@
         /// 鑾峰彇缃戝叧鍔犵壒鏁堢殑鍚嶇О
         /// </summary>
         /// <param name="zbGateway"></param>
-        /// <param name="mode"></param>
         /// <returns></returns>
-        public string GetGatewayName(ZbGateway zbGateway, GetNameMode mode = GetNameMode.SpecialGateway)
+        public string GetGatewayName(ZbGateway zbGateway)
         {
+            if (zbGateway == null) { return string.Empty; }
+
             string gwId = zbGateway.GwId;
             if (this.dicGateway.ContainsKey(gwId) == false)
             {
@@ -1351,14 +1289,10 @@
                 return name;
             }
 
-            if (mode == GetNameMode.SpecialGateway)
+            var nameContent = LocalDevice.Current.GetDeviceModelIdNameInfo(localWay.LinuxImageType.ToString());
+            if (nameContent != null)
             {
-                string keyName = Common.LocalDevice.deviceModelIdName + localWay.LinuxImageType;
-                if (LocalDevice.Current.dicDeviceAllNameID.ContainsKey(keyName) == true)
-                {
-                    //娌℃湁鍚嶇О鏃讹紝鍒欎娇鐢≧鏂囦欢閲岄潰璁剧疆鐨勯粯璁よ澶囧悕绉�
-                    return Language.StringByID(LocalDevice.Current.dicDeviceAllNameID[keyName] + 20000);
-                }
+                return nameContent.A澶囨敞鍚嶅瓧;
             }
 
             return string.Empty;
@@ -1395,11 +1329,10 @@
                 //濡傛灉杩欎釜缃戝叧娌℃湁淇℃伅锛屽垯浠庢柊鑾峰彇
                 if (zbGateway.LinuxImageType != -1)
                 {
-                    string keyName = Common.LocalDevice.deviceModelIdName + zbGateway.LinuxImageType;
-                    if (Common.LocalDevice.Current.dicDeviceAllNameID.ContainsKey(keyName) == true)
+                    var nameContent = LocalDevice.Current.GetDeviceModelIdNameInfo(zbGateway.LinuxImageType.ToString());
+                    if (nameContent != null)
                     {
-                        //浣跨敤R鏂囦欢閲岄潰璁剧疆鐨勪笢瑗�
-                        button.TextID = LocalDevice.Current.dicDeviceAllNameID[keyName];
+                        button.Text = nameContent.A瀹樻柟鍚嶅瓧;
                     }
                 }
                 else
@@ -1407,7 +1340,7 @@
                     //缁欎竴涓嚎绋嬪幓鑾峰彇瀹冪殑闀滃儚绫诲瀷
                     HdlThreadLogic.Current.RunThread(() =>
                     {
-                        var result = this.GetGatewayInfo(zbGateway, ShowErrorMode.NO);
+                        var result = this.GetGatewayInfo(zbGateway, false, ShowErrorMode.NO);
                         if (result != null)
                         {
                             //灏嗙綉鍏崇殑鏁版嵁璁剧疆鍒版湰鍦扮紦瀛樹腑
@@ -1415,11 +1348,10 @@
 
                             HdlThreadLogic.Current.RunMain(() =>
                             {
-                                string keyName = Common.LocalDevice.deviceModelIdName + zbGateway.LinuxImageType;
-                                if (Common.LocalDevice.Current.dicDeviceAllNameID.ContainsKey(keyName) == true)
+                                var nameContent = LocalDevice.Current.GetDeviceModelIdNameInfo(zbGateway.LinuxImageType.ToString());
+                                if (nameContent != null)
                                 {
-                                    //浣跨敤R鏂囦欢閲岄潰璁剧疆鐨勪笢瑗�
-                                    button.TextID = LocalDevice.Current.dicDeviceAllNameID[keyName];
+                                    button.Text = nameContent.A瀹樻柟鍚嶅瓧;
                                 }
                             });
                         }
@@ -1428,11 +1360,10 @@
             }
             else
             {
-                string keyName = Common.LocalDevice.deviceModelIdName + this.dicGateway[gwId].LinuxImageType;
-                if (Common.LocalDevice.Current.dicDeviceAllNameID.ContainsKey(keyName) == true)
+                var nameContent = LocalDevice.Current.GetDeviceModelIdNameInfo(zbGateway.LinuxImageType.ToString());
+                if (nameContent != null)
                 {
-                    //浣跨敤R鏂囦欢閲岄潰璁剧疆鐨勪笢瑗�
-                    button.TextID = Common.LocalDevice.Current.dicDeviceAllNameID[keyName];
+                    button.Text = nameContent.A瀹樻柟鍚嶅瓧;
                 }
             }
         }
@@ -1445,13 +1376,14 @@
         /// 鑾峰彇缃戝叧淇℃伅(鐗堟湰淇℃伅,闀滃儚绫诲瀷,鍩烘湰淇℃伅绛夈�傚彧鍒锋柊鏈湴缃戝叧鐨勭紦瀛�)
         /// </summary>
         /// <param name="zbGateway"></param>
+        /// <param name="useLocalConnect">鏄惁寮哄埗浣跨敤鏈湴杩炴帴鍙戦��</param>
         /// <param name="mode"></param>
         /// <returns></returns>
-        public ZbGatewayData.GetGwData GetGatewayInfo(ZbGateway zbGateway, ShowErrorMode mode = ShowErrorMode.YES)
+        public ZbGatewayData.GetGwData GetGatewayInfo(ZbGateway zbGateway, bool useLocalConnect, ShowErrorMode mode = ShowErrorMode.YES)
         {
             //鑾峰彇缃戝叧鐗堟湰淇℃伅
             var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 95 } };
-            var result = this.SendJobjectDataToGateway(zbGateway, "GetZbGwInfo", jObject.ToString(), "GetZbGwInfo_Respon");
+            var result = this.SendJobjectDataToGateway(zbGateway, "GetZbGwInfo", jObject.ToString(), "GetZbGwInfo_Respon", 5, useLocalConnect);
 
             if (result.ErrorMsgDiv != 1)
             {
@@ -1500,6 +1432,7 @@
             localWay.CoordinatorFirmwareVersion = data.ZbFWVersion;
             localWay.CoordinatorImageId = data.ZbImageType;
             localWay.DriveCodeList = data.DriveCodeList;
+            localWay.GwVersionDate = data.AppVersion;
             if (saveFile == true)
             {
                 localWay.ReSave();
@@ -1538,11 +1471,11 @@
         /// <summary>
         /// 鍙樻洿缃戝叧鎴块棿
         /// </summary>
-        /// <param name="zbGateway">缃戝叧瀵硅薄</param>
+        /// <param name="gwId">缃戝叧Id</param>
         /// <param name="roomId">鎴块棿ID</param>
-        public void ChangedGatewayRoom(ZbGateway zbGateway, string roomId)
+        public void ChangedGatewayRoom(string gwId, string roomId)
         {
-            var localGateway = this.GetLocalGateway(zbGateway.GwId);
+            var localGateway = this.GetLocalGateway(gwId);
             if (localGateway != null)
             {
                 localGateway.RoomId = roomId;
@@ -1587,7 +1520,7 @@
         public List<FirmwareVersionInfo> GetGatewayAllNewVersion(ZbGateway zbGateway, ShowErrorMode mode = ShowErrorMode.YES)
         {
             //鑾峰彇缃戝叧鐗堟湰淇℃伅
-            var result = this.GetGatewayInfo(zbGateway, mode);
+            var result = this.GetGatewayInfo(zbGateway, false, mode);
             if (result == null)
             {
                 return null;
@@ -1737,7 +1670,7 @@
                     //缁欎竴涓嚎绋嬪幓鑾峰彇瀹冪殑闀滃儚绫诲瀷
                     HdlThreadLogic.Current.RunThread(() =>
                     {
-                        var result = this.GetGatewayInfo(zbGateway, ShowErrorMode.NO);
+                        var result = this.GetGatewayInfo(zbGateway, true, ShowErrorMode.NO);
                         if (result != null)
                         {
                             //灏嗙綉鍏崇殑鏁版嵁璁剧疆鍒版湰鍦扮紦瀛樹腑
@@ -1775,7 +1708,7 @@
                     //缁欎竴涓嚎绋嬪幓鑾峰彇瀹冪殑闀滃儚绫诲瀷
                     HdlThreadLogic.Current.RunThread(() =>
                     {
-                        var result = this.GetGatewayInfo(zbGateway, ShowErrorMode.NO);
+                        var result = this.GetGatewayInfo(zbGateway, true, ShowErrorMode.NO);
                         if (result != null)
                         {
                             //灏嗙綉鍏崇殑鏁版嵁璁剧疆鍒版湰鍦扮紦瀛樹腑
@@ -2008,7 +1941,7 @@
             //鑾峰彇鎺у埗涓讳汉璐﹀彿鐨凾oken
             Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
 
-            List<string> listNotShowError = new List<string>() { "NoExist", "NoBind", "NoRecord" };
+            List<string> listNotShowError = new List<string>() { "NoExist", "NoBind", "NoRecord", "NotCheck" };
 
             bool result = UserCenterLogic.GetResultStatuByRequestHttps("App/ReleaseGatewayToHome", true, Pra, listNotShowError);
             if (result == false)
@@ -2034,9 +1967,7 @@
                 listBackupGwId.Add(strId);
 
                 //澶囦唤
-                var strData = Newtonsoft.Json.JsonConvert.SerializeObject(listBackupGwId);
-                var byteData = System.Text.Encoding.UTF8.GetBytes(strData);
-                Global.WriteFileToDirectoryByBytes(DirNameResourse.LocalMemoryDirectory, DirNameResourse.BackupGatewayIdFile, byteData);
+                HdlFileLogic.Current.SaveFileContent(DirNameResourse.BackupGatewayIdFile, listBackupGwId);
             }
         }
 
@@ -2047,7 +1978,7 @@
         {
             HdlThreadLogic.Current.RunThread(() =>
             {
-                var fileData = Global.ReadFileByDirectory(DirNameResourse.LocalMemoryDirectory, DirNameResourse.BackupGatewayIdFile);
+                var fileData = HdlFileLogic.Current.ReadFileByteContent(DirNameResourse.BackupGatewayIdFile);
                 if (fileData == null)
                 {
                     return;
@@ -2065,7 +1996,7 @@
                 {
                     bindGateway.BindGateways.Clear();
                     bindGateway.BindGateways.Add(gwId);
-                    var result = UserCenterLogic.GetResultCodeByRequestHttps("App/BindGatewayToHome", true, bindGateway);
+                    var result = UserCenterLogic.GetResultCodeByRequestHttps("App/BindGatewayToHome", true, bindGateway, new List<string> { "NotCheck" });
                     if (result == "Success")
                     {
                         this.listBackupGwId.Remove(gwId);
@@ -2079,7 +2010,7 @@
                 if (this.listBackupGwId.Count == 0)
                 {
                     //濡傛灉娌℃湁浜嗗唴瀹�,鍒欏垹闄ゆ枃浠�
-                    string file = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.BackupGatewayIdFile);
+                    string file = DirNameResourse.BackupGatewayIdFile;
                     if (System.IO.File.Exists(file) == true)
                     {
                         System.IO.File.Delete(file);
@@ -2088,9 +2019,7 @@
                 else
                 {
                     //澶囦唤
-                    var strData = Newtonsoft.Json.JsonConvert.SerializeObject(listBackupGwId);
-                    var byteData = System.Text.Encoding.UTF8.GetBytes(strData);
-                    Global.WriteFileToDirectoryByBytes(DirNameResourse.LocalMemoryDirectory, DirNameResourse.BackupGatewayIdFile, byteData);
+                    HdlFileLogic.Current.SaveFileContent(DirNameResourse.BackupGatewayIdFile, listBackupGwId);
                 }
             });
         }
@@ -2107,8 +2036,9 @@
         /// <param name="sendData">闇�瑕佸彂閫佺殑鏁版嵁  JObject.ToString()鐨勪笢瑗�</param>
         /// <param name="receiptTopic">鎸囧畾鎺ユ敹鍝釜涓婚</param>
         /// <param name="waitTime">瓒呮椂鏃堕棿(绉�)</param>
+        /// <param name="useLocalConnect">鏄惁寮哄埗浣跨敤鏈湴杩炴帴鍙戦��</param>
         /// <returns>缃戝叧杩斿洖鐨勬暟鎹�</returns>
-        public ReceiptGatewayResult SendJobjectDataToGateway(ZbGateway gateway, string sendTopic, string sendData, string receiptTopic, int waitTime = 5)
+        public ReceiptGatewayResult SendJobjectDataToGateway(ZbGateway gateway, string sendTopic, string sendData, string receiptTopic, int waitTime = 5, bool useLocalConnect = false)
         {
             var reResult = new ReceiptGatewayResult();
 
@@ -2145,7 +2075,14 @@
             };
             myGateway.Actions += receiptAction;
             //鍙戦�佹暟鎹�
-            myGateway.Send(sendTopic, sendData);
+            if (useLocalConnect == false)
+            {
+                myGateway.Send(sendTopic, sendData);
+            }
+            else
+            {
+                myGateway.SendLocation(sendTopic, System.Text.Encoding.UTF8.GetBytes(sendData));
+            }
 
             //瓒呮椂鏃堕棿
             int TimeOut = 0;

--
Gitblit v1.8.0