| | |
| | | /// <param name="zbGateway">网关</param> |
| | | /// <param name="mode">是否显示错误</param> |
| | | public async Task<bool> AddNewGateway(ZbGateway zbGateway, ShowErrorMode mode) |
| | | { |
| | | {
|
| | | //设置网关的经纬度
|
| | | bool falge = this.SetGatewaySite(zbGateway, Common.Config.Instance.Home.Longitude, Common.Config.Instance.Home.Latitude, ShowErrorMode.NO); |
| | | if (falge == false)
|
| | | {
|
| | | return falge;
|
| | | } |
| | | //执行添加网关到内存 |
| | | var result = await this.DoAddGatewayToMemory(zbGateway, mode); |
| | | //前的网关绑定在了当前账号下的不同住宅里面
|
| | |
| | | {
|
| | | return false;
|
| | | } |
| | | //设置网关的经纬度 |
| | | bool falge = this.SetGatewaySite(zbGateway, Common.Config.Instance.Home.Longitude, Common.Config.Instance.Home.Latitude); |
| | | return falge; |
| | | return true; |
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | return -1;
|
| | | }
|
| | | //设置网关的经纬度
|
| | | bool falge = this.SetGatewaySite(zbGateway, Common.Config.Instance.Home.Longitude, Common.Config.Instance.Home.Latitude); |
| | | bool falge = this.SetGatewaySite(zbGateway, Common.Config.Instance.Home.Longitude, Common.Config.Instance.Home.Latitude, ShowErrorMode.YES); |
| | | if (falge == false)
|
| | | {
|
| | | return -1;
|
| | |
| | | if (mode == GetNameMode.SpecialGateway && localWay.getGwInfo != null)
|
| | | {
|
| | | string keyName = Common.LocalDevice.deviceModelIdName + this.GetGwInfoAttribute(localWay, "LinuxImageType").ToString();
|
| | | if (Common.LocalDevice.Current.dicDeviceDefultNameID.ContainsKey(keyName) == true)
|
| | | if (LocalDevice.Current.dicDeviceAllNameID.ContainsKey(keyName) == true)
|
| | | {
|
| | | //没有名称时,则使用R文件里面设置的东西
|
| | | return Language.StringByID(Common.LocalDevice.Current.dicDeviceDefultNameID[keyName]);
|
| | | //没有名称时,则使用R文件里面设置的默认设备名称
|
| | | return Language.StringByID(LocalDevice.Current.dicDeviceAllNameID[keyName] + 20000);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | if (zbGateway.getGwInfo != null && zbGateway.getGwInfo.LinuxImageType != 0)
|
| | | {
|
| | | string keyName = Common.LocalDevice.deviceModelIdName + zbGateway.getGwInfo.LinuxImageType;
|
| | | if (Common.LocalDevice.Current.dicDeviceDefultNameID.ContainsKey(keyName) == true)
|
| | | if (Common.LocalDevice.Current.dicDeviceAllNameID.ContainsKey(keyName) == true)
|
| | | {
|
| | | //使用R文件里面设置的东西
|
| | | button.TextID = LocalDevice.Current.dicDeviceDefultNameID[keyName];
|
| | | button.TextID = LocalDevice.Current.dicDeviceAllNameID[keyName];
|
| | | }
|
| | | }
|
| | | else
|
| | |
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | string keyName = Common.LocalDevice.deviceModelIdName + zbGateway.getGwInfo.LinuxImageType;
|
| | | if (Common.LocalDevice.Current.dicDeviceDefultNameID.ContainsKey(keyName) == true)
|
| | | if (Common.LocalDevice.Current.dicDeviceAllNameID.ContainsKey(keyName) == true)
|
| | | {
|
| | | //使用R文件里面设置的东西
|
| | | button.TextID = LocalDevice.Current.dicDeviceDefultNameID[keyName];
|
| | | button.TextID = LocalDevice.Current.dicDeviceAllNameID[keyName];
|
| | | }
|
| | | });
|
| | | }
|
| | |
| | | else
|
| | | {
|
| | | string keyName = Common.LocalDevice.deviceModelIdName + this.dicGateway[gwId].getGwInfo.LinuxImageType;
|
| | | if (Common.LocalDevice.Current.dicDeviceDefultNameID.ContainsKey(keyName) == true)
|
| | | if (Common.LocalDevice.Current.dicDeviceAllNameID.ContainsKey(keyName) == true)
|
| | | {
|
| | | //使用R文件里面设置的东西
|
| | | button.TextID = Common.LocalDevice.Current.dicDeviceDefultNameID[keyName];
|
| | | button.TextID = Common.LocalDevice.Current.dicDeviceAllNameID[keyName];
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | System.Threading.Thread.Sleep(500);
|
| | | }
|
| | | return result;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 网关房间相关_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 获取网关所在的房间
|
| | | /// </summary>
|
| | | /// <param name="zbGateway">网关对象</param>
|
| | | /// <returns></returns>
|
| | | public Room GetRoomByGateway(ZbGateway zbGateway)
|
| | | {
|
| | | var gatewayId = this.GetGatewayId(zbGateway);
|
| | | return this.GetRoomByGateway(gatewayId);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取网关所在的房间
|
| | | /// </summary>
|
| | | /// <param name="gatewayId">网关ID</param>
|
| | | /// <returns></returns>
|
| | | public Room GetRoomByGateway(string gatewayId)
|
| | | {
|
| | | var localGateway = this.GetLocalGateway(gatewayId);
|
| | | if (localGateway == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | return HdlRoomLogic.Current.GetRoomById(localGateway.RoomId);
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 变更网关房间
|
| | | /// </summary>
|
| | | /// <param name="zbGateway">网关对象</param>
|
| | | /// <param name="roomId">房间ID</param>
|
| | | public void ChangedGatewayRoom(ZbGateway zbGateway, string roomId)
|
| | | {
|
| | | var gatewayId = this.GetGatewayId(zbGateway);
|
| | | var localGateway = this.GetLocalGateway(gatewayId);
|
| | | if (localGateway != null)
|
| | | {
|
| | | localGateway.RoomId = roomId;
|
| | | localGateway.ReSave();
|
| | | //添加备份
|
| | | HdlAutoBackupLogic.AddOrEditorFile(localGateway.FilePath);
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// <param name="gateway">网关对象</param>
|
| | | /// <param name="Longitude">经度</param>
|
| | | /// <param name="Latitude">维度</param>
|
| | | /// <param name="mode">显示错误</param>
|
| | | /// <returns></returns>
|
| | | public bool SetGatewaySite(ZbGateway gateway, double Longitude, double Latitude)
|
| | | public bool SetGatewaySite(ZbGateway gateway, double Longitude, double Latitude, ShowErrorMode mode)
|
| | | {
|
| | | ZbGateway realWay = null;
|
| | | if (this.GetRealGateway(ref realWay, gateway) == false)
|
| | | {
|
| | | //错误:网关对象丢失
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg);
|
| | | this.ShowTipMsg(msg);
|
| | | if (mode == ShowErrorMode.YES)
|
| | | {
|
| | | //错误:网关对象丢失
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg);
|
| | | this.ShowTipMsg(msg);
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | |
| | | realWay.Actions -= action;
|
| | | if (result != 0)
|
| | | {
|
| | | //设置网关经纬度失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uSetGatewaySiteFail);
|
| | | if (result == -1)
|
| | | if (mode == ShowErrorMode.YES)
|
| | | {
|
| | | msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "回复超时");
|
| | | //设置网关经纬度失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uSetGatewaySiteFail);
|
| | | if (result == -1)
|
| | | {
|
| | | msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "回复超时");
|
| | | }
|
| | | this.ShowTipMsg(msg);
|
| | | }
|
| | | this.ShowTipMsg(msg);
|
| | | return false;
|
| | | }
|
| | |
|