| | |
| | | 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 = GetBackFileIDFromDB(BackupClassId, IsGatewayAutoBackup, ZigbeeUniqueId);
|
| | |
| | | return null;
|
| | | }
|
| | | //将输入写入本地的临时文件夹
|
| | | Global.WriteFileToDirectoryByBytes(newDir, fileName, result);
|
| | | HdlFileLogic.Current.SaveTextToFile(System.IO.Path.Combine(newDir, fileName), System.Text.Encoding.UTF8.GetString(result));
|
| | | //设置进度值
|
| | | ProgressFormBar.Current.SetValue(i + 1, listFileCount);
|
| | | }
|
| | |
| | | {
|
| | | //获取本地文件
|
| | | listAllFile = Global.FileListByHomeId();
|
| | | fullDir = UserCenterLogic.CombinePath();
|
| | | 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 (fileName.EndsWith(".png") == true
|
| | | || fileName.EndsWith(".bin") == true)
|
| | | {
|
| | | //图片文件
|
| | | listPicFile.Add(fileName);
|
| | |
| | | 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);
|
| | |
| | | /// <returns></returns>
|
| | | 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;
|
| | |
| | | {
|
| | | try
|
| | | {
|
| | | var listAllFile = HdlAutoBackupLogic.GetFileFromDirectory(upPath);
|
| | | var listAllFile = HdlFileLogic.Current.GetFileFromDirectory(upPath);
|
| | | if (listAllFile.Count > 10)
|
| | | {
|
| | | listAllFile.Sort();
|
| | |
| | | });
|
| | |
|
| | | 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
|
| | |
| | | ProgressFormBar.Current.Close();
|
| | |
|
| | | //如果读取到的文件完全没有问题,则清理本地的文件
|
| | | UserCenterLogic.DeleteAllLocationFile(false);
|
| | | HdlFileLogic.Current.DeleteAllLocationFile(false);
|
| | |
|
| | | //没有错误的话,则移动到当前住宅文件夹下面
|
| | | Global.MoveDirectoryFileToHomeDirectory(tempDirectory, true);
|
| | | HdlFileLogic.Current.MoveDirectoryFileToHomeDirectory(tempDirectory, true);
|
| | |
|
| | | //删除全部的自动备份的本地文件(此函数用于读取自动备份的时候使用)
|
| | | HdlAutoBackupLogic.DeleteAllAutoBackupFile();
|