old mode 100755
new mode 100644
File was renamed from ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlAutoBackupLogic.cs |
| | |
| | | using System.Text;
|
| | | using System.Threading.Tasks;
|
| | |
|
| | | namespace Shared.Phone.UserCenter
|
| | | namespace Shared.Phone |
| | | {
|
| | | /// <summary>
|
| | | /// 自动备份的逻辑
|
| | |
| | | /// <returns></returns>
|
| | | private static bool UpLoadBackupFileToDB(List<string> listFile)
|
| | | {
|
| | | //获取app的自动备份 |
| | | var listBackData = HdlBackupLogic.Current.GetBackupListNameFromDB(BackUpMode.A自动备份); |
| | | if (listBackData == null) |
| | | { |
| | | return false; |
| | | } |
| | | string strBackId = string.Empty; |
| | | if (listBackData.Count == 0) |
| | | { |
| | | //创建一个新的备份 |
| | | strBackId = HdlBackupLogic.Current.CreatNewBackupNameToDB("AutoBackup", BackUpMode.A自动备份); |
| | | if (strBackId == null) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | //自动备份只有一个 |
| | | strBackId = listBackData[0].Id; |
| | | } |
| | | |
| | | string localPath = Config.Instance.FullPath;
|
| | |
|
| | | //将模板数据保存到到指定的文件夹中
|
| | |
| | | for (int i = 0; i < listUpFile.Count; i++)
|
| | | {
|
| | | string file = listUpFile[i];
|
| | | var datainfo = new FileInfoData();
|
| | | datainfo.BackupFileName = file;
|
| | | datainfo.BackupFileContent = HdlFileLogic.Current.ReadFileByteContent(System.IO.Path.Combine(localPath, file));
|
| | | if (datainfo.BackupFileContent == null)
|
| | | //读取文件内容 |
| | | var fileContent = HdlFileLogic.Current.ReadFileByteContent(System.IO.Path.Combine(localPath, file)); |
| | | if (fileContent == null) |
| | | {
|
| | | continue;
|
| | | }
|
| | |
|
| | | var upData = new UpLoadDataPra();
|
| | | upData.HomeId = Config.Instance.Home.Id;
|
| | | upData.UploadSubFileLists = new List<FileInfoData> { datainfo };
|
| | | //获取控制主人账号的Token
|
| | | upData.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
|
| | |
|
| | | //执行是上传
|
| | | bool falge = UserCenterLogic.GetResultStatuByRequestHttps("App/HomeAppAutoDataBackup", true, upData, null, true);
|
| | | //执行上传 |
| | | var falge = HdlBackupLogic.Current.DoUpLoadInfoToDB(strBackId, file, fileContent); |
| | | if (falge == false)
|
| | | {
|
| | | return false;
|
| | |
| | | HdlFileLogic.Current.DeleteFile(localTemplateName);
|
| | |
|
| | | //删除文件
|
| | | var backPath = DirNameResourse.AutoBackupDirectory;
|
| | | var backPath = HdlFileNameResourse.AutoBackupDirectory; |
| | | foreach (var file in listFile)
|
| | | {
|
| | | string fullName = System.IO.Path.Combine(backPath, file);
|
| | |
| | | }
|
| | |
|
| | | //获取app的自动备份
|
| | | var data = HdlBackupLogic.Current.GetBackupListNameFromDB(1);
|
| | | var data = HdlBackupLogic.Current.GetBackupListNameFromDB(BackUpMode.A自动备份); |
| | | if (data == null || data.Count == 0)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | //自动备份只有一个
|
| | | var autoBackupId = data[0].Id;
|
| | |
|
| | | var upData = new DeleteFilePra();
|
| | | upData.BackupClassId = autoBackupId;
|
| | | upData.HomeId = Config.Instance.Home.Id;
|
| | | upData.DeleteFileNameLists = listData;
|
| | | //获取控制主人账号的Token
|
| | | upData.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
|
| | |
|
| | | bool falge = UserCenterLogic.GetResultStatuByRequestHttps("App/DeleteAppBackupFile", true, upData);
|
| | | if (falge == false)
|
| | | var result = HdlBackupLogic.Current.DeleteDbBackupData(data[0].Id); |
| | | if (result == false) |
| | | {
|
| | | return false;
|
| | | }
|
| | |
|
| | | //删除文件
|
| | | var backPath = DirNameResourse.AutoBackupdeleteDirectory;
|
| | | var backPath = HdlFileNameResourse.AutoBackupdeleteDirectory; |
| | | foreach (var file in listData)
|
| | | {
|
| | | string fullName = System.IO.Path.Combine(backPath, file);
|
| | |
| | | /// <returns></returns>
|
| | | public static List<string> GetAutoBackupEditorFile()
|
| | | {
|
| | | return HdlFileLogic.Current.GetFileFromDirectory(DirNameResourse.AutoBackupDirectory);
|
| | | return HdlFileLogic.Current.GetFileFromDirectory(HdlFileNameResourse.AutoBackupDirectory); |
| | | }
|
| | |
|
| | | /// <summary>
|
| | |
| | | /// <returns></returns>
|
| | | public static List<string> GetAutoBackupDeleteFile()
|
| | | {
|
| | | return HdlFileLogic.Current.GetFileFromDirectory(DirNameResourse.AutoBackupdeleteDirectory);
|
| | | return HdlFileLogic.Current.GetFileFromDirectory(HdlFileNameResourse.AutoBackupdeleteDirectory); |
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | {
|
| | | fileName = System.IO.Path.GetFileName(fileName);
|
| | | //自动备份目录
|
| | | string strBackPath = DirNameResourse.AutoBackupDirectory;
|
| | | string strBackPath = HdlFileNameResourse.AutoBackupDirectory; |
| | | if (System.IO.Directory.Exists(strBackPath) == false)
|
| | | {
|
| | | //预创建个人中心全部的文件夹
|
| | |
| | | }
|
| | |
|
| | | //自动删除备份目录
|
| | | string strdelBackPath = DirNameResourse.AutoBackupdeleteDirectory;
|
| | | string strdelBackPath = HdlFileNameResourse.AutoBackupdeleteDirectory; |
| | | //如果删除列表里面有这个东西的话,移除掉
|
| | | string delFile = System.IO.Path.Combine(strdelBackPath, fileName);
|
| | | HdlFileLogic.Current.DeleteFile(delFile);
|
| | |
| | | {
|
| | | fileName = System.IO.Path.GetFileName(fileName);
|
| | | //自动删除备份目录
|
| | | string strBackPath = DirNameResourse.AutoBackupdeleteDirectory;
|
| | | string strBackPath = HdlFileNameResourse.AutoBackupdeleteDirectory; |
| | | string newFile = System.IO.Path.Combine(strBackPath, fileName);
|
| | |
|
| | | //创建一个空文件
|
| | |
| | | file.Close();
|
| | |
|
| | | //自动备份目录
|
| | | strBackPath = DirNameResourse.AutoBackupDirectory;
|
| | | strBackPath = HdlFileNameResourse.AutoBackupDirectory; |
| | | //如果备份列表里面有这个东西的话,移除掉
|
| | | string delFile = System.IO.Path.Combine(strBackPath, fileName);
|
| | |
|
| | |
| | | public static int SynchronizeDbAutoBackupData()
|
| | | {
|
| | | //暂时不支持成员
|
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 3)
|
| | | if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 3) |
| | | {
|
| | | //同步服务器的分享内容
|
| | | HdlShardLogic.Current.SynchronizeDbSharedContent();
|
| | | return 1;
|
| | | }
|
| | | //判断是否能够同步数据
|
| | | string checkFile = DirNameResourse.AutoDownLoadBackupCheckFile;
|
| | | string checkFile = HdlFileNameResourse.AutoDownLoadBackupCheckFile; |
| | | //如果本地已经拥有了这个文件,则说明不是新手机,不再自动还原
|
| | | if (System.IO.File.Exists(checkFile) == true)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | //获取app的自动备份
|
| | | var data = HdlBackupLogic.Current.GetBackupListNameFromDB(1);
|
| | | if (data == null)
|
| | | var listData = HdlBackupLogic.Current.GetBackupListNameFromDB(BackUpMode.A自动备份); |
| | | if (listData == null) |
| | | {
|
| | | return -1;
|
| | | }
|
| | | if (data.Count == 0)
|
| | | if (listData.Count == 0) |
| | | {
|
| | | //创建一个空文件(标识已经完成同步)
|
| | | var file = System.IO.File.Create(checkFile);
|
| | |
| | | return 2;
|
| | | }
|
| | | //自动备份只有一个
|
| | | string backId = data[0].Id;
|
| | | string backId = listData[0].Id; |
| | |
|
| | | //账号数据同步中
|
| | | ProgressFormBar.Current.Start();
|
| | |
| | | file2.Close();
|
| | |
|
| | | //重新刷新住宅对象
|
| | | UserCenterLogic.RefreshHomeObject();
|
| | | HdlUserCenterLogic.Current.RefreshHomeObject(); |
| | | //根据模板文件,恢复数据
|
| | | TemplateData.TemplateCommonLogic.Current.RecoverDataByTemplateBinFile();
|
| | | //强制生成设备和网关文件
|
| | |
| | | public static void DeleteAllAutoBackupFile()
|
| | | {
|
| | | //清空自动备份【文件夹】(编辑,追加)
|
| | | string dirPath = DirNameResourse.AutoBackupDirectory;
|
| | | string dirPath = HdlFileNameResourse.AutoBackupDirectory; |
| | | HdlFileLogic.Current.DeleteDirectory(dirPath);
|
| | | HdlFileLogic.Current.CreateDirectory(dirPath, true);
|
| | |
|
| | | //清空自动备份【文件夹】(删除)
|
| | | dirPath = DirNameResourse.AutoBackupdeleteDirectory;
|
| | | dirPath = HdlFileNameResourse.AutoBackupdeleteDirectory; |
| | | HdlFileLogic.Current.DeleteDirectory(dirPath);
|
| | | HdlFileLogic.Current.CreateDirectory(dirPath, true);
|
| | | }
|
| | |
| | | public static void SaveBackupNotPrompted(bool notPrompted, int day = -1)
|
| | | {
|
| | | //文件全路径
|
| | | string fullName = DirNameResourse.AutoBackupNotPromptedFile;
|
| | | string fullName = HdlFileNameResourse.AutoBackupNotPromptedFile; |
| | | BackupNotPrompted info = null;
|
| | | if (System.IO.File.Exists(fullName) == true)
|
| | | {
|
| | |
| | | /// </summary>
|
| | | public static void ShowAutoBackupPromptedForm()
|
| | | {
|
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 3)
|
| | | if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 3) |
| | | {
|
| | | //暂不支持成员
|
| | | return;
|
| | |
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | var form = new HdlBackup.HdlAutoBackupForm();
|
| | | var form = new UserCenter.HdlBackup.HdlAutoBackupForm(); |
| | | form.AddForm();
|
| | | });
|
| | | }
|
| | |
| | | /// <returns></returns>
|
| | | private static bool CheckAutoBackupFileIsChanged()
|
| | | {
|
| | | List<string> listFile1 = HdlFileLogic.Current.GetFileFromDirectory(DirNameResourse.AutoBackupDirectory);
|
| | | List<string> listFile1 = HdlFileLogic.Current.GetFileFromDirectory(HdlFileNameResourse.AutoBackupDirectory); |
| | | List<string> listFile2 = GetAutoBackupDeleteFile();
|
| | |
|
| | | if (listFile1.Count == 0 && listFile2.Count == 0)
|
| | |
| | | private static bool CheckCanShowAutoBackupForm()
|
| | | {
|
| | | //文件全路径
|
| | | string fullName = DirNameResourse.AutoBackupNotPromptedFile;
|
| | | string fullName = HdlFileNameResourse.AutoBackupNotPromptedFile; |
| | | if (System.IO.File.Exists(fullName) == false)
|
| | | {
|
| | | //本地没有存在这个文件
|