| | |
| | | using System.IO;
|
| | | using System.Net;
|
| | | using System.Text;
|
| | | using System.Threading.Tasks;
|
| | |
|
| | | namespace Shared.Phone.UserCenter
|
| | | {
|
| | |
| | | /// <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();
|
| | |
| | | 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;
|
| | |
| | | /// <param name="IsGatewayAutoBackup">当前获取是否为网关自动备份</param>
|
| | | /// <param name="ZigbeeUniqueId">ZigbeeUniqueId 网关的唯一Id(当IsGatewayBackup=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);
|
| | | string newDir = DirNameResourse.DownLoadBackupTempDirectory;
|
| | | HdlFileLogic.Current.CreateDirectory(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;
|
| | | }
|
| | |
|
| | |
| | | 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;
|
| | | }
|
| | | //将输入写入本地的临时文件夹
|
| | | Global.WriteFileToDirectoryByBytes(newDir, fileName, result);
|
| | | HdlFileLogic.Current.SaveByteToFile(System.IO.Path.Combine(newDir, fileName), result);
|
| | | //设置进度值
|
| | | ProgressFormBar.Current.SetValue(i + 1, listFileCount);
|
| | | }
|
| | | //关闭进度条
|
| | | ProgressFormBar.Current.Close();
|
| | |
|
| | | //允许按系统的返回键
|
| | | Shared.Common.CommonPage.BackKeyCanClick = true;
|
| | | UserCenterResourse.Option.AppCanSignout = true;
|
| | | UserCenterResourse.AccountOption.AppCanSignout = true;
|
| | |
|
| | | return newDir;
|
| | | }
|
| | |
| | | /// <param name="IsGatewayAutoBackup">当前获取是否为网关自动备份</param>
|
| | | /// <param name="ZigbeeUniqueId">ZigbeeUniqueId 网关的唯一Id(当IsGatewayBackup=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;
|
| | |
| | | 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;
|
| | | }
|
| | |
| | | /// <param name="ManualBackupType">手动备份类型(0:App手动备份,2:网关手动备份)</param>
|
| | | /// <param name="ZigbeeUniqueId">网关的唯一Id,当ManualBackupType=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;
|
| | |
| | | //获取控制主人账号的Token
|
| | | 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;
|
| | | }
|
| | |
| | | /// <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;
|
| | | //文件夹的全路径
|
| | | string fullDir = string.Empty;
|
| | | string localTemplateName = string.Empty;
|
| | | if (upPath == string.Empty)
|
| | | {
|
| | | //将模板数据保存到到指定的文件夹中
|
| | | var templateName = TemplateData.TemplateCommonLogic.Current.GetNewTemplateFileName();
|
| | | var templateFile = TemplateData.TemplateCommonLogic.Current.SaveTemplateDataToFile(templateName, "HomeTemplate");
|
| | |
|
| | | //将模板bin文件移动到备份文件夹中
|
| | | localTemplateName = System.IO.Path.Combine(Config.Instance.FullPath, templateName);
|
| | | try { System.IO.File.Move(templateFile, localTemplateName); }
|
| | | catch (Exception ex) { HdlLogLogic.Current.WriteLog(ex, "移动模板失败"); }
|
| | |
|
| | | //获取本地文件
|
| | | listAllFile = Global.FileListByHomeId();
|
| | | fullDir = UserCenterLogic.CombinePath();
|
| | | listAllFile = HdlFileLogic.Current.GetRootPathListFile();
|
| | | fullDir = Common.Config.Instance.FullPath;
|
| | | }
|
| | | else
|
| | | {
|
| | | listAllFile = HdlAutoBackupLogic.GetFileFromDirectory(upPath);
|
| | | listAllFile = HdlFileLogic.Current.GetFileFromDirectory(upPath);
|
| | | fullDir = upPath;
|
| | | }
|
| | | if (listAllFile.Count == 0)
|
| | |
| | |
|
| | | foreach (string fileName in listAllFile)
|
| | | {
|
| | | if (fileName.EndsWith(".png") == true)
|
| | | //判断指定文件是否需要上传(根目录的才判断)
|
| | | if (upPath == string.Empty && this.IsNotUpLoadFile(fileName) == true)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | if (fileName.EndsWith(".png") == true
|
| | | || fileName.EndsWith(".bin") == true)
|
| | | {
|
| | | //图片文件
|
| | | listPicFile.Add(fileName);
|
| | |
| | | }
|
| | |
|
| | | //开启进度条
|
| | | int listFileCount = listAllFile.Count;
|
| | | int listFileCount = listPicFile.Count + listNormalFile.Count;
|
| | | if (showBar == true)
|
| | | {
|
| | | //开启进度条 正在上传备份文件
|
| | |
| | |
|
| | | //不允许按系统的返回键
|
| | | Shared.Common.CommonPage.BackKeyCanClick = false;
|
| | | UserCenterResourse.Option.AppCanSignout = false;
|
| | | UserCenterResourse.AccountOption.AppCanSignout = false;
|
| | |
|
| | | //你说为什么这里不分一个函数出来(理论上是分函数出来的)
|
| | | //是因为如果分函数的话,会出现双重异步,导致主线程的进度条的百分比永远定死0%
|
| | |
| | | ProgressFormBar.Current.Close();
|
| | | //允许按系统的返回键
|
| | | Shared.Common.CommonPage.BackKeyCanClick = true;
|
| | | UserCenterResourse.Option.AppCanSignout = true;
|
| | | UserCenterResourse.AccountOption.AppCanSignout = true;
|
| | | if (localTemplateName != string.Empty)
|
| | | {
|
| | | //删除掉这个模板文件
|
| | | HdlFileLogic.Current.DeleteFile(localTemplateName);
|
| | | }
|
| | | return false;
|
| | | }
|
| | | //判断是否是应该上传的文件
|
| | | if (IsNotUpLoadFile(file) == true && upPath == string.Empty)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | //整理数据
|
| | | var datainfo = new FileInfoData();
|
| | | datainfo.BackupFileName = file;
|
| | | string fullFileName = System.IO.Path.Combine(fullDir, file);
|
| | | datainfo.BackupFileContent = Shared.IO.FileUtils.ReadFile(fullFileName);
|
| | | datainfo.BackupFileContent = HdlFileLogic.Current.ReadFileByteContent(fullFileName);
|
| | |
|
| | | var list = new List<FileInfoData>();
|
| | | 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;
|
| | | if (localTemplateName != string.Empty)
|
| | | {
|
| | | //删除掉这个模板文件
|
| | | HdlFileLogic.Current.DeleteFile(localTemplateName);
|
| | | }
|
| | | return false;
|
| | | }
|
| | | //设置进度值
|
| | |
| | | ProgressFormBar.Current.Close();
|
| | | //允许按系统的返回键
|
| | | Shared.Common.CommonPage.BackKeyCanClick = true;
|
| | | UserCenterResourse.Option.AppCanSignout = true;
|
| | | UserCenterResourse.AccountOption.AppCanSignout = true;
|
| | | if (localTemplateName != string.Empty)
|
| | | {
|
| | | //删除掉这个模板文件
|
| | | HdlFileLogic.Current.DeleteFile(localTemplateName);
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | |
| | | ProgressFormBar.Current.Close();
|
| | | //允许按系统的返回键
|
| | | Shared.Common.CommonPage.BackKeyCanClick = true;
|
| | | UserCenterResourse.Option.AppCanSignout = true;
|
| | | UserCenterResourse.AccountOption.AppCanSignout = true;
|
| | | if (localTemplateName != string.Empty)
|
| | | {
|
| | | //删除掉这个模板文件
|
| | | HdlFileLogic.Current.DeleteFile(localTemplateName);
|
| | | }
|
| | | return false;
|
| | | }
|
| | | //设置进度值
|
| | | ProgressFormBar.Current.SetValue(i + 1 + listNormalFile.Count, listFileCount);
|
| | | }
|
| | |
|
| | | if (localTemplateName != string.Empty)
|
| | | {
|
| | | //删除掉这个模板文件
|
| | | HdlFileLogic.Current.DeleteFile(localTemplateName);
|
| | | }
|
| | |
|
| | | //进度条关闭
|
| | | ProgressFormBar.Current.Close();
|
| | | //允许按系统的返回键
|
| | | Shared.Common.CommonPage.BackKeyCanClick = true;
|
| | | UserCenterResourse.Option.AppCanSignout = true;
|
| | | UserCenterResourse.AccountOption.AppCanSignout = true;
|
| | |
|
| | | return true;
|
| | | }
|
| | |
| | | /// <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;
|
| | |
| | | //获取控制主人账号的Token
|
| | | 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;
|
| | |
| | | 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)
|
| | |
| | | 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}";
|
| | | }
|
| | |
| | | /// 上传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)
|
| | | string upPath = DirNameResourse.LogDirectory;
|
| | | if (HdlFileLogic.Current.GetFileFromDirectory(upPath).Count == 0)
|
| | | {
|
| | | //没有Log文件
|
| | | return true;
|
| | |
| | | ProgressFormBar.Current.SetMsg("正在上传Log文件");
|
| | |
|
| | | //从云端获取数据
|
| | | var pageData = await HdlBackupLogic.Current.GetBackupListNameFromDB(0, null, true);
|
| | | var pageData = HdlBackupLogic.Current.GetBackupListNameFromDB(0, null, true);
|
| | | if (pageData == null)
|
| | | {
|
| | | ProgressFormBar.Current.Close();
|
| | |
| | | if (backId == string.Empty)
|
| | | {
|
| | | //创建新的备份
|
| | | backId = await HdlBackupLogic.Current.CreatNewBackupNameToDB(DirNameResourse.OptionBackupName);
|
| | | backId = HdlBackupLogic.Current.CreatNewBackupNameToDB(DirNameResourse.OptionBackupName);
|
| | | if (backId == null)
|
| | | {
|
| | | ProgressFormBar.Current.Close();
|
| | |
| | | }
|
| | | }
|
| | | //上传Log文件
|
| | | bool result = await this.UpLoadBackupFileToDB(backId, 0, upPath, false);
|
| | | bool result = this.UpLoadBackupFileToDB(backId, 0, upPath, false);
|
| | | if (result == true)
|
| | | {
|
| | | try
|
| | | {
|
| | | //删除本地全部Log
|
| | | Global.CreateEmptyDirectory(Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.LogDirectory), true);
|
| | | var listAllFile = HdlFileLogic.Current.GetFileFromDirectory(upPath);
|
| | | if (listAllFile.Count > 10)
|
| | | {
|
| | | listAllFile.Sort();
|
| | | while (listAllFile.Count >= 10)
|
| | | {
|
| | | System.IO.File.Delete(listAllFile[0]);
|
| | | listAllFile.RemoveAt(0);
|
| | | }
|
| | | }
|
| | | }
|
| | | catch { }
|
| | | }
|
| | | ProgressFormBar.Current.Close();
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | var contr = new ShowMsgControl(ShowMsgType.Tip, "Log上传成功");
|
| | | contr.Show();
|
| | | });
|
| | |
|
| | | return result;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 上传东西到隐匿功能备份
|
| | | /// </summary>
|
| | | /// <param name="fileName"></param>
|
| | | /// <param name="byteData"></param>
|
| | | /// <returns></returns>
|
| | | public bool UpLoadByteDataToOptionBackup(string fileName, byte[] byteData)
|
| | | {
|
| | | ProgressFormBar.Current.Start();
|
| | | ProgressFormBar.Current.SetMsg("正在上传文件");
|
| | |
|
| | | //从云端获取数据
|
| | | var pageData = HdlBackupLogic.Current.GetBackupListNameFromDB(0, null, true);
|
| | | if (pageData == null)
|
| | | {
|
| | | ProgressFormBar.Current.Close();
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | var contr = new ShowMsgControl(ShowMsgType.Tip, "获取功能备份失败");
|
| | | contr.Show();
|
| | | });
|
| | | return false;
|
| | | }
|
| | | string backId = string.Empty;
|
| | | for (int i = 0; i < pageData.Count; i++)
|
| | | {
|
| | | if (pageData[i].BackupName == DirNameResourse.OptionBackupName)
|
| | | {
|
| | | //获取功能备份的ID
|
| | | backId = pageData[i].Id;
|
| | | break;
|
| | | }
|
| | | }
|
| | | if (backId == string.Empty)
|
| | | {
|
| | | //创建新的备份
|
| | | backId = this.CreatNewBackupNameToDB(DirNameResourse.OptionBackupName);
|
| | | if (backId == null)
|
| | | {
|
| | | ProgressFormBar.Current.Close();
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | var contr = new ShowMsgControl(ShowMsgType.Tip, "创建功能备份失败");
|
| | | contr.Show();
|
| | | });
|
| | | return false;
|
| | | }
|
| | | }
|
| | | //上传Log文件
|
| | | var datainfo = new FileInfoData();
|
| | | datainfo.BackupFileName = fileName;
|
| | | datainfo.BackupFileContent = byteData;
|
| | |
|
| | | var list = new List<FileInfoData>();
|
| | | list.Add(datainfo);
|
| | |
|
| | | //执行上传
|
| | | bool falge = DoUpLoadInfoToDB(backId, list, 0);
|
| | | //关闭进度条
|
| | | ProgressFormBar.Current.Close();
|
| | |
|
| | | if (falge == false)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | var contr = new ShowMsgControl(ShowMsgType.Tip, "文件上传成功");
|
| | | contr.Show();
|
| | | });
|
| | | return false;
|
| | | }
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | var contr = new ShowMsgControl(ShowMsgType.Tip, "文件上传成功");
|
| | | contr.Show();
|
| | | });
|
| | |
|
| | | return true;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | /// 读取隐匿功能配置(不要在意返回值)
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | public async Task<bool> LoadHideOption()
|
| | | public bool LoadHideOption()
|
| | | {
|
| | | //先初始化
|
| | | UserCenterResourse.HideOption = new HideOptionInfo();
|
| | |
| | | //无视错误
|
| | | IMessageCommon.Current.IgnoreError = true;
|
| | | //从云端获取数据
|
| | | var pageData = await this.GetBackupListNameFromDB(0, null, true);
|
| | | var pageData = this.GetBackupListNameFromDB(0, null, true);
|
| | | if (pageData == null)
|
| | | {
|
| | | //恢复
|
| | |
| | | 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;
|
| | | }
|
| | |
|
| | | //检测
|
| | |
| | | //出力详细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;
|
| | | }
|
| | | checkKeys = UserCenterLogic.EncryptPassword(UserCenterResourse.FileEncryptKey, DirNameResourse.StartDebugAppFile + UserCenterResourse.UserInfo.Account);
|
| | | if (listFile.Contains(checkKeys) == true)
|
| | | {
|
| | | //开启后台调试App功能(Debug用)
|
| | | UserCenterResourse.HideOption.StartDebugApp = 1;
|
| | | }
|
| | | checkKeys = UserCenterLogic.EncryptPassword(UserCenterResourse.FileEncryptKey, DirNameResourse.CheckDeviceTypeFile + UserCenterResourse.UserInfo.Account);
|
| | | if (listFile.Contains(checkKeys) == true)
|
| | | {
|
| | | //开启检测设备Type的(Debug用)
|
| | | UserCenterResourse.HideOption.CheckDeviceType = 1;
|
| | | }
|
| | |
|
| | | //恢复
|
| | | IMessageCommon.Current.IgnoreError = false;
|
| | |
| | | /// 读取APP备份文档(函数内部有进度条)
|
| | | /// </summary>
|
| | | /// <param name="BackupClassId"></param>
|
| | | public async Task<bool> LoadAppBackupInfo(string BackupClassId)
|
| | | public bool LoadAppBackupInfo(string BackupClassId)
|
| | | {
|
| | | //打开进度条 正在获取备份文件列表
|
| | | ProgressFormBar.Current.Start();
|
| | | ProgressFormBar.Current.SetMsg(Language.StringByID(R.MyInternationalizationString.uBackupFileListGetting));
|
| | |
|
| | | //从云端获取备份的文件,然后存入本地的临时文件夹
|
| | | string tempDirectory = await GetBackFileFromDBAndSetToLocation(BackupClassId);
|
| | | string tempDirectory = GetBackFileFromDBAndSetToLocation(BackupClassId);
|
| | | if (tempDirectory == null)
|
| | | {
|
| | | //关闭进度条
|
| | | ProgressFormBar.Current.Close();
|
| | | return false;
|
| | | }
|
| | | //关闭进度条
|
| | | ProgressFormBar.Current.Close();
|
| | |
|
| | | //清空全部房间
|
| | | HdlRoomLogic.Current.DeleteAllRoom();
|
| | | //清空本地全部的场景数据
|
| | | HdlSceneLogic.Current.DeleteAllLocalScene();
|
| | | //如果读取到的文件完全没有问题,则清理本地的文件
|
| | | UserCenterLogic.DeleteAllLocationFile(false);
|
| | | HdlFileLogic.Current.DeleteAllLocationFile(false);
|
| | |
|
| | | //清理本地的模板文件
|
| | | TemplateData.TemplateCommonLogic.Current.DeleteAllLocalFile();
|
| | |
|
| | | //没有错误的话,则移动到当前住宅文件夹下面
|
| | | Global.MoveDirectoryFileToHomeDirectory(tempDirectory, true);
|
| | | HdlFileLogic.Current.MoveDirectoryFileToHomeDirectory(tempDirectory, true);
|
| | |
|
| | | //删除全部的自动备份的本地文件(此函数用于读取自动备份的时候使用)
|
| | | HdlAutoBackupLogic.DeleteAllAutoBackupFile();
|
| | |
|
| | | //刷新本地缓存
|
| | | UserCenterLogic.RefreshAllMemory();
|
| | |
|
| | | //关闭进度条
|
| | | ProgressFormBar.Current.Close();
|
| | |
|
| | | return true;
|
| | | }
|
| | |
| | | /// </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;
|
| | | //获取控制主人账号的Token
|
| | | Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
|
| | |
|
| | | bool success = await UserCenterLogic.GetResultStatuByRequestHttps("App/DelHomeAppGatewayName", true, Pra);
|
| | | bool success = UserCenterLogic.GetResultStatuByRequestHttps("App/DelHomeAppGatewayName", true, Pra);
|
| | |
|
| | | return success;
|
| | | }
|
| | |
| | | /// </summary>
|
| | | /// <param name="file"></param>
|
| | | /// <returns></returns>
|
| | | public bool IsNotUpLoadFile(string file)
|
| | | private bool IsNotUpLoadFile(string file)
|
| | | {
|
| | | if (file == "Config.json")
|
| | | if (file.StartsWith("Device_") == true
|
| | | || file.StartsWith("Gateway_") == true
|
| | | || file.StartsWith("Room_") == true
|
| | | || file.StartsWith("Scene_") == true)
|
| | | {
|
| | | //不能覆盖Config文件
|
| | | //设备,网关,房间,场景文件不需要上传,它已经保存在bin模板文件中
|
| | | return true;
|
| | | }
|
| | | return false;
|