From a4924de3136289d10cabbf2f61a228387d44ded7 Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期四, 07 十一月 2019 13:48:36 +0800 Subject: [PATCH] Merge branch 'dev-tzy' into DEV_GXC --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs | 272 ++++++++++++----------------------------------------- 1 files changed, 64 insertions(+), 208 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs index 7bfa527..a6f4487 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayLogic.cs @@ -391,7 +391,7 @@ /// 閲嶆柊缁戝畾缃戝叧(1:姝e父 -1:寮傚父 0:褰撳墠鐨勭綉鍏崇粦瀹氬湪浜嗗綋鍓嶈处鍙蜂笅鐨勪笉鍚屼綇瀹呴噷闈�) /// </summary> /// <param name="zbGateway">缃戝叧</param> - public async Task<int> ReBindNewGateway(ZbGateway zbGateway, NormalViewControl btnMsg = null) + public async Task<int> ReBindNewGateway(ZbGateway zbGateway) { if (zbGateway == null) { @@ -424,19 +424,9 @@ HdlGatewayLogic.Current.BackupGatewayIdOnNotNetwork(zbGateway); } - if (btnMsg == null) - { - //缃戝叧鍐呴儴鏁版嵁鍙樻洿涓�,璇风◢鍚� - ProgressBar.SetValue(Language.StringByID(R.MyInternationalizationString.uGatewayDataIsChangingPleaseWhait)); - } - else - { - HdlThreadLogic.Current.RunMain(() => - { - //缃戝叧鍐呴儴鏁版嵁鍙樻洿涓�,璇风◢鍚� - btnMsg.TextID = R.MyInternationalizationString.uGatewayDataIsChangingPleaseWhait; - }); - } + //缃戝叧鍐呴儴鏁版嵁鍙樻洿涓�,璇风◢鍚� + ProgressBar.SetValue(Language.StringByID(R.MyInternationalizationString.uGatewayDataIsChangingPleaseWhait)); + await System.Threading.Tasks.Task.Delay(8000); //鑾峰彇缃戝叧鐨勪俊鎭� @@ -548,104 +538,8 @@ 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 = 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 鈻� 鍒犻櫎缃戝叧___________________________ @@ -784,8 +678,8 @@ if (waitTime == true) { - //杩欐槸绗竴閬撳潕,寮哄埗妫�鏌IFI:绛夊緟2绉�(鍥犱负wifi鐨勬椂鍊欙紝瀹冧細鑷姩鍘诲埛鏂癴lage) - System.Threading.Thread.Sleep(2000); + //杩欐槸绗竴閬撳潕,寮哄埗妫�鏌IFI:绛夊緟3绉�(鍥犱负wifi鐨勬椂鍊欙紝瀹冧細鑷姩鍘诲埛鏂癴lage) + System.Threading.Thread.Sleep(3000); //妫�鏌ユ槸鍚︽嫢鏈夌綉鍏冲瓨鍦ㄤ簬WIFi涓� if (this.CheckHadGatewayInWifi(listRealWay) == false) { @@ -1159,60 +1053,38 @@ } /// <summary> - /// 璁剧疆缃戝叧闀滃儚绫诲瀷鐨勭炕璇戝悕瀛� + /// 鑾峰彇缃戝叧闀滃儚绫诲瀷鐨勭炕璇戝悕瀛� /// </summary> - /// <param name="button"></param> /// <param name="zbGateway"></param> /// <returns></returns> - public void SetGatewayImageText(Button button, ZbGateway zbGateway) + public string GetGatewayImageText(ZbGateway zbGateway) { - //鍒濆鍊�:鏃犳硶璇嗗埆鐨勭綉鍏宠澶� - button.TextID = R.MyInternationalizationString.uUnDistinguishTheGatewayDevice; - string gwId = this.GetGatewayId(zbGateway); + int imageType = -1; if (this.dicGateway.ContainsKey(gwId) == false || this.dicGateway[gwId].getGwInfo == null) { //濡傛灉杩欎釜缃戝叧娌℃湁淇℃伅锛屽垯浠庢柊鑾峰彇 - if (zbGateway.getGwInfo != null && zbGateway.getGwInfo.LinuxImageType != 0) + var result = this.GetGatewayNewInfo(zbGateway, ShowErrorMode.NO); + if (result == null) { - string keyName = Common.LocalDevice.deviceModelIdName + zbGateway.getGwInfo.LinuxImageType; - if (Common.LocalDevice.Current.dicDeviceDefultNameID.ContainsKey(keyName) == true) - { - //浣跨敤R鏂囦欢閲岄潰璁剧疆鐨勪笢瑗� - button.TextID = LocalDevice.Current.dicDeviceDefultNameID[keyName]; - } + //鏃犳硶璇嗗埆鐨勭綉鍏宠澶� + return Language.StringByID(R.MyInternationalizationString.uUnDistinguishTheGatewayDevice); } - else - { - //缁欎竴涓嚎绋嬪幓鑾峰彇瀹冪殑闀滃儚绫诲瀷 - HdlThreadLogic.Current.RunThread(async () => - { - var result = await this.GetGatewayNewInfoAsync(zbGateway, ShowErrorMode.NO); - if (result != null) - { - zbGateway.getGwInfo = result; - HdlThreadLogic.Current.RunMain(() => - { - string keyName = Common.LocalDevice.deviceModelIdName + zbGateway.getGwInfo.LinuxImageType; - if (Common.LocalDevice.Current.dicDeviceDefultNameID.ContainsKey(keyName) == true) - { - //浣跨敤R鏂囦欢閲岄潰璁剧疆鐨勪笢瑗� - button.TextID = LocalDevice.Current.dicDeviceDefultNameID[keyName]; - } - }); - } - }); - } + imageType = result.LinuxImageType; } else { - string keyName = Common.LocalDevice.deviceModelIdName + this.dicGateway[gwId].getGwInfo.LinuxImageType; - if (Common.LocalDevice.Current.dicDeviceDefultNameID.ContainsKey(keyName) == true) - { - //浣跨敤R鏂囦欢閲岄潰璁剧疆鐨勪笢瑗� - button.TextID = Common.LocalDevice.Current.dicDeviceDefultNameID[keyName]; - } + imageType = Convert.ToInt32(this.GetGwInfoAttribute(this.dicGateway[gwId], "LinuxImageType")); } + string keyName = Common.LocalDevice.deviceModelIdName + imageType; + if (Common.LocalDevice.Current.dicDeviceDefultNameID.ContainsKey(keyName) == true) + { + //浣跨敤R鏂囦欢閲岄潰璁剧疆鐨勪笢瑗� + return Language.StringByID(Common.LocalDevice.Current.dicDeviceDefultNameID[keyName]); + } + + //鏃犳硶璇嗗埆鐨勭綉鍏宠澶� + return Language.StringByID(R.MyInternationalizationString.uUnDistinguishTheGatewayDevice); } #endregion @@ -1442,7 +1314,7 @@ #region 鈻� 涓荤綉鍏冲垽瀹歘________________________ /// <summary> - /// 鍒ゆ柇鏄惁涓荤綉鍏�(1:涓荤綉鍏� 0:涓嶅湪绾� 2:瀛愮綉鍏�) + /// 鍒ゆ柇鏄惁涓荤綉鍏�(1:涓荤綉鍏� 0:涓嶅湪绾� -1:杩滅▼妯″紡,涓嶅瓨鍦ㄥ暐涓荤綉鍏崇殑璇存硶) /// </summary> /// <param name="zbGateway">缃戝叧瀵硅薄</param> /// <returns></returns> @@ -1453,7 +1325,7 @@ } /// <summary> - /// 鍒ゆ柇鏄惁涓荤綉鍏�(1:涓荤綉鍏� 0:涓嶅湪绾� 2:瀛愮綉鍏�) + /// 鍒ゆ柇鏄惁涓荤綉鍏�(1:涓荤綉鍏� 0:涓嶅湪绾� -1:杩滅▼妯″紡,涓嶅瓨鍦ㄥ暐涓荤綉鍏崇殑璇存硶) /// </summary> /// <param name="waiID">缃戝叧id</param> /// <returns></returns> @@ -1464,7 +1336,7 @@ { return 0; } - return zbGateway.IsMainGateWay == true ? 1 : 2; + return zbGateway.IsMainGateWay == true ? 1 : 0; } #endregion @@ -1472,7 +1344,7 @@ #region 鈻� 璁剧疆缃戝叧鍥剧墖_______________________ /// <summary> - /// 璁剧疆鐪熷疄缃戝叧鐨勫浘鐗� + /// 璁剧疆鐪熷疄缃戝叧鐨勫浘鐗囷紝瑙勬牸锛�915X492 /// </summary> /// <param name="button"></param> /// <param name="zbGateway"></param> @@ -1482,35 +1354,30 @@ var localWay = this.GetLocalGateway(gwID); if (localWay == null || localWay.getGwInfo == null) { - if (zbGateway.getGwInfo != null && zbGateway.getGwInfo.LinuxImageType != 0) + //缁欎竴涓嚎绋嬪幓鑾峰彇瀹冪殑闀滃儚绫诲瀷 + HdlThreadLogic.Current.RunThread(async () => { - button.UnSelectedImagePath = "Gateway/RealGateway" + zbGateway.getGwInfo.LinuxImageType + ".png"; - } - else - { - //缁欎竴涓嚎绋嬪幓鑾峰彇瀹冪殑闀滃儚绫诲瀷 - HdlThreadLogic.Current.RunThread(async () => + var result = await this.GetGatewayNewInfoAsync(zbGateway, ShowErrorMode.NO); + if (result != null) { - var result = await this.GetGatewayNewInfoAsync(zbGateway, ShowErrorMode.NO); - if (result != null) + Application.RunOnMainThread(() => { - zbGateway.getGwInfo = result; - HdlThreadLogic.Current.RunMain(() => + if (button != null) { button.UnSelectedImagePath = "Gateway/RealGateway" + result.LinuxImageType + ".png"; - }); - } - }); - } + } + }); + } + }); } else { - button.UnSelectedImagePath = "Gateway/RealGateway" + localWay.getGwInfo.LinuxImageType + ".png"; + button.UnSelectedImagePath = "Gateway/RealGateway" + this.GetGwInfoAttribute(localWay, "LinuxImageType").ToString() + ".png"; } } /// <summary> - /// 璁剧疆缃戝叧鍥炬爣 + /// 璁剧疆缃戝叧鍥炬爣锛岃鏍硷細110X110 /// </summary> /// <param name="button"></param> /// <param name="zbGateway"></param> @@ -1520,30 +1387,28 @@ var localWay = this.GetLocalGateway(gwID); if (localWay == null || localWay.getGwInfo == null) { - if (zbGateway.getGwInfo != null && zbGateway.getGwInfo.LinuxImageType != 0) + //缁欎竴涓嚎绋嬪幓鑾峰彇瀹冪殑闀滃儚绫诲瀷 + HdlThreadLogic.Current.RunThread(async () => { - button.UnSelectedImagePath = "Gateway/GatewayIcon" + zbGateway.getGwInfo.LinuxImageType + ".png"; - } - else - { - //缁欎竴涓嚎绋嬪幓鑾峰彇瀹冪殑闀滃儚绫诲瀷 - HdlThreadLogic.Current.RunThread(async () => + var result = await this.GetGatewayNewInfoAsync(zbGateway, ShowErrorMode.NO); + if (result != null) { - var result = await this.GetGatewayNewInfoAsync(zbGateway, ShowErrorMode.NO); - if (result != null) + Application.RunOnMainThread(() => { - zbGateway.getGwInfo = result; - HdlThreadLogic.Current.RunMain(() => + if (button != null) { button.UnSelectedImagePath = "Gateway/GatewayIcon" + result.LinuxImageType + ".png"; - }); - } - }); - } + button.SelectedImagePath = "Gateway/GatewayIcon" + result.LinuxImageType + "Selected.png"; + } + }); + } + }); } else { - button.UnSelectedImagePath = "Gateway/GatewayIcon" + localWay.getGwInfo.LinuxImageType + ".png"; + string linType = this.GetGwInfoAttribute(localWay, "LinuxImageType").ToString(); + button.UnSelectedImagePath = "Gateway/GatewayIcon" + linType + ".png"; + button.SelectedImagePath = "Gateway/GatewayIcon" + linType + "Selected.png"; } } @@ -1578,13 +1443,13 @@ #endregion - #region 鈻� 缃戝叧瀹氫綅___________________________ + #region 鈻� 娴嬭瘯缃戝叧___________________________ /// <summary> - /// 鍙戦�佹寚浠ゅ埌缃戝叧杩涜瀹氫綅(缃戝叧LED闂儊璇嗗埆) + /// 鍙戦�佹祴璇曟寚浠ゅ埌璁惧(缃戝叧LED闂儊璇嗗埆) /// </summary> /// <param name="zbGateway"></param> - public void SetFixedPositionCommand(ZbGateway zbGateway) + public void SetTestCommand(ZbGateway zbGateway) { ZbGateway realWay = null; if (this.GetRealGateway(ref realWay, zbGateway) == false) @@ -2247,19 +2112,19 @@ else if (backType == GatewayBackupEnum.APir鐏厜閰嶇疆) { var recoverData = Newtonsoft.Json.JsonConvert.DeserializeObject<IASZone.ConfigureParamates>(System.Text.Encoding.UTF8.GetString(byteData)); - result = await HdlDevicePirSensorLogic.Current.SetPirSensorLightSettion((IASZone)device, recoverData); + result = await HdlPirSensorLogic.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 HdlDevicePanelLogic.Current.SetPanelEpointColorInfo((Panel)device, recoverData); + result = await HdlPanelLogic.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 HdlDevicePanelLogic.Current.SetDeviceLightSettion((Panel)device, directionsLevel, backlightLevel); + result = await HdlPanelLogic.Current.SetDeviceLightSettion((Panel)device, directionsLevel, backlightLevel); } else if (backType == GatewayBackupEnum.A骞叉帴鐐硅妭鑳芥ā寮�) { @@ -2267,21 +2132,12 @@ bool modeEnable = Convert.ToBoolean(recoverData["modeEnable"]); int modeTime = Convert.ToInt32(recoverData["modeTime"]); int level = Convert.ToInt32(recoverData["level"]); - result = await HdlDevicePanelLogic.Current.SetDeviceEnergyConservationMode((Panel)device, modeEnable, modeTime, level); + result = await HdlPanelLogic.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 HdlDevicePanelLogic.Current.EditorDryContactFunction((Panel)device, recoverData); - } - else if (backType == GatewayBackupEnum.A绐楀笜鏂瑰悜) - { - } - else if (backType == GatewayBackupEnum.A绐楀笜鎵嬫媺鎺у埗) - { - } - else if (backType == GatewayBackupEnum.A绐楀笜涓婁笅闄愪綅) - { + result = await HdlPanelLogic.Current.EditorDryContactFunction((Panel)device, recoverData); } return result == true ? 1 : -1; } -- Gitblit v1.8.0