| | |
| | | HdlAutoBackupLogic.AddOrEditorFile(zbGateway.FilePath); |
| | | |
| | | return true; |
| | | } |
| | | |
| | | }
|
| | |
|
| | | #endregion |
| | |
|
| | | #region ■ 网关切换___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 执行切换网关操作
|
| | | /// </summary>
|
| | | /// <param name="gatewayId"></param>
|
| | | 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)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | }
|
| | | //切换网关,保存缓存
|
| | | this.SaveGatewayIdToLocation(gatewayId);
|
| | | return true;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取在线网关信息
|
| | | /// </summary>
|
| | | /// <param name="gatewayId"></param>
|
| | | /// <returns></returns>
|
| | | private async Task<bool> GetOnlineGatewayInfo(string gatewayId)
|
| | | {
|
| | | //显示进度条
|
| | | ProgressBar.Show();
|
| | |
|
| | | //检测广播到的这个网关是否拥有住宅ID
|
| | | ZbGateway realWay = null;
|
| | | bool getGatewayInfo = true;
|
| | | if (this.GetRealGateway(ref realWay, gatewayId) == true)
|
| | | {
|
| | | //重新设置住宅ID(这个应该是不经过APP,直接把网关恢复了出厂设置)
|
| | | if (this.HomeIdIsEmpty(realWay.getGatewayBaseInfo.HomeId) == true)
|
| | | {
|
| | | int result2 = await this.ReBindNewGateway(realWay);
|
| | | if (result2 == 0)
|
| | | {
|
| | | //出现未知错误,请稍后再试
|
| | | this.ShowTipMsg(Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndResetAgain));
|
| | | //关闭进度条
|
| | | ProgressBar.Close();
|
| | | }
|
| | | else if (result2 == -1)
|
| | | {
|
| | | //关闭进度条
|
| | | ProgressBar.Close();
|
| | | return false;
|
| | | }
|
| | | //重新绑定网关里面已经重新获取了网关信息
|
| | | getGatewayInfo = false;
|
| | | }
|
| | | }
|
| | |
|
| | | if (getGatewayInfo == true)
|
| | | {
|
| | | //获取网关信息
|
| | | var info = await this.GetGatewayNewInfoAsync(realWay);
|
| | | if (info == null)
|
| | | {
|
| | | //关闭进度条
|
| | | ProgressBar.Close();
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | //获取全部设备
|
| | | bool result = await LocalDevice.Current.SetDeviceToMemmoryByGateway(realWay);
|
| | | //关闭进度条
|
| | | ProgressBar.Close();
|
| | | if (result == false)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 保存选择的网关ID到本地
|
| | | /// </summary>
|
| | | /// <param name="gatewayId"></param>
|
| | | 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);
|
| | | }
|
| | |
|
| | | #endregion |
| | | |
| | | #region ■ 删除网关___________________________ |
| | |
| | |
|
| | | if (waitTime == true)
|
| | | {
|
| | | //这是第一道坎,强制检查WIFI:等待3秒(因为wifi的时候,它会自动去刷新flage)
|
| | | System.Threading.Thread.Sleep(3000);
|
| | | //这是第一道坎,强制检查WIFI:等待2秒(因为wifi的时候,它会自动去刷新flage)
|
| | | System.Threading.Thread.Sleep(2000);
|
| | | //检查是否拥有网关存在于WIFi下
|
| | | if (this.CheckHadGatewayInWifi(listRealWay) == false)
|
| | | {
|
| | |
| | | else if (backType == GatewayBackupEnum.APir灯光配置)
|
| | | {
|
| | | var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.ConfigureParamates>(System.Text.Encoding.UTF8.GetString(byteData));
|
| | | result = await HdlPirSensorLogic.Current.SetPirSensorLightSettion((IASZone)device, recoverData);
|
| | | result = await HdlDevicePirSensorLogic.Current.SetPirSensorLightSettion((IASZone)device, recoverData);
|
| | | }
|
| | | else if (backType == GatewayBackupEnum.A干接点颜色调节)
|
| | | {
|
| | | var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.KeyColorData>(System.Text.Encoding.UTF8.GetString(byteData));
|
| | | result = await HdlPanelLogic.Current.SetPanelEpointColorInfo((Panel)device, recoverData);
|
| | | result = await HdlDevicePanelLogic.Current.SetPanelEpointColorInfo((Panel)device, recoverData);
|
| | | }
|
| | | else if (backType == GatewayBackupEnum.A干接点亮度调节)
|
| | | {
|
| | | var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JObject>(System.Text.Encoding.UTF8.GetString(byteData));
|
| | | int directionsLevel = Convert.ToInt32(recoverData["directionsLevel"]);
|
| | | int backlightLevel = Convert.ToInt32(recoverData["backlightLevel"]);
|
| | | result = await HdlPanelLogic.Current.SetDeviceLightSettion((Panel)device, directionsLevel, backlightLevel);
|
| | | result = await HdlDevicePanelLogic.Current.SetDeviceLightSettion((Panel)device, directionsLevel, backlightLevel);
|
| | | }
|
| | | else if (backType == GatewayBackupEnum.A干接点节能模式)
|
| | | {
|
| | |
| | | bool modeEnable = Convert.ToBoolean(recoverData["modeEnable"]);
|
| | | int modeTime = Convert.ToInt32(recoverData["modeTime"]);
|
| | | int level = Convert.ToInt32(recoverData["level"]);
|
| | | result = await HdlPanelLogic.Current.SetDeviceEnergyConservationMode((Panel)device, modeEnable, modeTime, level);
|
| | | result = await HdlDevicePanelLogic.Current.SetDeviceEnergyConservationMode((Panel)device, modeEnable, modeTime, level);
|
| | | }
|
| | | else if (backType == GatewayBackupEnum.A干接点私有属性)
|
| | | {
|
| | | var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<int>(System.Text.Encoding.UTF8.GetString(byteData));
|
| | | result = await HdlPanelLogic.Current.EditorDryContactFunction((Panel)device, recoverData);
|
| | | result = await HdlDevicePanelLogic.Current.EditorDryContactFunction((Panel)device, recoverData);
|
| | | }
|
| | | else if (backType == GatewayBackupEnum.A窗帘方向)
|
| | | {
|
| | | }
|
| | | else if (backType == GatewayBackupEnum.A窗帘手拉控制)
|
| | | {
|
| | | }
|
| | | else if (backType == GatewayBackupEnum.A窗帘上下限位)
|
| | | {
|
| | | }
|
| | | return result == true ? 1 : -1;
|
| | | }
|