From 4f0ab0ad21ce450b7856d50f98322a7899361386 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期二, 22 九月 2020 10:30:01 +0800
Subject: [PATCH] 不要下载这个备份
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs | 190 +++++++++++++++++++++++++++++++++++++++++------
1 files changed, 164 insertions(+), 26 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs
index b966e9a..04a86a6 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs
@@ -96,8 +96,8 @@
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);
@@ -147,12 +147,11 @@
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.AccountOption.AppCanSignout = true;
@@ -242,15 +241,25 @@
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");
+
+ //灏嗘ā鏉縝in鏂囦欢绉诲姩鍒板浠芥枃浠跺す涓�
+ 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)
@@ -265,7 +274,13 @@
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);
@@ -275,7 +290,7 @@
}
//寮�鍚繘搴︽潯
- int listFileCount = listAllFile.Count;
+ int listFileCount = listPicFile.Count + listNormalFile.Count;
if (showBar == true)
{
//寮�鍚繘搴︽潯 姝e湪涓婁紶澶囦唤鏂囦欢
@@ -300,18 +315,18 @@
//鍏佽鎸夌郴缁熺殑杩斿洖閿�
Shared.Common.CommonPage.BackKeyCanClick = 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);
@@ -325,6 +340,11 @@
//鍏佽鎸夌郴缁熺殑杩斿洖閿�
Shared.Common.CommonPage.BackKeyCanClick = true;
UserCenterResourse.AccountOption.AppCanSignout = true;
+ if (localTemplateName != string.Empty)
+ {
+ //鍒犻櫎鎺夎繖涓ā鏉挎枃浠�
+ HdlFileLogic.Current.DeleteFile(localTemplateName);
+ }
return false;
}
//璁剧疆杩涘害鍊�
@@ -342,6 +362,11 @@
//鍏佽鎸夌郴缁熺殑杩斿洖閿�
Shared.Common.CommonPage.BackKeyCanClick = true;
UserCenterResourse.AccountOption.AppCanSignout = true;
+ if (localTemplateName != string.Empty)
+ {
+ //鍒犻櫎鎺夎繖涓ā鏉挎枃浠�
+ HdlFileLogic.Current.DeleteFile(localTemplateName);
+ }
return false;
}
@@ -357,10 +382,21 @@
//鍏佽鎸夌郴缁熺殑杩斿洖閿�
Shared.Common.CommonPage.BackKeyCanClick = 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);
}
//杩涘害鏉″叧闂�
@@ -529,8 +565,8 @@
/// <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;
@@ -572,7 +608,7 @@
{
try
{
- var listAllFile = HdlAutoBackupLogic.GetFileFromDirectory(upPath);
+ var listAllFile = HdlFileLogic.Current.GetFileFromDirectory(upPath);
if (listAllFile.Count > 10)
{
listAllFile.Sort();
@@ -594,6 +630,85 @@
});
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("姝e湪涓婁紶鏂囦欢");
+
+ //浠庝簯绔幏鍙栨暟鎹�
+ 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)
+ {
+ //鑾峰彇鍔熻兘澶囦唤鐨処D
+ 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
@@ -673,6 +788,18 @@
//鏄剧ず璁惧鍘嗗彶鐗堟湰(Debug鐢�)
UserCenterResourse.HideOption.DeviceHistory = 1;
}
+ checkKeys = UserCenterLogic.EncryptPassword(UserCenterResourse.FileEncryptKey, DirNameResourse.StartDebugAppFile + UserCenterResourse.UserInfo.Account);
+ if (listFile.Contains(checkKeys) == true)
+ {
+ //寮�鍚悗鍙拌皟璇旳pp鍔熻兘(Debug鐢�)
+ UserCenterResourse.HideOption.StartDebugApp = 1;
+ }
+ checkKeys = UserCenterLogic.EncryptPassword(UserCenterResourse.FileEncryptKey, DirNameResourse.CheckDeviceTypeFile + UserCenterResourse.UserInfo.Account);
+ if (listFile.Contains(checkKeys) == true)
+ {
+ //寮�鍚娴嬭澶嘥ype鐨�(Debug鐢�)
+ UserCenterResourse.HideOption.CheckDeviceType = 1;
+ }
//鎭㈠
IMessageCommon.Current.IgnoreError = false;
@@ -701,20 +828,28 @@
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;
}
@@ -749,11 +884,14 @@
/// </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;
--
Gitblit v1.8.0