From f23ad1b3f9f6193f35f72104d690b21dc67d5c1f Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期一, 06 七月 2020 12:35:25 +0800 Subject: [PATCH] 去掉了访问外网的异步 --- ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs | 101 +++++++++++++++++++++++++++----------------------- 1 files changed, 54 insertions(+), 47 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs index 0788c92..b966e9a 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs @@ -5,7 +5,6 @@ using System.IO; using System.Net; using System.Text; -using System.Threading.Tasks; namespace Shared.Phone.UserCenter { @@ -46,7 +45,7 @@ /// <param name="ZigbeeUniqueId">缃戝叧鐨勫敮涓�Id,鑾峰彇缃戝叧澶囦唤闇�瑕�</param> /// <param name="getOptionBackup">鏄惁鑾峰彇鍔熻兘澶囦唤</param> /// <returns></returns> - public async Task<List<BackupListNameInfo>> GetBackupListNameFromDB(int ZigbeeBackupType = 0, string ZigbeeUniqueId = null, bool getOptionBackup = false) + public List<BackupListNameInfo> GetBackupListNameFromDB(int ZigbeeBackupType = 0, string ZigbeeUniqueId = null, bool getOptionBackup = false) { //澶囦唤鍚嶅瓧寰堝皯鐨勫唴瀛橈紝鍙互鐩存帴涓�娆℃�у叏閮ㄥ彇瀹� var pra = new GetBackupListPra(); @@ -58,8 +57,7 @@ pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); //璁块棶鎺ュ彛 - var listNotShow = new List<string>() { "NotSetAgain" }; - string result = await UserCenterLogic.GetResponseDataByRequestHttps("App/GetHomeDataBackupPagger", true, pra, listNotShow); + string result = UserCenterLogic.GetResponseDataByRequestHttps("App/GetHomeDataBackupPagger", true, pra); if (string.IsNullOrEmpty(result) == true) { return null; @@ -91,25 +89,25 @@ /// <param name="IsGatewayAutoBackup">褰撳墠鑾峰彇鏄惁涓虹綉鍏宠嚜鍔ㄥ浠�</param> /// <param name="ZigbeeUniqueId">ZigbeeUniqueId 缃戝叧鐨勫敮涓�Id(褰揑sGatewayBackup=true鏃讹紝姝ゅ弬鏁板繀椤绘彁渚�</param> /// <returns></returns> - public async Task<string> GetBackFileFromDBAndSetToLocation(string BackupClassId, bool IsGatewayAutoBackup = false, string ZigbeeUniqueId = null) + public string GetBackFileFromDBAndSetToLocation(string BackupClassId, bool IsGatewayAutoBackup = false, string ZigbeeUniqueId = null) { //涓嶅厑璁告寜绯荤粺鐨勮繑鍥為敭 Shared.Common.CommonPage.BackKeyCanClick = false; - UserCenterResourse.Option.AppCanSignout = false; + UserCenterResourse.AccountOption.AppCanSignout = false; //棣栧厛鍏堝垱寤轰竴涓复鏃舵枃浠跺す,瀛樺湪鏂囦欢鍒欐竻绌� string newDir = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.DownLoadBackupTempDirectory); Global.CreateEmptyDirectory(newDir, true); //鑾峰彇杩欎釜澶囦唤涓嬮潰鏈夊灏戜釜鏂囦欢 - List<string> listFile = await GetBackFileIDFromDB(BackupClassId, IsGatewayAutoBackup, ZigbeeUniqueId); + List<string> listFile = GetBackFileIDFromDB(BackupClassId, IsGatewayAutoBackup, ZigbeeUniqueId); if (listFile == null) { //鍏抽棴杩涘害鏉� ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return null; } @@ -132,20 +130,20 @@ ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return null; } //鈽呰缃渶瑕佽幏鍙栫殑鏂囦欢鍚嶅瓧鈽� pra.BackupFileName = fileName; - var result = await UserCenterLogic.GetByteResponseDataByRequestHttps("App/DownloadSomeDataBackup", true, pra); + var result = UserCenterLogic.GetByteResponseDataByRequestHttps("App/DownloadSomeDataBackup", true, pra, null, true); if (result == null) { //鍏抽棴杩涘害鏉� ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return null; } //灏嗚緭鍏ュ啓鍏ユ湰鍦扮殑涓存椂鏂囦欢澶� @@ -157,7 +155,7 @@ ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return newDir; } @@ -169,7 +167,7 @@ /// <param name="IsGatewayAutoBackup">褰撳墠鑾峰彇鏄惁涓虹綉鍏宠嚜鍔ㄥ浠�</param> /// <param name="ZigbeeUniqueId">ZigbeeUniqueId 缃戝叧鐨勫敮涓�Id(褰揑sGatewayBackup=true鏃讹紝姝ゅ弬鏁板繀椤绘彁渚�</param> /// <returns></returns> - private async Task<List<string>> GetBackFileIDFromDB(string BackupClassId, bool IsGatewayAutoBackup, string ZigbeeUniqueId) + private List<string> GetBackFileIDFromDB(string BackupClassId, bool IsGatewayAutoBackup, string ZigbeeUniqueId) { var pra = new LoadBackInfoPra(); pra.BackupClassId = BackupClassId; @@ -181,8 +179,8 @@ pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); //棣栧厛鍏堣幏鍙栦簯绔湁浠�涔堟枃浠� - string result = await UserCenterLogic.GetResponseDataByRequestHttps("App/GetHomeDataBackupUploadListPagger", true, pra); - if (result == null) + string result = UserCenterLogic.GetResponseDataByRequestHttps("App/GetHomeDataBackupUploadListPagger", true, pra); + if (string.IsNullOrEmpty(result) == true) { return null; } @@ -208,7 +206,7 @@ /// <param name="ManualBackupType">鎵嬪姩澶囦唤绫诲瀷(0:App鎵嬪姩澶囦唤,2锛氱綉鍏虫墜鍔ㄥ浠�)</param> /// <param name="ZigbeeUniqueId">缃戝叧鐨勫敮涓�Id,褰揗anualBackupType=2鏃�,姝ゅ�间笉鑳戒负绌�!</param> /// <returns></returns> - public async Task<string> CreatNewBackupNameToDB(string backupName, int ManualBackupType = 0, string ZigbeeUniqueId = null) + public string CreatNewBackupNameToDB(string backupName, int ManualBackupType = 0, string ZigbeeUniqueId = null) { var pra = new AddBackUpNamePra(); pra.BackupName = backupName; @@ -217,8 +215,8 @@ //鑾峰彇鎺у埗涓讳汉璐﹀彿鐨凾oken pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); - var result = await UserCenterLogic.GetResponseDataByRequestHttps("App/AddHomeAppGatewayName", true, pra); - if (result == null) + var result = UserCenterLogic.GetResponseDataByRequestHttps("App/AddHomeAppGatewayName", true, pra); + if (string.IsNullOrEmpty(result) == true) { return null; } @@ -239,7 +237,7 @@ /// <param name="upPath">鎸囧畾涓婁紶鐨勬槸鍝釜鏂囦欢澶圭殑鏂囦欢(鍏ㄨ矾寰�),涓嶆寚瀹氭椂锛屼笂浼犵殑鏄湰鍦拌矾寰勪笅鐨勬枃浠�</param> /// <param name="showBar">鏄惁璁剧疆鏄剧ず杩涘害鏉�</param> /// <returns></returns> - public async Task<bool> UpLoadBackupFileToDB(string BackupClassId, int ManualBackupType = 0, string upPath = "", bool showBar = true) + public bool UpLoadBackupFileToDB(string BackupClassId, int ManualBackupType = 0, string upPath = "", bool showBar = true) { List<string> listAllFile = null; //鏂囦欢澶圭殑鍏ㄨ矾寰� @@ -287,7 +285,7 @@ //涓嶅厑璁告寜绯荤粺鐨勮繑鍥為敭 Shared.Common.CommonPage.BackKeyCanClick = false; - UserCenterResourse.Option.AppCanSignout = false; + UserCenterResourse.AccountOption.AppCanSignout = false; //浣犺涓轰粈涔堣繖閲屼笉鍒嗕竴涓嚱鏁板嚭鏉ワ紙鐞嗚涓婃槸鍒嗗嚱鏁板嚭鏉ョ殑锛� //鏄洜涓哄鏋滃垎鍑芥暟鐨勮瘽锛屼細鍑虹幇鍙岄噸寮傛锛屽鑷翠富绾跨▼鐨勮繘搴︽潯鐨勭櫨鍒嗘瘮姘歌繙瀹氭0% @@ -301,7 +299,7 @@ ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return false; } //鍒ゆ柇鏄惁鏄簲璇ヤ笂浼犵殑鏂囦欢 @@ -319,14 +317,14 @@ list.Add(datainfo); //鎵ц涓婁紶 - bool falge = await DoUpLoadInfoToDB(BackupClassId, list, ManualBackupType); + bool falge = DoUpLoadInfoToDB(BackupClassId, list, ManualBackupType); if (falge == false) { //鍏抽棴杩涘害鏉� ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return false; } //璁剧疆杩涘害鍊� @@ -343,7 +341,7 @@ ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return false; } @@ -358,7 +356,7 @@ ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return false; } //璁剧疆杩涘害鍊� @@ -369,7 +367,7 @@ ProgressFormBar.Current.Close(); //鍏佽鎸夌郴缁熺殑杩斿洖閿� Shared.Common.CommonPage.BackKeyCanClick = true; - UserCenterResourse.Option.AppCanSignout = true; + UserCenterResourse.AccountOption.AppCanSignout = true; return true; } @@ -381,7 +379,7 @@ /// <param name="listData">涓婁紶鐨勬暟鎹�</param> /// <param name="ManualBackupType">鎵嬪姩澶囦唤绫诲瀷(0:App鎵嬪姩澶囦唤,2锛氱綉鍏虫墜鍔ㄥ浠�)</param> /// <returns></returns> - private async Task<bool> DoUpLoadInfoToDB(string BackupClassId, List<FileInfoData> listData, int ManualBackupType = 0) + private bool DoUpLoadInfoToDB(string BackupClassId, List<FileInfoData> listData, int ManualBackupType = 0) { var upData = new UpLoadDataPra(); upData.ManualBackupType = ManualBackupType; @@ -390,7 +388,7 @@ //鑾峰彇鎺у埗涓讳汉璐﹀彿鐨凾oken upData.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); - bool falge = await UserCenterLogic.GetResultStatuByRequestHttps("App/UploadHomeAppGatewaySubFiles", true, upData); + bool falge = UserCenterLogic.GetResultStatuByRequestHttps("App/UploadHomeAppGatewaySubFiles", true, upData, null, true); if (falge == false) { return false; @@ -418,14 +416,11 @@ nvc.Add("HomeId", Shared.Common.Config.Instance.Home.Id); nvc.Add("BackupClassId", BackupClassId); nvc.Add("ManualBackupType", ManualBackupType.ToString()); - nvc.Add("IsOtherAccountCtrl", Common.Config.Instance.isAdministrator.ToString()); + nvc.Add("IsOtherAccountCtrl", Common.Config.Instance.Home.IsOthreShare.ToString()); - for (int i = 0; i < listPicFile.Count; i++) - { - string base64 = GetBase64Text(fullName); - nvc.Add("UploadSubFileLists[" + i + "].BackupFileName", fileName); - nvc.Add("UploadSubFileLists[" + i + "].BackupFileContent", base64); - } + string base64 = GetBase64Text(fullName); + nvc.Add("UploadSubFileLists[0].BackupFileName", fileName); + nvc.Add("UploadSubFileLists[0].BackupFileContent", base64); bool result = UpLoadBigBackupFileToDB("App/UploadHomeAppGatewaySubFiles", fullName, nvc); if (result == false) @@ -449,7 +444,7 @@ string contentType = "application/octet-stream"; string requestUrl = string.Empty; //鍚敤绠$悊鍛樻潈闄� - if (Config.Instance.isAdministrator == true) + if (Config.Instance.Home.IsOthreShare == true) { requestUrl = $"{Config.Instance.AdminRequestBaseUrl}/{RequestName}"; } @@ -532,7 +527,7 @@ /// 涓婁紶Log澶囦唤(闅愬尶鍔熻兘) /// </summary> /// <returns></returns> - public async Task<bool> UpLoadLogBackup() + public bool UpLoadLogBackup() { string upPath = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.LogDirectory); if (HdlAutoBackupLogic.GetFileFromDirectory(upPath).Count == 0) @@ -545,7 +540,7 @@ ProgressFormBar.Current.SetMsg("姝e湪涓婁紶Log鏂囦欢"); //浠庝簯绔幏鍙栨暟鎹� - var pageData = await HdlBackupLogic.Current.GetBackupListNameFromDB(0, null, true); + var pageData = HdlBackupLogic.Current.GetBackupListNameFromDB(0, null, true); if (pageData == null) { ProgressFormBar.Current.Close(); @@ -564,7 +559,7 @@ if (backId == string.Empty) { //鍒涘缓鏂扮殑澶囦唤 - backId = await HdlBackupLogic.Current.CreatNewBackupNameToDB(DirNameResourse.OptionBackupName); + backId = HdlBackupLogic.Current.CreatNewBackupNameToDB(DirNameResourse.OptionBackupName); if (backId == null) { ProgressFormBar.Current.Close(); @@ -572,7 +567,7 @@ } } //涓婁紶Log鏂囦欢 - bool result = await this.UpLoadBackupFileToDB(backId, 0, upPath, false); + bool result = this.UpLoadBackupFileToDB(backId, 0, upPath, false); if (result == true) { try @@ -609,7 +604,7 @@ /// 璇诲彇闅愬尶鍔熻兘閰嶇疆(涓嶈鍦ㄦ剰杩斿洖鍊�) /// </summary> /// <returns></returns> - public async Task<bool> LoadHideOption() + public bool LoadHideOption() { //鍏堝垵濮嬪寲 UserCenterResourse.HideOption = new HideOptionInfo(); @@ -621,7 +616,7 @@ //鏃犺閿欒 IMessageCommon.Current.IgnoreError = true; //浠庝簯绔幏鍙栨暟鎹� - var pageData = await this.GetBackupListNameFromDB(0, null, true); + var pageData = this.GetBackupListNameFromDB(0, null, true); if (pageData == null) { //鎭㈠ @@ -645,12 +640,18 @@ return true; } //鑾峰彇杩欎釜澶囦唤涓嬮潰鏈夊灏戜釜鏂囦欢 - List<string> listFile = await GetBackFileIDFromDB(backId, false, null); + List<string> listFile = GetBackFileIDFromDB(backId, false, null); if (listFile == null) { //鎭㈠ IMessageCommon.Current.IgnoreError = false; return false; + } + if (listFile.Count == 0) + { + //鎭㈠ + IMessageCommon.Current.IgnoreError = false; + return true; } //妫�娴� @@ -666,6 +667,12 @@ //鍑哄姏璇︾粏Log(Debug鐢�) UserCenterResourse.HideOption.DetailedLog = 1; } + checkKeys = UserCenterLogic.EncryptPassword(UserCenterResourse.FileEncryptKey, DirNameResourse.DeviceHistoryFile + UserCenterResourse.UserInfo.Account); + if (listFile.Contains(checkKeys) == true) + { + //鏄剧ず璁惧鍘嗗彶鐗堟湰(Debug鐢�) + UserCenterResourse.HideOption.DeviceHistory = 1; + } //鎭㈠ IMessageCommon.Current.IgnoreError = false; @@ -680,14 +687,14 @@ /// 璇诲彇APP澶囦唤鏂囨。(鍑芥暟鍐呴儴鏈夎繘搴︽潯) /// </summary> /// <param name="BackupClassId"></param> - public async Task<bool> LoadAppBackupInfo(string BackupClassId) + public bool LoadAppBackupInfo(string BackupClassId) { //鎵撳紑杩涘害鏉� 姝e湪鑾峰彇澶囦唤鏂囦欢鍒楄〃 ProgressFormBar.Current.Start(); ProgressFormBar.Current.SetMsg(Language.StringByID(R.MyInternationalizationString.uBackupFileListGetting)); //浠庝簯绔幏鍙栧浠界殑鏂囦欢锛岀劧鍚庡瓨鍏ユ湰鍦扮殑涓存椂鏂囦欢澶� - string tempDirectory = await GetBackFileFromDBAndSetToLocation(BackupClassId); + string tempDirectory = GetBackFileFromDBAndSetToLocation(BackupClassId); if (tempDirectory == null) { //鍏抽棴杩涘害鏉� @@ -721,14 +728,14 @@ /// </summary> /// <param name="BackupClassId">澶囦唤鐨勪富閿�</param> /// <returns></returns> - public async Task<bool> DeleteDbBackupData(string BackupClassId) + public bool DeleteDbBackupData(string BackupClassId) { var Pra = new LoadBackInfoPra(); Pra.BackupClassId = BackupClassId; //鑾峰彇鎺у埗涓讳汉璐﹀彿鐨凾oken Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken(); - bool success = await UserCenterLogic.GetResultStatuByRequestHttps("App/DelHomeAppGatewayName", true, Pra); + bool success = UserCenterLogic.GetResultStatuByRequestHttps("App/DelHomeAppGatewayName", true, Pra); return success; } -- Gitblit v1.8.0