| | |
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// Log备份的名字
|
| | | /// </summary>
|
| | | private string LogBackupName = "##Log##";
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 获取备份名字列表___________________
|
| | |
| | | /// </summary>
|
| | | /// <param name="ZigbeeBackupType">0:App手动备份 1: App 自动备份 2:网关手动备份 3:网关自动备份</param>
|
| | | /// <param name="ZigbeeUniqueId">网关的唯一Id,获取网关备份需要</param>
|
| | | /// <param name="getLogBackup">是否获取Log备份</param>
|
| | | /// <param name="getOptionBackup">是否获取功能备份</param>
|
| | | /// <returns></returns>
|
| | | public async Task<List<BackupListNameInfo>> GetBackupListNameFromDB(int ZigbeeBackupType = 0, string ZigbeeUniqueId = null, bool getLogBackup = false)
|
| | | public async Task<List<BackupListNameInfo>> GetBackupListNameFromDB(int ZigbeeBackupType = 0, string ZigbeeUniqueId = null, bool getOptionBackup = false)
|
| | | {
|
| | | //备份名字很少的内存,可以直接一次性全部取完
|
| | | var pra = new GetBackupListPra();
|
| | |
| | | {
|
| | | continue;
|
| | | }
|
| | | if (getLogBackup == false && data2.BackupName == LogBackupName)
|
| | | if (getOptionBackup == false && data2.BackupName == DirNameResourse.OptionBackupName)
|
| | | {
|
| | | //不获取Log备份
|
| | | //不获取功能备份
|
| | | continue;
|
| | | }
|
| | | list.Add(data2);
|
| | |
| | | ProgressFormBar.Current.SetValue(i + 1 + listNormalFile.Count, listFileCount);
|
| | | }
|
| | |
|
| | | //上传Log备份
|
| | | if (upPath != UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.LogDirectory))
|
| | | {
|
| | | //里面有个回调自身的方法,所以这里加个判断,不然会死循环
|
| | | await this.UpLoadLogBackup();
|
| | | }
|
| | |
|
| | | //进度条关闭
|
| | | ProgressFormBar.Current.Close();
|
| | | //允许按系统的返回键
|
| | |
| | | nvc.Add("ManualBackupType", ManualBackupType.ToString());
|
| | | nvc.Add("IsOtherAccountCtrl", Common.Config.Instance.isAdministrator.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)
|
| | |
| | | #region ■ 上传Log备份________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 上传Log备份
|
| | | /// 上传Log备份(隐匿功能)
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | private async Task<bool> UpLoadLogBackup()
|
| | | public async Task<bool> UpLoadLogBackup()
|
| | | {
|
| | | string upPath = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.LogDirectory);
|
| | | if (HdlAutoBackupLogic.GetFileFromDirectory(upPath).Count == 0)
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | ProgressFormBar.Current.Start();
|
| | | ProgressFormBar.Current.SetMsg("正在上传Log文件");
|
| | |
|
| | | //从云端获取数据
|
| | | var pageData = await HdlBackupLogic.Current.GetBackupListNameFromDB(0, null, true);
|
| | | if (pageData == null)
|
| | | {
|
| | | ProgressFormBar.Current.Close();
|
| | | 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 = await HdlBackupLogic.Current.CreatNewBackupNameToDB(DirNameResourse.OptionBackupName);
|
| | | if (backId == null)
|
| | | {
|
| | | ProgressFormBar.Current.Close();
|
| | | return false;
|
| | | }
|
| | | }
|
| | | //上传Log文件
|
| | | bool result = await this.UpLoadBackupFileToDB(backId, 0, upPath, false);
|
| | | if (result == true)
|
| | | {
|
| | | try
|
| | | {
|
| | | var listAllFile = HdlAutoBackupLogic.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;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 读取隐匿功能配置___________________
|
| | |
|
| | | /// <summary>
|
| | | /// 读取隐匿功能配置(不要在意返回值)
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | public async Task<bool> LoadHideOption()
|
| | | {
|
| | | //先初始化
|
| | | UserCenterResourse.HideOption = new HideOptionInfo();
|
| | | if (UserCenterResourse.UserInfo.AuthorityNo != 1 && UserCenterResourse.UserInfo.AuthorityNo != 2)
|
| | | {
|
| | | return true;
|
| | | }
|
| | |
|
| | | //无视错误
|
| | | IMessageCommon.Current.IgnoreError = true;
|
| | | //从云端获取数据
|
| | | var pageData = await HdlBackupLogic.Current.GetBackupListNameFromDB(0, null, true);
|
| | | var pageData = await this.GetBackupListNameFromDB(0, null, true);
|
| | | if (pageData == null)
|
| | | {
|
| | | //恢复
|
| | | IMessageCommon.Current.IgnoreError = false;
|
| | | return false;
|
| | | }
|
| | | string backId = string.Empty;
|
| | | for (int i = 0; i < pageData.Count; i++)
|
| | | {
|
| | | if (pageData[i].BackupName == LogBackupName)
|
| | | if (pageData[i].BackupName == DirNameResourse.OptionBackupName)
|
| | | {
|
| | | //删除掉这个备份
|
| | | bool flage = await this.DeleteDbBackupData(pageData[i].Id);
|
| | | if (flage == false)
|
| | | {
|
| | | //恢复
|
| | | IMessageCommon.Current.IgnoreError = false;
|
| | | return false;
|
| | | }
|
| | | //获取功能备份的ID
|
| | | backId = pageData[i].Id;
|
| | | break;
|
| | | }
|
| | | }
|
| | | //创建新的备份
|
| | | string backupClassId = await HdlBackupLogic.Current.CreatNewBackupNameToDB(LogBackupName);
|
| | | if (backupClassId == null)
|
| | | if (backId == string.Empty)
|
| | | {
|
| | | //没有功能配置
|
| | | IMessageCommon.Current.IgnoreError = false;
|
| | | return true;
|
| | | }
|
| | | //获取这个备份下面有多少个文件
|
| | | List<string> listFile = await GetBackFileIDFromDB(backId, false, null);
|
| | | if (listFile == null)
|
| | | {
|
| | | //恢复
|
| | | IMessageCommon.Current.IgnoreError = false;
|
| | | return false;
|
| | | }
|
| | | //上传Log文件
|
| | | bool result = await this.UpLoadBackupFileToDB(backupClassId, 0, upPath, false);
|
| | | if (result == true)
|
| | |
|
| | | //检测
|
| | | string checkKeys = UserCenterLogic.EncryptPassword(UserCenterResourse.FileEncryptKey, DirNameResourse.ShowOptionMenuFile + UserCenterResourse.UserInfo.Account);
|
| | | if (listFile.Contains(checkKeys) == true)
|
| | | {
|
| | | try
|
| | | {
|
| | | //删除本地全部Log
|
| | | Global.CreateEmptyDirectory(Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.LogDirectory), true);
|
| | | }
|
| | | catch { }
|
| | | //显示主页隐藏菜单(Debug用)
|
| | | UserCenterResourse.HideOption.CenterHideMenu = 1;
|
| | | }
|
| | | checkKeys = UserCenterLogic.EncryptPassword(UserCenterResourse.FileEncryptKey, DirNameResourse.DetailedLogFile + UserCenterResourse.UserInfo.Account);
|
| | | if (listFile.Contains(checkKeys) == true)
|
| | | {
|
| | | //出力详细Log(Debug用)
|
| | | UserCenterResourse.HideOption.DetailedLog = 1;
|
| | | }
|
| | |
|
| | | //恢复
|
| | | IMessageCommon.Current.IgnoreError = false;
|
| | |
|
| | | return result;
|
| | | return true;
|
| | | }
|
| | |
|
| | | #endregion
|