From e90209beae6a4e822cecb18e6889f8bda23f630e Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期一, 14 十二月 2020 11:16:06 +0800 Subject: [PATCH] 合并了晾衣架(非新云端) --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayBackupLogic.cs | 220 ++++++++++++++++++++++++++---------------------------- 1 files changed, 106 insertions(+), 114 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/Common/Logic/HdlGatewayBackupLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayBackupLogic.cs similarity index 78% rename from ZigbeeApp/Shared/Phone/Common/Logic/HdlGatewayBackupLogic.cs rename to ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayBackupLogic.cs index b0dee6b..dae74bf 100644 --- a/ZigbeeApp/Shared/Phone/Common/Logic/HdlGatewayBackupLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlGatewayBackupLogic.cs @@ -3,7 +3,7 @@ using System.Text; using ZigBee.Device; -namespace Shared.Phone +namespace Shared.Phone.UserCenter { /// <summary> /// 缃戝叧澶囦唤涓氬姟鐨勯�昏緫 @@ -48,10 +48,8 @@ ProgressFormBar.Current.SetMsg(Language.StringByID(R.MyInternationalizationString.uCreatBackupFile)); System.Threading.Thread.Sleep(1000); - //鈽嗐優銉笺偗鈽� //鍒涘缓涓�涓浠藉悕瀛� - //string backupClassId = HdlBackupLogic.Current.CreatNewBackupNameToDB(backupName, 2, realGateway.GwId); - string backupClassId = null; + string backupClassId = HdlBackupLogic.Current.CreatNewBackupNameToDB(backupName, 2, realGateway.GwId); if (backupClassId == null) { //鍏抽棴杩涘害鏉� @@ -142,7 +140,7 @@ string msg = Language.StringByID(R.MyInternationalizationString.uSaveGatewayNVFileFail); if (result == -1) { - msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂"); + msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂"); } this.ShowErrorMsg(msg); return false; @@ -195,7 +193,7 @@ string msg = Language.StringByID(R.MyInternationalizationString.uOpenZbMsComSendFail); if (result == -1) { - msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂"); + msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂"); } this.ShowErrorMsg(msg); return false; @@ -274,29 +272,28 @@ }; realGateway.Actions += action; - //鈽嗐優銉笺偗鈽� - ////鑾峰彇鎺ュ彛鐨勮繛鎺ユā寮� - //string fullUrl = string.Empty; - //var connectMode = HdlUserCenterLogic.GetHttpConnectMode(true); - //if (connectMode == HttpConnectMode.Normal) - //{ - // //鏅�氳闂� - // fullUrl = $"{Common.CommonPage.RequestHttpsHost}/{"App/UploadHomeAppGatewaySubFiles"}"; - //} - //else if (connectMode == HttpConnectMode.Admin) - //{ - // //浠ョ鐞嗗憳鐨勮韩浠借闂紝鑷韩鏄垚鍛� - // fullUrl = $"{Common.Config.Instance.AdminRequestBaseUrl}/{"App/UploadHomeAppGatewaySubFiles"}"; - //} + //鑾峰彇鎺ュ彛鐨勮繛鎺ユā寮� + string fullUrl = string.Empty; + var connectMode = UserCenterLogic.GetHttpConnectMode(true); + if (connectMode == HttpConnectMode.Normal) + { + //鏅�氳闂� + fullUrl = $"{Common.CommonPage.RequestHttpsHost}/{"App/UploadHomeAppGatewaySubFiles"}"; + } + else if (connectMode == HttpConnectMode.Admin) + { + //浠ョ鐞嗗憳鐨勮韩浠借闂紝鑷韩鏄垚鍛� + fullUrl = $"{Common.Config.Instance.AdminRequestBaseUrl}/{"App/UploadHomeAppGatewaySubFiles"}"; + } - //var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 6200 } }; - //var data = new Newtonsoft.Json.Linq.JObject { - // { "url", fullUrl }, { "RequestVersion", Common.CommonPage.RequestVersion }, - // { "LoginAccessToken", HdlUserCenterLogic.GetConnectMainToken() }, { "BackupClassId", backupClassId }, - // { "ManualBackupType", 2 },{ "IsOtherAccountCtrl",connectMode == HttpConnectMode.Admin?1:0} - //}; - //jObject.Add("Data", data); - //realGateway.Send("BackupGwDataFile", jObject.ToString()); + var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 6200 } }; + var data = new Newtonsoft.Json.Linq.JObject { + { "url", fullUrl }, { "RequestVersion", Common.CommonPage.RequestVersion }, + { "LoginAccessToken", UserCenterLogic.GetConnectMainToken() }, { "BackupClassId", backupClassId }, + { "ManualBackupType", 2 },{ "IsOtherAccountCtrl",connectMode == HttpConnectMode.Admin?1:0} + }; + jObject.Add("Data", data); + realGateway.Send("BackupGwDataFile", jObject.ToString()); while (threadAction == true && TimeOut < waitime) { @@ -326,7 +323,8 @@ /// <param name="realGateway">鐪熷疄鐗╃悊缃戝叧瀵硅薄</param> /// <param name="backupId">澶囦唤涓婚敭</param> /// <param name="isAutoBack">0:鑾峰彇缃戝叧鎵嬪姩澶囦唤鏂囦欢鍒楄〃 1:鑾峰彇缃戝叧鑷姩澶囦唤鏂囦欢鍒楄〃</param> - public bool RecoverGateway(ZbGateway realGateway, string backupId, int isAutoBack) + /// <param name="closeBar">鏄惁鍏抽棴杩涘害鏉�</param> + public bool RecoverGateway(ZbGateway realGateway, string backupId, int isAutoBack, bool closeBar = true) { //灞曞紑杩涘害鏉� ProgressFormBar.Current.Start(); @@ -368,8 +366,19 @@ //閲嶅惎缃戝叧绯荤粺 result = this.GatewayReboot(realGateway); - //鍏抽棴杩涘害鏉� - ProgressFormBar.Current.Close(); + + if (result == true) + { + //鍒锋柊鍏ㄩ儴鍦烘櫙 + HdlSceneLogic.Current.RefreshSceneUIList(false); + //鑾峰彇鍏ㄩ儴璁惧 + Common.LocalDevice.Current.SetDeviceToMemmoryByGateway(realGateway.GwId, false); + } + if (closeBar == true) + { + //鍏抽棴杩涘害鏉� + ProgressFormBar.Current.Close(); + } return result; } @@ -387,7 +396,6 @@ { //姝e湪鑾峰彇澶囦唤鏂囦欢鍒楄〃 ProgressFormBar.Current.SetMsg(Language.StringByID(R.MyInternationalizationString.uBackupFileListGetting)); - ProgressFormBar.Current.SetValue(0); System.Threading.Thread.Sleep(1000); int result = -1; @@ -408,30 +416,29 @@ }; realGateway.Actions += action; - //鈽嗐優銉笺偗鈽� - ////鑾峰彇鎺ュ彛鐨勮繛鎺ユā寮� - //string fullUrl = string.Empty; - //var connectMode = HdlUserCenterLogic.GetHttpConnectMode(true); - //if (connectMode == HttpConnectMode.Normal) - //{ - // //鏅�氳闂� - // fullUrl = $"{Common.CommonPage.RequestHttpsHost}/{"App/GetHomeDataBackupUploadListPagger"}"; - //} - //else if (connectMode == HttpConnectMode.Admin) - //{ - // //浠ョ鐞嗗憳鐨勮韩浠借闂紝鑷韩鏄垚鍛� - // fullUrl = $"{Common.Config.Instance.AdminRequestBaseUrl}/{"App/GetHomeDataBackupUploadListPagger"}"; - //} + //鑾峰彇鎺ュ彛鐨勮繛鎺ユā寮� + string fullUrl = string.Empty; + var connectMode = UserCenterLogic.GetHttpConnectMode(true); + if (connectMode == HttpConnectMode.Normal) + { + //鏅�氳闂� + fullUrl = $"{Common.CommonPage.RequestHttpsHost}/{"App/GetHomeDataBackupUploadListPagger"}"; + } + else if (connectMode == HttpConnectMode.Admin) + { + //浠ョ鐞嗗憳鐨勮韩浠借闂紝鑷韩鏄垚鍛� + fullUrl = $"{Common.Config.Instance.AdminRequestBaseUrl}/{"App/GetHomeDataBackupUploadListPagger"}"; + } - //var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 6202 } }; - //var data = new Newtonsoft.Json.Linq.JObject { - // { "url", fullUrl }, { "RequestVersion", Common.CommonPage.RequestVersion }, - // { "LoginAccessToken", HdlUserCenterLogic.GetConnectMainToken() }, { "IsGatewayAutoBackup", isAutoBack }, - // { "BackupClassId", backupClassId },{ "GatewayUniqueId",realGateway.GwId}, - // { "IsOtherAccountCtrl",connectMode == HttpConnectMode.Admin?1:0} - //}; - //jObject.Add("Data", data); - //realGateway.Send("GetDataFileList", jObject.ToString()); + var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 6202 } }; + var data = new Newtonsoft.Json.Linq.JObject { + { "url", fullUrl }, { "RequestVersion", Common.CommonPage.RequestVersion }, + { "LoginAccessToken", UserCenterLogic.GetConnectMainToken() }, { "IsGatewayAutoBackup", isAutoBack }, + { "BackupClassId", backupClassId },{ "GatewayUniqueId",realGateway.GwId}, + { "IsOtherAccountCtrl",connectMode == HttpConnectMode.Admin?1:0} + }; + jObject.Add("Data", data); + realGateway.Send("GetDataFileList", jObject.ToString()); int timeOut = 0; while (result == -1 && timeOut < 30) @@ -468,7 +475,7 @@ { //姝e湪涓嬭浇澶囦唤鏂囦欢 ProgressFormBar.Current.SetMsg(Language.StringByID(R.MyInternationalizationString.uBackupFileDownloading)); - ProgressFormBar.Current.SetValue(0); + ProgressFormBar.Current.ResetProgressBar(); System.Threading.Thread.Sleep(1000); bool threadAction = true; @@ -501,36 +508,36 @@ timeOut = 0; //璁剧疆杩涘害鐧惧垎姣� var persent = Convert.ToInt32(jobject["Data"]["RestoreDataPercent"].ToString()); - ProgressFormBar.Current.SetValue(persent, 100); + //缃戝叧涓嬭浇瀹屾垚涔嬪悗锛屽畠鑷繁浼氬崱涓�浼氾紝鎵嶄細鍙戦��2杩囨潵 + ProgressFormBar.Current.SetValue(persent - 1, 100); } } }; realGateway.Actions += action; - //鈽嗐優銉笺偗鈽� - ////鑾峰彇鎺ュ彛鐨勮繛鎺ユā寮� - //string fullUrl = string.Empty; - //var connectMode = HdlUserCenterLogic.GetHttpConnectMode(true); - //if (connectMode == HttpConnectMode.Normal) - //{ - // //鏅�氳闂� - // fullUrl = $"{Common.CommonPage.RequestHttpsHost}/{"App/DownloadSomeDataBackup"}"; - //} - //else if (connectMode == HttpConnectMode.Admin) - //{ - // //浠ョ鐞嗗憳鐨勮韩浠借闂紝鑷韩鏄垚鍛� - // fullUrl = $"{Common.Config.Instance.AdminRequestBaseUrl}/{"App/DownloadSomeDataBackup"}"; - //} + //鑾峰彇鎺ュ彛鐨勮繛鎺ユā寮� + string fullUrl = string.Empty; + var connectMode = UserCenterLogic.GetHttpConnectMode(true); + if (connectMode == HttpConnectMode.Normal) + { + //鏅�氳闂� + fullUrl = $"{Common.CommonPage.RequestHttpsHost}/{"App/DownloadSomeDataBackup"}"; + } + else if (connectMode == HttpConnectMode.Admin) + { + //浠ョ鐞嗗憳鐨勮韩浠借闂紝鑷韩鏄垚鍛� + fullUrl = $"{Common.Config.Instance.AdminRequestBaseUrl}/{"App/DownloadSomeDataBackup"}"; + } - //var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 6203 } }; - //var data = new Newtonsoft.Json.Linq.JObject { - // { "url", fullUrl }, { "RequestVersion", Common.CommonPage.RequestVersion }, - // { "LoginAccessToken", HdlUserCenterLogic.GetConnectMainToken() }, { "IsGatewayAutoBackup", isAutoBack }, - // { "BackupClassId", backupClassId },{ "GatewayUniqueId",realGateway.GwId}, - // { "IsOtherAccountCtrl",connectMode == HttpConnectMode.Admin?1:0} - //}; - //jObject.Add("Data", data); - //realGateway.Send("GetDataFileList", jObject.ToString()); + var jObject = new Newtonsoft.Json.Linq.JObject { { "Cluster_ID", 0 }, { "Command", 6203 } }; + var data = new Newtonsoft.Json.Linq.JObject { + { "url", fullUrl }, { "RequestVersion", Common.CommonPage.RequestVersion }, + { "LoginAccessToken", UserCenterLogic.GetConnectMainToken() }, { "IsGatewayAutoBackup", isAutoBack }, + { "BackupClassId", backupClassId },{ "GatewayUniqueId",realGateway.GwId}, + { "IsOtherAccountCtrl",connectMode == HttpConnectMode.Admin?1:0} + }; + jObject.Add("Data", data); + realGateway.Send("GetDataFileList", jObject.ToString()); while (threadAction == true && timeOut < 30) { @@ -618,7 +625,7 @@ { //姝e湪閲嶅惎缃戝叧绯荤粺 ProgressFormBar.Current.SetMsg(Language.StringByID(R.MyInternationalizationString.uGatewayRerooting)); - ProgressFormBar.Current.SetValue(0); + ProgressFormBar.Current.ResetProgressBar(); System.Threading.Thread.Sleep(1000); int result = -1; @@ -649,56 +656,41 @@ string msg = Language.StringByID(R.MyInternationalizationString.uGatewayRerootFail); if (result == -1) { - msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂"); + msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, null, "鍥炲瓒呮椂"); } this.ShowErrorMsg(msg); return false; } //缃戝叧宸茬粡鎺ユ敹鍒伴噸鍚懡浠�,鎺ヤ笅鏉ュ幓鍒ゆ柇缃戝叧鏄惁閲嶅惎瀹屾垚 - bool gatewatAction = false; - bool threadAction = true; - HdlThreadLogic.Current.RunThread(() => + timeOut = 0; + while (true) { - timeOut = 0; - while (gatewatAction == false) + //澶ф缃戝叧閲嶅惎瑕�60绉� + if (timeOut >= 65 && timeOut % 5 == 0) { - //澶ф缃戝叧閲嶅惎瑕�60绉� - if (timeOut >= 65 && timeOut % 5 == 0) + //5绉掍竴娆�,鍘昏幏鍙栫増鏈� + var data = HdlGatewayLogic.Current.GetGatewayInfo(realGateway, false, ShowErrorMode.NO); + if (data != null) { - //5绉掍竴娆�,鍘昏幏鍙栫増鏈� - var data = HdlGatewayLogic.Current.GetGatewayInfo(realGateway, false, ShowErrorMode.NO); - if (data != null) - { - gatewatAction = true; - threadAction = false; - break; - } - } - System.Threading.Thread.Sleep(1000); - timeOut++; - //璁剧疆杩涘害鍊� - ProgressFormBar.Current.SetValue(timeOut, 180); - if (timeOut >= 180) - { - //180绉掕繕绛変笉鍒扮殑璇濓紝缃戝叧搴旇鍑洪棶棰樹簡 - threadAction = false; break; } } - }); - while (threadAction == true) - { - System.Threading.Thread.Sleep(4000); + System.Threading.Thread.Sleep(1000); + timeOut++; + //璁剧疆杩涘害鍊� + ProgressFormBar.Current.SetValue(timeOut, 180); + if (timeOut >= 180) + { + //180绉掕繕绛変笉鍒扮殑璇濓紝缃戝叧搴旇鍑洪棶棰樹簡 + break; + } } - if (gatewatAction == true) + if (timeOut < 180) { //璁剧疆杩涘害鍊�:100% ProgressFormBar.Current.SetValue(1, 1); System.Threading.Thread.Sleep(1000); - //缃戝叧鏁版嵁鎭㈠鎴愬姛! - string msg = Language.StringByID(R.MyInternationalizationString.uRestoreGatewayDataSuccess); - this.ShowTipMsg(msg); return true; } else -- Gitblit v1.8.0