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/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 40 insertions(+), 8 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs index 0993102..023fb10 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 @@ -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) -- Gitblit v1.8.0