From b78a4d0ca90416d37fcbaf5e54b00f7eaab53919 Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期一, 14 十月 2019 17:03:58 +0800
Subject: [PATCH] 2019-10-14-2
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 103 insertions(+), 17 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs
index 0576cfe..a5ef6ca 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlBackupLogic.cs
@@ -35,6 +35,11 @@
}
}
+ /// <summary>
+ /// Log澶囦唤鐨勫悕瀛�
+ /// </summary>
+ private string LogBackupName = "##Log##";
+
#endregion
#region 鈻� 鑾峰彇澶囦唤鍚嶅瓧鍒楄〃___________________
@@ -44,8 +49,9 @@
/// </summary>
/// <param name="ZigbeeBackupType">0:App鎵嬪姩澶囦唤 1: App 鑷姩澶囦唤 2锛氱綉鍏虫墜鍔ㄥ浠� 3:缃戝叧鑷姩澶囦唤</param>
/// <param name="ZigbeeUniqueId">缃戝叧鐨勫敮涓�Id,鑾峰彇缃戝叧澶囦唤闇�瑕�</param>
+ /// <param name="getLogBackup">鏄惁鑾峰彇Log澶囦唤</param>
/// <returns></returns>
- public async Task<List<BackupListNameInfo>> GetBackupListNameFromDB(int ZigbeeBackupType = 0, string ZigbeeUniqueId = null)
+ public async Task<List<BackupListNameInfo>> GetBackupListNameFromDB(int ZigbeeBackupType = 0, string ZigbeeUniqueId = null, bool getLogBackup = false)
{
//澶囦唤鍚嶅瓧寰堝皯鐨勫唴瀛橈紝鍙互鐩存帴涓�娆℃�у叏閮ㄥ彇瀹�
var pra = new GetBackupListPra();
@@ -65,20 +71,21 @@
}
var data = Newtonsoft.Json.JsonConvert.DeserializeObject<GetBackupListResult>(result);
- if (ZigbeeUniqueId != null)
+ var list = new List<BackupListNameInfo>();
+ foreach (var data2 in data.PageData)
{
- var list = new List<BackupListNameInfo>();
- foreach (var data2 in data.PageData)
+ if (ZigbeeUniqueId != null && data2.GatewayUniqueId != ZigbeeUniqueId)
{
- if (data2.GatewayUniqueId == ZigbeeUniqueId)
- {
- list.Add(data2);
- }
+ continue;
}
- return list;
+ if (getLogBackup == false && data2.BackupName == LogBackupName)
+ {
+ //涓嶈幏鍙朙og澶囦唤
+ continue;
+ }
+ list.Add(data2);
}
-
- return data.PageData;
+ return list;
}
/// <summary>
@@ -120,7 +127,7 @@
foreach (string fileName in listFile)
{
//璐﹀彿宸茬粡閫�鍑�
- if (UserCenterLogic.IsAccountLoginOut() == true)
+ if (HdlCheckLogic.Current.IsAccountLoginOut() == true)
{
//鍏抽棴杩涘害鏉�
ProgressBar.Close(true);
@@ -222,8 +229,9 @@
/// <param name="BackupClassId">澶囦唤涓婚敭ID</param>
/// <param name="ManualBackupType">鎵嬪姩澶囦唤绫诲瀷(0:App鎵嬪姩澶囦唤,2锛氱綉鍏虫墜鍔ㄥ浠�)</param>
/// <param name="upPath">鎸囧畾涓婁紶鐨勬槸鍝釜鏂囦欢澶圭殑鏂囦欢(鍏ㄨ矾寰�),涓嶆寚瀹氭椂锛屼笂浼犵殑鏄湰鍦拌矾寰勪笅鐨勬枃浠�</param>
+ /// <param name="setBarMaxValue">鏄惁璁剧疆杩涘害鏉$殑鏈�澶у��(杩欎釜涓滆タ涓�鑸笉鐢ㄥ姩瀹�)</param>
/// <returns></returns>
- public async Task<bool> UpLoadBackupFileToDB(string BackupClassId, int ManualBackupType = 0, string upPath = "")
+ public async Task<bool> UpLoadBackupFileToDB(string BackupClassId, int ManualBackupType = 0, string upPath = "", bool setBarMaxValue = true)
{
List<string> listAllFile = null;
//鏂囦欢澶圭殑鍏ㄨ矾寰�
@@ -261,15 +269,18 @@
}
//寮�鍚繘搴︽潯
- ProgressBar.SetMaxValue(listAllFile.Count);
- ProgressBar.Show();
+ if (setBarMaxValue == true)
+ {
+ ProgressBar.SetMaxValue(listAllFile.Count);
+ ProgressBar.Show();
+ }
//浣犺涓轰粈涔堣繖閲屼笉鍒嗕竴涓嚱鏁板嚭鏉ワ紙鐞嗚涓婃槸鍒嗗嚱鏁板嚭鏉ョ殑锛�
//鏄洜涓哄鏋滃垎鍑芥暟鐨勮瘽锛屼細鍑虹幇鍙岄噸寮傛锛屽鑷翠富绾跨▼鐨勮繘搴︽潯鐨勭櫨鍒嗘瘮姘歌繙瀹氭0%
foreach (string file in listNormalFile)
{
//璐﹀彿宸茬粡閫�鍑�
- if (UserCenterLogic.IsAccountLoginOut() == true)
+ if (HdlCheckLogic.Current.IsAccountLoginOut() == true)
{
//鍏抽棴杩涘害鏉�
ProgressBar.Close(true);
@@ -304,7 +315,7 @@
foreach (string file in listPicFile)
{
//璐﹀彿宸茬粡閫�鍑�
- if (UserCenterLogic.IsAccountLoginOut() == true)
+ if (HdlCheckLogic.Current.IsAccountLoginOut() == true)
{
//鍏抽棴杩涘害鏉�
ProgressBar.Close(true);
@@ -325,6 +336,14 @@
//璁剧疆杩涘害鍊�
ProgressBar.SetValue(listPic.Count);
}
+
+ //涓婁紶Log澶囦唤
+ if (upPath != UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.LogDirectory))
+ {
+ //閲岄潰鏈変釜鍥炶皟鑷韩鐨勬柟娉�,鎵�浠ヨ繖閲屽姞涓垽鏂�,涓嶇劧浼氭寰幆
+ await this.UpLoadLogBackup();
+ }
+
//杩涘害鏉″叧闂�
ProgressBar.Close();
@@ -483,6 +502,73 @@
#endregion
+ #region 鈻� 涓婁紶Log澶囦唤________________________
+
+ /// <summary>
+ /// 涓婁紶Log澶囦唤
+ /// </summary>
+ /// <returns></returns>
+ private async Task<bool> UpLoadLogBackup()
+ {
+ string upPath = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.LogDirectory);
+ if (HdlAutoBackupLogic.GetFileFromDirectory(upPath).Count == 0)
+ {
+ //娌℃湁Log鏂囦欢
+ return true;
+ }
+
+ //鏃犺閿欒
+ IMessageCommon.Current.IgnoreError = true;
+ //浠庝簯绔幏鍙栨暟鎹�
+ var pageData = await HdlBackupLogic.Current.GetBackupListNameFromDB(0, null, true);
+ if (pageData == null)
+ {
+ //鎭㈠
+ IMessageCommon.Current.IgnoreError = false;
+ return false;
+ }
+ for (int i = 0; i < pageData.Count; i++)
+ {
+ if (pageData[i].BackupName == LogBackupName)
+ {
+ //鍒犻櫎鎺夎繖涓浠�
+ bool flage = await this.DeleteDbBackupData(pageData[i].Id);
+ if (flage == false)
+ {
+ //鎭㈠
+ IMessageCommon.Current.IgnoreError = false;
+ return false;
+ }
+ break;
+ }
+ }
+ //鍒涘缓鏂扮殑澶囦唤
+ string backupClassId = await HdlBackupLogic.Current.CreatNewBackupNameToDB(LogBackupName);
+ if (backupClassId == null)
+ {
+ //鎭㈠
+ IMessageCommon.Current.IgnoreError = false;
+ return false;
+ }
+ //涓婁紶Log鏂囦欢
+ bool result = await this.UpLoadBackupFileToDB(backupClassId, 0, upPath, false);
+ if (result == true)
+ {
+ try
+ {
+ //鍒犻櫎鏈湴鍏ㄩ儴Log
+ Global.CreateEmptyDirectory(Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.LogDirectory), true);
+ }
+ catch { }
+ }
+ //鎭㈠
+ IMessageCommon.Current.IgnoreError = false;
+
+ return result;
+ }
+
+ #endregion
+
#region 鈻� 璇诲彇澶囦唤___________________________
/// <summary>
--
Gitblit v1.8.0