| | |
| | | /// <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 |
| | |
| | | }
|
| | | 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>
|
| | |
| | | //错误:网关对象丢失
|
| | | 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;
|
| | | }
|
| | |
|
| | |
| | | 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 |
| | |
| | | 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)
|