From b8cbf4a8b6910eefcb83b6d3a39e9b5b5a9cd79e Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 10 一月 2020 16:39:22 +0800
Subject: [PATCH] 2019.1.10

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs |   52 ++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 42 insertions(+), 10 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs
index 0993102..0222f38 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs
@@ -178,10 +178,18 @@
         /// <returns></returns>
         private ZbGateway GetGatewayFromFile(string file)
         {
-            byte[] filebyte = Global.ReadFileByHomeId(file);
-            string strvalue = System.Text.Encoding.UTF8.GetString(filebyte);
-            var gateway = JsonConvert.DeserializeObject<ZbGateway>(strvalue);
-            return gateway;
+            try
+            {
+                byte[] filebyte = Global.ReadFileByHomeId(file);
+                string strvalue = System.Text.Encoding.UTF8.GetString(filebyte);
+                var gateway = JsonConvert.DeserializeObject<ZbGateway>(strvalue);
+                return gateway;
+            }
+            catch (Exception ex)
+            {
+                HdlLogLogic.Current.WriteLog(ex);
+                return null;
+            }
         }
 
         #endregion
@@ -212,11 +220,13 @@
                 }
                 return false;
             }
-            if (result != 1)
+            if (result == -1)
             {
                 return false;
             }
-            return true;
+            //璁剧疆缃戝叧鐨勭粡绾害
+            bool falge = this.SetGatewaySite(zbGateway, Common.Config.Instance.Home.Longitude, Common.Config.Instance.Home.Latitude);
+            return falge;
         }
 
         /// <summary>
@@ -422,6 +432,12 @@
                 //閿欒:缃戝叧瀵硅薄涓㈠け
                 string msg = Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg);
                 this.ShowTipMsg(msg);
+                return -1;
+            }
+            //璁剧疆缃戝叧鐨勭粡绾害
+            bool falge = this.SetGatewaySite(zbGateway, Common.Config.Instance.Home.Longitude, Common.Config.Instance.Home.Latitude);
+            if (falge == false)
+            {
                 return -1;
             }
 
@@ -1832,7 +1848,15 @@
                 return;
             }
             var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 85 } };
-            realWay.Send("GwLinuxLocate_Respon", jObject.ToString());
+            if (this.IsGatewayExist(zbGateway) == true)
+            {
+                realWay.Send("GwLinuxLocate_Respon", jObject.ToString());
+            }
+            else
+            {
+                //濡傛灉杩欎釜缃戝叧杩樻病鏈夌粦瀹氱殑璇濓紝鍒欏己鍒朵娇鐢ㄦ湰鍦拌繛鎺�
+                realWay.SendLocation("GwLinuxLocate_Respon", System.Text.Encoding.UTF8.GetBytes(jObject.ToString()));
+            }
         }
 
         #endregion
@@ -2121,7 +2145,7 @@
             bool canBreak = false;
             HdlThreadLogic.Current.RunThread(async () =>
             {
-                List<string> list = new List<string>() { "NotSetAgain" };
+                List<string> list = new List<string>() { "NotSetAgain", "NotCheck" };
 
                 //璁剧疆璁块棶鎺ュ彛鐨勫弬鏁�
                 var pra = new GetGatewayPra();
@@ -2205,7 +2229,15 @@
             var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 2013 } };
             var data = new Newtonsoft.Json.Linq.JObject { { "Longitude", intLongitude }, { "Latitude", intLatitude } };
             jObject.Add("Data", data);
-            realWay.Send("Logic/SetSite", jObject.ToString());
+            if (this.IsGatewayExist(gateway) == true)
+            {
+                realWay.Send("Logic/SetSite", jObject.ToString());
+            }
+            else
+            {
+                //濡傛灉杩欎釜缃戝叧杩樻病鏈夌粦瀹氱殑璇濓紝鍒欏己鍒朵娇鐢ㄦ湰鍦拌繛鎺�
+                realWay.SendLocation("Logic/SetSite", System.Text.Encoding.UTF8.GetBytes(jObject.ToString()));
+            }
 
             int TimeOut = 0;
             while (result == -1 && TimeOut < 30)
@@ -2514,7 +2546,7 @@
             else if (backType == GatewayBackupEnum.APir鐏厜閰嶇疆)
             {
                 var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.ConfigureParamates>(System.Text.Encoding.UTF8.GetString(byteData));
-                result = await HdlDevicePirSensorLogic.Current.SetPirSensorLightSettion((IASZone)device, recoverData);
+                result = await HdlDevicePirSensorLogic.Current.SetPirSensorSettion((IASZone)device, recoverData);
             }
             else if (backType == GatewayBackupEnum.A骞叉帴鐐归鑹茶皟鑺�)
             {

--
Gitblit v1.8.0