using Shared.Common;
|
using System;
|
using System.Collections.Generic;
|
using System.Collections.Specialized;
|
using System.IO;
|
using System.Net;
|
using System.Text;
|
|
namespace Shared.Phone
|
{
|
/// <summary>
|
/// 备份业务的逻辑
|
/// </summary>
|
public class HdlBackupLogic
|
{
|
#region ■ 变量声明___________________________
|
|
/// <summary>
|
/// 备份业务的逻辑
|
/// </summary>
|
private static HdlBackupLogic m_Current = null;
|
/// <summary>
|
/// 备份业务的逻辑
|
/// </summary>
|
public static HdlBackupLogic Current
|
{
|
get
|
{
|
if (m_Current == null)
|
{
|
m_Current = new HdlBackupLogic();
|
}
|
return m_Current;
|
}
|
}
|
|
#endregion
|
|
#region ■ 获取备份名字列表___________________
|
|
/// <summary>
|
/// 从云端获取备份数据的名字列表
|
/// </summary>
|
/// <param name="backupDiv">备份类型(1:手动备份,2:自动备份)</param>
|
/// <param name="mode">失败时是否显示tip消息</param>
|
/// <param name="getOptionBackup">是否获取功能备份</param>
|
/// <returns></returns>
|
public List<BackupListNameInfo> GetBackupListNameFromDB(BackUpMode backupDiv, ShowNetCodeMode mode = ShowNetCodeMode.YES, bool getOptionBackup = false)
|
{
|
var pra = new { homeId = Config.Instance.Home.Id };
|
var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/backup/folder/findAll", RestSharp.Method.POST, pra, null, null, CheckMode.A账号权限);
|
//检测状态码
|
if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false)
|
{
|
return null;
|
}
|
//获取备份类型的字符标识
|
string strdiv = this.GetBackUpModeText(backupDiv);
|
|
var listData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<BackupListNameInfo>>(result.Data.ToString());
|
var list = new List<BackupListNameInfo>();
|
foreach (var data2 in listData)
|
{
|
if (getOptionBackup == false && data2.FolderName == HdlFileNameResourse.OptionBackupName)
|
{
|
//不获取功能备份
|
continue;
|
}
|
if (data2.BackupClassify != strdiv || data2.BackupDataType != "ZIGBEE_HOME")
|
{
|
//不是指定的备份类型,或者zigbee的备份,则不获取
|
continue;
|
}
|
list.Add(data2);
|
}
|
return list;
|
}
|
|
/// <summary>
|
/// <para>从云端获取备份的文件,然后存入本地指定的临时文件夹</para>
|
/// <para>返回文件夹名字(里面存放着全部的文件),返回null时,代表失败</para>
|
/// </summary>
|
/// <param name="i_folderId">备份主键</param>
|
/// <param name="mode">失败时是否显示tip消息</param>
|
/// <returns></returns>
|
public string GetBackFileFromDBAndSetToLocation(string i_folderId, ShowNetCodeMode mode = ShowNetCodeMode.YES)
|
{
|
//不允许按系统的返回键
|
Config.Instance.BackKeyCanClick = false;
|
HdlUserCenterResourse.AccountOption.AppCanSignout = false;
|
|
//首先先创建一个临时文件夹,存在文件则清空
|
string newDir = HdlFileNameResourse.DownLoadBackupTempDirectory;
|
HdlFileLogic.Current.CreateDirectory(newDir, true);
|
|
//获取这个备份下面有多少个文件
|
var dicFile = GetBackFileIDFromDB(i_folderId, mode);
|
if (dicFile == null)
|
{
|
//关闭进度条
|
ProgressFormBar.Current.Close();
|
//允许按系统的返回键
|
Config.Instance.BackKeyCanClick = true;
|
HdlUserCenterResourse.AccountOption.AppCanSignout = true;
|
return null;
|
}
|
|
//一个个的下载文件
|
int listFileCount = dicFile.Count;
|
int fileCount = 0;
|
foreach(string fileName in dicFile.Keys)
|
{
|
fileCount++;
|
//账号已经退出
|
if (HdlCheckLogic.Current.IsAccountLoginOut() == true)
|
{
|
//关闭进度条
|
ProgressFormBar.Current.Close();
|
//允许按系统的返回键
|
Config.Instance.BackKeyCanClick = true;
|
HdlUserCenterResourse.AccountOption.AppCanSignout = true;
|
return null;
|
}
|
|
//★设置需要获取的文件名字★
|
var pra = new { fileId = dicFile[fileName], folderId = i_folderId, homeId = Config.Instance.Home.Id };
|
var result = HdlHttpLogic.Current.RequestByteFromZigbeeHttps("home-wisdom/backup/file/downOne", RestSharp.Method.POST, pra, null, null, CheckMode.A账号权限, true, 10);
|
//检测状态码
|
if (result == null || result.Length == 0)
|
{
|
//关闭进度条
|
ProgressFormBar.Current.Close();
|
//允许按系统的返回键
|
Config.Instance.BackKeyCanClick = true;
|
HdlUserCenterResourse.AccountOption.AppCanSignout = true;
|
return null;
|
}
|
//将输入写入本地的临时文件夹
|
if (fileName.StartsWith("House_") == false)
|
{
|
HdlFileLogic.Current.SaveByteToFile(System.IO.Path.Combine(newDir, fileName), result);
|
}
|
else
|
{
|
//兼容旧云端的数据迁移到新云端
|
var myHouse = Newtonsoft.Json.JsonConvert.DeserializeObject<House>(Encoding.UTF8.GetString(result));
|
myHouse.Id = Config.Instance.Home.Id;
|
HdlFileLogic.Current.SaveFileContent(System.IO.Path.Combine(newDir, myHouse.FileName), myHouse);
|
}
|
//设置进度值
|
ProgressFormBar.Current.SetValue(fileCount, listFileCount);
|
}
|
|
//允许按系统的返回键
|
Config.Instance.BackKeyCanClick = true;
|
HdlUserCenterResourse.AccountOption.AppCanSignout = true;
|
|
return newDir;
|
}
|
|
/// <summary>
|
/// 从云端获取全部的备份文件的名字(key:文件名字 value:主键)
|
/// </summary>
|
/// <param name="i_folderId">备份主键</param>
|
/// <param name="mode">失败时是否显示tip消息</param>
|
/// <returns></returns>
|
private Dictionary<string, string> GetBackFileIDFromDB(string i_folderId, ShowNetCodeMode mode = ShowNetCodeMode.YES)
|
{
|
//获取这个备份下的文件列表
|
var pra = new { folderId = i_folderId, homeId = Config.Instance.Home.Id };
|
var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/backup/file/findAll", RestSharp.Method.POST, pra, null, null, CheckMode.A账号权限);
|
//检测状态码
|
if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false)
|
{
|
return null;
|
}
|
var listData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<LoadBackupFileNameInfo>>(result.Data.ToString());
|
|
//获取文件名字
|
var dicFileName = new Dictionary<string, string>();
|
foreach (var fileData in listData)
|
{
|
dicFileName[fileData.FileName] = fileData.Id;
|
}
|
return dicFileName;
|
}
|
|
#endregion
|
|
#region ■ 创建备份___________________________
|
|
/// <summary>
|
/// 创建一个备份名字(成功时返回备份的主键ID,失败时返回null)
|
/// </summary>
|
/// <param name="backupName">备份名字</param>
|
/// <param name="backupDiv">备份类型(1:手动备份,2:自动备份)</param>
|
/// <param name="mode">失败时是否显示tip消息</param>
|
/// <returns></returns>
|
public string CreatNewBackupNameToDB(string backupName, BackUpMode backupDiv, ShowNetCodeMode mode = ShowNetCodeMode.YES)
|
{
|
//获取备份类型的字符标识
|
string strdiv = this.GetBackUpModeText(backupDiv);
|
|
var pra = new
|
{
|
backupClassify = strdiv,
|
backupDataType = "ZIGBEE_HOME",
|
folderName = backupName,
|
homeId = Config.Instance.Home.Id
|
};
|
var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/backup/folder/create", RestSharp.Method.POST, pra, null, null, CheckMode.A账号权限);
|
//检测状态码
|
if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false)
|
{
|
return null;
|
}
|
var data = Newtonsoft.Json.JsonConvert.DeserializeObject<AddBackupNameResult>(result.Data.ToString());
|
return data.Id;
|
}
|
|
#endregion
|
|
#region ■ 上传备份___________________________
|
|
/// <summary>
|
/// 上传本地所有文件到云端(函数内部有进度条)
|
/// </summary>
|
/// <param name="i_folderId">备份主键ID</param>
|
/// <param name="upPath">指定上传的是哪个文件夹的文件(全路径),不指定时,上传的是本地路径下的文件</param>
|
/// <param name="showBar">是否设置显示进度条</param>
|
/// <param name="mode">失败时是否显示tip消息</param>
|
/// <returns></returns>
|
public bool UpLoadBackupFileToDB(string i_folderId, string upPath = "", bool showBar = true, ShowNetCodeMode mode = ShowNetCodeMode.YES)
|
{
|
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 = HdlFileLogic.Current.GetRootPathListFile();
|
fullDir = Common.Config.Instance.FullPath;
|
}
|
else
|
{
|
listAllFile = HdlFileLogic.Current.GetFileFromDirectory(upPath);
|
fullDir = upPath;
|
}
|
if (listAllFile.Count == 0)
|
{
|
return true;
|
}
|
|
//普通文件,可以一次性上传多个的
|
var listNormalFile = new List<string>();
|
foreach (string fileName in listAllFile)
|
{
|
//判断指定文件是否需要上传(根目录的才判断)
|
if (upPath == string.Empty && this.IsNotUpLoadFile(fileName) == true)
|
{
|
continue;
|
}
|
listNormalFile.Add(fileName);
|
}
|
|
//开启进度条
|
int listFileCount = listNormalFile.Count;
|
if (showBar == true)
|
{
|
//开启进度条 正在上传备份文件
|
ProgressFormBar.Current.Start();
|
ProgressFormBar.Current.SetMsg(Language.StringByID(R.MyInternationalizationString.uBackupFileUploading));
|
}
|
|
//不允许按系统的返回键
|
Config.Instance.BackKeyCanClick = false;
|
HdlUserCenterResourse.AccountOption.AppCanSignout = false;
|
|
for (int i = 0; i < listNormalFile.Count; i++)
|
{
|
string file = listNormalFile[i];
|
//账号已经退出
|
if (HdlCheckLogic.Current.IsAccountLoginOut() == true)
|
{
|
//关闭进度条
|
ProgressFormBar.Current.Close();
|
//允许按系统的返回键
|
Config.Instance.BackKeyCanClick = true;
|
HdlUserCenterResourse.AccountOption.AppCanSignout = true;
|
if (localTemplateName != string.Empty)
|
{
|
//删除掉这个模板文件
|
HdlFileLogic.Current.DeleteFile(localTemplateName);
|
}
|
return false;
|
};
|
var fileByte = HdlFileLogic.Current.ReadFileByteContent(System.IO.Path.Combine(fullDir, file));
|
//执行上传
|
bool falge = this.DoUpLoadInfoToDB(i_folderId, file, fileByte, mode);
|
if (falge == false)
|
{
|
//关闭进度条
|
ProgressFormBar.Current.Close();
|
//允许按系统的返回键
|
Config.Instance.BackKeyCanClick = true;
|
HdlUserCenterResourse.AccountOption.AppCanSignout = true;
|
if (localTemplateName != string.Empty)
|
{
|
//删除掉这个模板文件
|
HdlFileLogic.Current.DeleteFile(localTemplateName);
|
}
|
return false;
|
}
|
//设置进度值
|
ProgressFormBar.Current.SetValue(i + 1, listFileCount);
|
}
|
|
if (localTemplateName != string.Empty)
|
{
|
//删除掉这个模板文件
|
HdlFileLogic.Current.DeleteFile(localTemplateName);
|
}
|
|
//进度条关闭
|
ProgressFormBar.Current.Close();
|
//允许按系统的返回键
|
Config.Instance.BackKeyCanClick = true;
|
HdlUserCenterResourse.AccountOption.AppCanSignout = true;
|
|
return true;
|
}
|
|
/// <summary>
|
/// 执行上传到云端
|
/// </summary>
|
/// <param name="i_folderId">备份主键ID</param>
|
/// <param name="i_fileName">文件名字</param>
|
/// <param name="i_content">上传的数据</param>
|
/// <param name="mode">失败时是否显示tip消息</param>
|
/// <returns></returns>
|
public bool DoUpLoadInfoToDB(string i_folderId, string i_fileName, byte[] i_content, ShowNetCodeMode mode = ShowNetCodeMode.YES)
|
{
|
var dicQuery = new Dictionary<string, object>();
|
dicQuery["folderId"] = i_folderId;
|
dicQuery["fileName"] = i_fileName;
|
dicQuery["homeId"] = Config.Instance.Home.Id;
|
|
var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/backup/file/create", RestSharp.Method.POST, i_content, dicQuery, null, CheckMode.A账号权限, true, 10);
|
//检测状态码
|
if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false)
|
{
|
return false;
|
}
|
return true;
|
}
|
|
#endregion
|
|
#region ■ 编辑备份___________________________
|
|
/// <summary>
|
/// 编辑备份名字
|
/// </summary>
|
/// <param name="i_folderId">备份主键id</param>
|
/// <param name="i_backName">备注名字</param>
|
/// <param name="mode">失败时是否显示tip消息</param>
|
/// <returns></returns>
|
public bool EditorBackupName(string i_folderId, string i_backName, ShowNetCodeMode mode = ShowNetCodeMode.YES)
|
{
|
var pra = new { folderId = i_folderId, folderName = i_backName, homeId = Config.Instance.Home.Id };
|
var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/backup/folder/update", RestSharp.Method.POST, pra, null, null, CheckMode.A账号权限);
|
//检测状态码
|
if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false)
|
{
|
return false;
|
}
|
return true;
|
}
|
|
#endregion
|
|
#region ■ 上传Log备份________________________
|
|
/// <summary>
|
/// 上传Log备份(隐匿功能)
|
/// </summary>
|
/// <returns></returns>
|
public bool UpLoadLogBackup()
|
{
|
string upPath = HdlFileNameResourse.LogDirectory;
|
if (HdlFileLogic.Current.GetFileFromDirectory(upPath).Count == 0)
|
{
|
//没有Log文件
|
return true;
|
}
|
|
ProgressFormBar.Current.Start();
|
ProgressFormBar.Current.SetMsg("正在上传Log文件");
|
|
//从云端获取数据
|
var pageData = this.GetBackupListNameFromDB(BackUpMode.A手动备份, ShowNetCodeMode.YES, true);
|
if (pageData == null)
|
{
|
ProgressFormBar.Current.Close();
|
return false;
|
}
|
string backId = string.Empty;
|
for (int i = 0; i < pageData.Count; i++)
|
{
|
if (pageData[i].FolderName == HdlFileNameResourse.OptionBackupName)
|
{
|
//获取功能备份的ID
|
backId = pageData[i].Id;
|
break;
|
}
|
}
|
if (backId == string.Empty)
|
{
|
//创建新的备份
|
backId = this.CreatNewBackupNameToDB(HdlFileNameResourse.OptionBackupName, BackUpMode.A手动备份);
|
if (backId == null)
|
{
|
ProgressFormBar.Current.Close();
|
return false;
|
}
|
}
|
//上传Log文件
|
bool result = this.UpLoadBackupFileToDB(backId, upPath, false);
|
if (result == true)
|
{
|
try
|
{
|
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 = this.GetBackupListNameFromDB(BackUpMode.A手动备份, ShowNetCodeMode.YES, 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].FolderName == HdlFileNameResourse.OptionBackupName)
|
{
|
//获取功能备份的ID
|
backId = pageData[i].Id;
|
break;
|
}
|
}
|
if (backId == string.Empty)
|
{
|
//创建新的备份
|
backId = this.CreatNewBackupNameToDB(HdlFileNameResourse.OptionBackupName, BackUpMode.A手动备份);
|
if (backId == null)
|
{
|
ProgressFormBar.Current.Close();
|
HdlThreadLogic.Current.RunMain(() =>
|
{
|
var contr = new ShowMsgControl(ShowMsgType.Tip, "创建功能备份失败");
|
contr.Show();
|
});
|
return false;
|
}
|
}
|
//执行上传
|
bool falge = DoUpLoadInfoToDB(backId, fileName, byteData);
|
//关闭进度条
|
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
|
|
#region ■ 读取隐匿功能配置___________________
|
|
/// <summary>
|
/// 读取隐匿功能配置(不要在意返回值)
|
/// </summary>
|
/// <returns></returns>
|
public bool LoadHideOption()
|
{
|
//先初始化
|
HdlUserCenterResourse.HideOption = new HideOptionInfo();
|
if (HdlUserCenterResourse.ResidenceOption.AuthorityNo != 1 && HdlUserCenterResourse.ResidenceOption.AuthorityNo != 2)
|
{
|
return true;
|
}
|
|
//从云端获取数据
|
var pageData = this.GetBackupListNameFromDB(BackUpMode.A手动备份, ShowNetCodeMode.No, true);
|
if (pageData == null)
|
{
|
return false;
|
}
|
string backId = string.Empty;
|
for (int i = 0; i < pageData.Count; i++)
|
{
|
if (pageData[i].FolderName == HdlFileNameResourse.OptionBackupName)
|
{
|
//获取功能备份的ID
|
backId = pageData[i].Id;
|
break;
|
}
|
}
|
if (backId == string.Empty)
|
{
|
//没有功能配置
|
return true;
|
}
|
//获取这个备份下面有多少个文件
|
var dicFile = this.GetBackFileIDFromDB(backId, ShowNetCodeMode.No);
|
if (dicFile == null)
|
{
|
return false;
|
}
|
if (dicFile.Count == 0)
|
{
|
return true;
|
}
|
|
//检测
|
string checkKeys = HdlCommonLogic.Current.EncryptPassword(HdlUserCenterResourse.FileEncryptKey, HdlFileNameResourse.ShowOptionMenuFile + HdlUserCenterResourse.UserInfo.Account);
|
if (dicFile.ContainsKey(checkKeys) == true)
|
{
|
//显示主页隐藏菜单(Debug用)
|
HdlUserCenterResourse.HideOption.CenterHideMenu = 1;
|
}
|
checkKeys = HdlCommonLogic.Current.EncryptPassword(HdlUserCenterResourse.FileEncryptKey, HdlFileNameResourse.DetailedLogFile + HdlUserCenterResourse.UserInfo.Account);
|
if (dicFile.ContainsKey(checkKeys) == true)
|
{
|
//出力详细Log(Debug用)
|
HdlUserCenterResourse.HideOption.DetailedLog = 1;
|
}
|
checkKeys = HdlCommonLogic.Current.EncryptPassword(HdlUserCenterResourse.FileEncryptKey, HdlFileNameResourse.DeviceHistoryFile + HdlUserCenterResourse.UserInfo.Account);
|
if (dicFile.ContainsKey(checkKeys) == true)
|
{
|
//显示设备历史版本(Debug用)
|
HdlUserCenterResourse.HideOption.DeviceHistory = 1;
|
}
|
checkKeys = HdlCommonLogic.Current.EncryptPassword(HdlUserCenterResourse.FileEncryptKey, HdlFileNameResourse.StartDebugAppFile + HdlUserCenterResourse.UserInfo.Account);
|
if (dicFile.ContainsKey(checkKeys) == true)
|
{
|
//开启后台调试App功能(Debug用)
|
HdlUserCenterResourse.HideOption.StartDebugApp = 1;
|
}
|
checkKeys = HdlCommonLogic.Current.EncryptPassword(HdlUserCenterResourse.FileEncryptKey, HdlFileNameResourse.CheckDeviceTypeFile + HdlUserCenterResourse.UserInfo.Account);
|
if (dicFile.ContainsKey(checkKeys) == true)
|
{
|
//开启检测设备Type的(Debug用)
|
HdlUserCenterResourse.HideOption.CheckDeviceType = 1;
|
}
|
return true;
|
}
|
|
#endregion
|
|
#region ■ 读取备份___________________________
|
|
/// <summary>
|
/// 读取APP备份文档(函数内部有进度条)
|
/// </summary>
|
/// <param name="i_folderId"></param>
|
/// <param name="mode">失败时是否显示tip消息</param>
|
public bool LoadAppBackupInfo(string i_folderId, ShowNetCodeMode mode = ShowNetCodeMode.YES)
|
{
|
//打开进度条 正在获取备份文件列表
|
ProgressFormBar.Current.Start();
|
ProgressFormBar.Current.SetMsg(Language.StringByID(R.MyInternationalizationString.uBackupFileListGetting));
|
|
//从云端获取备份的文件,然后存入本地的临时文件夹
|
string tempDirectory = GetBackFileFromDBAndSetToLocation(i_folderId, mode);
|
if (tempDirectory == null)
|
{
|
//关闭进度条
|
ProgressFormBar.Current.Close();
|
return false;
|
}
|
|
//清空全部房间
|
HdlRoomLogic.Current.DeleteAllRoom();
|
//清空本地全部的场景数据
|
HdlSceneLogic.Current.DeleteAllLocalScene();
|
//如果读取到的文件完全没有问题,则清理本地的文件
|
HdlFileLogic.Current.DeleteAllLocationFile(false);
|
|
//清理本地的模板文件
|
TemplateData.TemplateCommonLogic.Current.DeleteAllLocalFile();
|
|
//没有错误的话,则移动到当前住宅文件夹下面
|
HdlFileLogic.Current.MoveDirectoryFileToHomeDirectory(tempDirectory, true);
|
|
//删除全部的自动备份的本地文件(此函数用于读取自动备份的时候使用)
|
HdlAutoBackupLogic.DeleteAllAutoBackupFile();
|
|
//刷新本地缓存
|
HdlUserCenterLogic.Current.RefreshAllMemory();
|
|
//关闭进度条
|
ProgressFormBar.Current.Close();
|
|
return true;
|
}
|
|
#endregion
|
|
#region ■ 删除备份___________________________
|
|
/// <summary>
|
/// 删除云端备份
|
/// </summary>
|
/// <param name="i_folderId">备份的主键</param>
|
/// <param name="mode">失败时是否显示tip消息</param>
|
/// <returns></returns>
|
public bool DeleteDbBackupData(string i_folderId, ShowNetCodeMode mode = ShowNetCodeMode.YES)
|
{
|
var pra = new { folderId = i_folderId, homeId = Config.Instance.Home.Id };
|
var result = HdlHttpLogic.Current.RequestResponseFromZigbeeHttps("home-wisdom/backup/folder/delete", RestSharp.Method.POST, pra, null, null, CheckMode.A账号权限);
|
//检测状态码
|
if (HdlCheckLogic.Current.CheckNetCode(result, mode) == false)
|
{
|
return false;
|
}
|
return true;
|
}
|
|
#endregion
|
|
#region ■ 一般方法___________________________
|
|
/// <summary>
|
/// 判断是否是应该上传的文件
|
/// </summary>
|
/// <param name="file"></param>
|
/// <returns></returns>
|
public bool IsNotUpLoadFile(string file)
|
{
|
if (file.StartsWith("Device_") == true
|
|| file.StartsWith("Gateway_") == true
|
|| file.StartsWith("Room_") == true
|
|| file.StartsWith("Scene_") == true)
|
{
|
//设备,网关,房间,场景文件不需要上传,它已经保存在bin模板文件中
|
return true;
|
}
|
return false;
|
}
|
|
/// <summary>
|
/// 获取备份类型的字符标识
|
/// </summary>
|
/// <param name="i_mode"></param>
|
/// <returns></returns>
|
private string GetBackUpModeText(BackUpMode i_mode)
|
{
|
if (i_mode == BackUpMode.A自动备份)
|
{
|
return "AUTOMATIC_USER_BACKUP";
|
}
|
return "USER_DEFINED_BACKUP";
|
}
|
|
#endregion
|
}
|
}
|