From 31497bb69602433d94c8a28ea01c3ee3c7cc8576 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期四, 24 十月 2019 14:32:30 +0800 Subject: [PATCH] 完全合并了Wjc,Xm 的 代码 --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs | 123 ++++++++++++++++++++++++++++++++++++++--- 1 files changed, 114 insertions(+), 9 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs index 20c6cb8..fd35796 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs @@ -548,8 +548,104 @@ 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(); + + //妫�娴嬪箍鎾埌鐨勮繖涓綉鍏虫槸鍚︽嫢鏈変綇瀹匢D + 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> + /// 淇濆瓨閫夋嫨鐨勭綉鍏矷D鍒版湰鍦� + /// </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 鈻� 鍒犻櫎缃戝叧___________________________ @@ -688,8 +784,8 @@ if (waitTime == true) { - //杩欐槸绗竴閬撳潕,寮哄埗妫�鏌IFI:绛夊緟3绉�(鍥犱负wifi鐨勬椂鍊欙紝瀹冧細鑷姩鍘诲埛鏂癴lage) - System.Threading.Thread.Sleep(3000); + //杩欐槸绗竴閬撳潕,寮哄埗妫�鏌IFI:绛夊緟2绉�(鍥犱负wifi鐨勬椂鍊欙紝瀹冧細鑷姩鍘诲埛鏂癴lage) + System.Threading.Thread.Sleep(2000); //妫�鏌ユ槸鍚︽嫢鏈夌綉鍏冲瓨鍦ㄤ簬WIFi涓� if (this.CheckHadGatewayInWifi(listRealWay) == false) { @@ -2151,19 +2247,19 @@ 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骞叉帴鐐硅妭鑳芥ā寮�) { @@ -2171,12 +2267,21 @@ 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; } -- Gitblit v1.8.0