From 8b9ce384b26c414db32f98e94e088f5334869c2d Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期三, 13 十一月 2019 15:36:28 +0800 Subject: [PATCH] 全部合并了代码,安卓和 IOS 都测试通过了 --- ZigbeeApp/Shared/Phone/UserCenter/HdlBackup/HdlBackupListForm.cs | 253 +++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 197 insertions(+), 56 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/HdlBackup/HdlManualBackUpForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/HdlBackup/HdlBackupListForm.cs similarity index 62% rename from ZigbeeApp/Shared/Phone/UserCenter/HdlBackup/HdlManualBackUpForm.cs rename to ZigbeeApp/Shared/Phone/UserCenter/HdlBackup/HdlBackupListForm.cs index 2c0eff2..65888c1 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/HdlBackup/HdlManualBackUpForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/HdlBackup/HdlBackupListForm.cs @@ -1,13 +1,13 @@ -锘縰sing Shared.Common; -using System; +锘縰sing System; using System.Collections.Generic; +using System.Text; namespace Shared.Phone.UserCenter.HdlBackup { /// <summary> - /// 澶囦唤鐢婚潰 + /// 澶囦唤鍒楄〃鐣岄潰 /// </summary> - public class HdlManualBackUpForm : EditorCommonForm + public class HdlBackupListForm : EditorCommonForm { #region 鈻� 鍙橀噺澹版槑___________________________ @@ -26,7 +26,7 @@ public void ShowForm() { //璁剧疆鏍囬淇℃伅 - base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uBackupAndRecover)); + base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uDataBackup)); //鍙充笂娣诲姞鎸夐挳 var btnTopIcon = new MostRightIconControl(69, 69); @@ -75,30 +75,60 @@ //杩涘害鏉� this.ShowProgressBar(); + //鑾峰彇app鐨勮嚜鍔ㄥ浠� + var autoData = await HdlBackupLogic.Current.GetBackupListNameFromDB(1); + if (autoData == null) + { + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(ShowReLoadMode.YES); + return; + } //浠庝簯绔幏鍙栨暟鎹� var pageData = await HdlBackupLogic.Current.GetBackupListNameFromDB(); + if (pageData == null) + { + //鍏抽棴杩涘害鏉� + this.CloseProgressBar(ShowReLoadMode.YES); + return; + } //鍏抽棴 this.CloseProgressBar(); - if (pageData == null) + HdlThreadLogic.Current.RunMain(() => { - return; - } - - Application.RunOnMainThread(() => - { - if (this.Parent == null || listView == null) + if (this.Parent == null) { return; } listView.RemoveAll(); - int count = pageData.Count - 1; + listView.RecoverHeight(); + //娣诲姞鑷姩澶囦唤琛� + if (autoData.Count == 0) + { + this.AddNotAutoBackupRow(pageData.Count > 0); + } + else + { + this.AddRowlayout(autoData[0], pageData.Count > 0, true); + } + + //鎺掑簭 + var dic = new Dictionary<string, BackupListNameInfo>(); + var listSort = new List<string>(); for (int i = 0; i < pageData.Count; i++) { - //娣诲姞澶囦唤琛� - this.AddRowlayout(pageData[i], i != count); + listSort.Add(pageData[i].CreatedOnUtc); + dic[pageData[i].CreatedOnUtc] = pageData[i]; } + listSort.Sort(); + + for (int i = listSort.Count - 1; i >= 0; i--) + { + //娣诲姞澶囦唤琛� + this.AddRowlayout(dic[listSort[i]], i != 0, false); + } + listView.AdjustRealHeight(Application.GetRealHeight(23)); }); } @@ -110,65 +140,145 @@ /// 娣诲姞澶囦唤琛� /// </summary> /// <param name="fileInfo"></param> - private void AddRowlayout(BackupListNameInfo fileInfo, bool addLine) + private void AddRowlayout(BackupListNameInfo fileInfo, bool addLine, bool autoBack) { //琛� var rowLayout = new RowLayoutControl(listView.rowSpace / 2); listView.AddChidren(rowLayout); + if (autoBack == true) + { + rowLayout.frameTable.UseClickStatu = false; + } //鍥炬爣 var btnPoint = rowLayout.frameTable.AddLeftIcon(); - btnPoint.UnSelectedImagePath = "Center/Backup.png"; + btnPoint.UnSelectedImagePath = "Item/DownLoad.png"; //澶囦唤鍚嶅瓧 - var txtText = rowLayout.frameTable.AddLeftCaption(fileInfo.BackupName, 700); + var txtText = rowLayout.frameTable.AddLeftCaption("", 700, 60); + if (autoBack == true) + { + //鑷姩澶囦唤 + txtText.Text = Language.StringByID(R.MyInternationalizationString.uAutoBackup); + } + else + { + txtText.Text = fileInfo.BackupName; + } + txtText.TextSize = 15; + //杩欎釜鍧愭爣鏈夌偣鐗规畩 + txtText.Y = Application.GetRealHeight(12) + rowLayout.chidrenYaxis; + rowLayout.frameTable.AddChidren(txtText, ChidrenBindMode.BindEventOnly); + //鏃堕棿 + var btnTime = rowLayout.frameTable.AddLeftCaption("", 600, 50, true); + //杩欎釜鍧愭爣鏈夌偣鐗规畩 + btnTime.Y = Application.GetRealHeight(72) + rowLayout.chidrenYaxis; + btnTime.TextSize = 12; + btnTime.TextColor = UserCenterColor.Current.TextGrayColor1; + rowLayout.frameTable.AddChidren(btnTime, ChidrenBindMode.BindEventOnly); + if (fileInfo.CreatedOnUtc.Length >= 19) + { + btnTime.Text = fileInfo.CreatedOnUtc.Replace("-", ".").Replace("T", " "); + } if (addLine == true) { //搴曠嚎 rowLayout.frameTable.AddBottomLine(); } - //缂栬緫澶囨敞鍚� - rowLayout.frameTable.ButtonClickEvent += (sender, e) => - { - //鏄剧ず缂栬緫澶囪�冨悕鐢婚潰 - this.ShowEditorBackupForm(fileInfo); - }; - - //涓嬭浇鍥炬爣 - var btnLoad = rowLayout.frameTable.AddMostRightEmptyIcon(81, 81); - rowLayout.frameTable.ChangedChidrenBindMode(btnLoad, ChidrenBindMode.NotBind); - //鍚敤鐐逛寒鍔熻兘 - btnLoad.UseClickStatu = true; - btnLoad.UnSelectedImagePath = "Item/DownLoad.png"; - btnLoad.SelectedImagePath = "Item/DownLoadSelected.png"; + //绔嬪嵆涓嬭浇 + var btnLoad = new NormalViewControl(Application.GetRealWidth(200), rowLayout.frameTable.Height, false); + btnLoad.X = rowLayout.frameTable.Width - Application.GetRealWidth(200 + 127); + btnLoad.TextID = R.MyInternationalizationString.uDownLoadNow; + btnLoad.TextAlignment = TextAlignment.CenterRight; + btnLoad.TextSize = 12; + btnLoad.TextColor = UserCenterColor.Current.TextOrangeColor; + rowLayout.frameTable.AddChidren(btnLoad, ChidrenBindMode.NotBind); btnLoad.ButtonClickEvent += (sender, e) => { //鏄惁瑕佷笅杞藉苟鎭㈠鏁版嵁锛� string msg = Language.StringByID(R.MyInternationalizationString.uDownLoadAndRecoverMsg); this.ShowMassage(ShowMsgType.Confirm, msg, () => - { - //璇诲彇澶囦唤鏂囨。 - this.LoadBackupInfo(fileInfo.Id); - }); + { + //璇诲彇澶囦唤鏂囨。 + this.LoadBackupInfo(fileInfo.Id); + }); }; + if (autoBack == true) + { + //涓婁紶 + var btnUpLoad = rowLayout.AddEditorControl(); + btnUpLoad.TextID = R.MyInternationalizationString.uUpload; + btnUpLoad.ButtonClickEvent += (sender, e) => + { + //纭鏄惁涓婁紶鏁版嵁鍒版湇鍔″櫒锛� + this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uSynchronizeDataToServiceMsg), () => + { + //涓婁紶鑷姩澶囦唤鏁版嵁 + this.UpLoadAutoBackupInfo(); + }); + }; + } + else + { + //缂栬緫澶囨敞鍚� + rowLayout.frameTable.ButtonClickEvent += (sender, e) => + { + //鏄剧ず缂栬緫澶囪�冨悕鐢婚潰 + this.ShowEditorBackupForm(fileInfo); + }; + } + //鍒犻櫎 - var btnDelete = new NormalViewControl(Application.GetRealWidth(177), rowLayout.Height, false); - btnDelete.BackgroundColor = UserCenterColor.Current.RowDeleteButtonColor; - btnDelete.TextAlignment = TextAlignment.Center; - btnDelete.TextColor = UserCenterColor.Current.White; - btnDelete.TextID = R.MyInternationalizationString.uDelete; - rowLayout.AddRightView(btnDelete); + var btnDelete = rowLayout.AddDeleteControl(); btnDelete.ButtonClickEvent += (sender, e) => { - //纭畾瑕佸垹闄ゆ枃浠跺悧锛� - string msg = Language.StringByID(R.MyInternationalizationString.uDoDeleteFileMsg); + //纭鍒犻櫎璇ュ浠芥暟鎹�? + string msg = Language.StringByID(R.MyInternationalizationString.uDoDeleteBackupMsg); this.ShowMassage(ShowMsgType.Confirm, msg, () => - { - //鍒犻櫎澶囦唤鏂囨。 - this.DeleteBackInfo(fileInfo.Id, ShowErrorMode.YES); - }); + { + //鍒犻櫎澶囦唤鏂囨。 + this.DeleteBackInfo(fileInfo.Id, ShowErrorMode.YES); + }); + }; + } + + /// <summary> + /// 娣诲姞娌℃湁鑷姩澶囦唤鏁版嵁鐨勮 + /// </summary> + /// <param name="addLine"></param> + private void AddNotAutoBackupRow(bool addLine) + { + //琛� + var rowLayout = new RowLayoutControl(listView.rowSpace / 2); + listView.AddChidren(rowLayout); + rowLayout.frameTable.UseClickStatu = false; + + //鍥炬爣 + var btnPoint = rowLayout.frameTable.AddLeftIcon(); + btnPoint.UnSelectedImagePath = "Item/DownLoad.png"; + + //澶囦唤鍚嶅瓧 + var txtText = rowLayout.frameTable.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uAutoBackup), 700); + txtText.TextSize = 15; + + if (addLine == true) + { + //搴曠嚎 + rowLayout.frameTable.AddBottomLine(); + } + //涓婁紶 + var btnUpLoad = rowLayout.AddEditorControl(); + btnUpLoad.TextID = R.MyInternationalizationString.uUpload; + btnUpLoad.ButtonClickEvent += (sender, e) => + { + //纭鏄惁涓婁紶鏁版嵁鍒版湇鍔″櫒锛� + this.ShowMassage(ShowMsgType.Confirm, Language.StringByID(R.MyInternationalizationString.uSynchronizeDataToServiceMsg), () => + { + //涓婁紶鑷姩澶囦唤鏁版嵁 + this.UpLoadAutoBackupInfo(); + }); }; } @@ -210,7 +320,7 @@ #endregion - #region 鈻� 涓婁紶鏁版嵁___________________________ + #region 鈻� 涓婁紶鎵嬪姩澶囦唤鏁版嵁___________________ /// <summary> /// 涓婁紶鏁版嵁 @@ -253,6 +363,37 @@ }); } + #endregion + + #region 鈻� 涓婁紶鑷姩澶囦唤鏁版嵁___________________ + + /// <summary> + /// 涓婁紶鑷姩澶囦唤鏁版嵁 + /// </summary> + public void UpLoadAutoBackupInfo() + { + HdlThreadLogic.Current.RunThread(async () => + { + int result = await HdlAutoBackupLogic.DoUpLoadAutoBackupData(); + if (result == -1) + { + //鏂囦欢涓婁紶澶辫触 + string msg = Language.StringByID(R.MyInternationalizationString.uFileUpLoadFail); + this.ShowMassage(ShowMsgType.Error, msg); + + return; + } + //鏁版嵁鎴愬姛鍚屾鍒版湇鍔″櫒 + string msg2 = Language.StringByID(R.MyInternationalizationString.uSynchronizeDataToServiceSuccessMsg); + this.ShowMassage(ShowMsgType.Normal, msg2); + + HdlThreadLogic.Current.RunThread(() => + { + //浠庝簯绔幏鍙栨暟鎹� + this.SetBackupInfoToForm(); + }); + }); + } #endregion #region 鈻� 缂栬緫澶囦唤鍚嶇О_______________________ @@ -340,8 +481,8 @@ private void ShowEditorBackupForm(BackupListNameInfo fileInfo) { //鐢熸垚涓�涓脊绐楃敾闈� - var dialogForm = new DialogInputFrameControl(this, DialogFrameMode.OnlyInput); - + var dialogForm = new DialogInputForm(); + dialogForm.AddForm(DialogFrameMode.OnlyInput); //缂栬緫澶囦唤 dialogForm.SetTitleText(Language.StringByID(R.MyInternationalizationString.uEditorBackup)); //璇疯緭鍏ュ娉ㄥ悕绉� @@ -358,7 +499,7 @@ } //鐢婚潰鍏抽棴 - dialogForm.CloseDialog(); + dialogForm.CloseForm(); //鍚嶅瓧涓�鏍锋椂锛屼笉澶勭悊 if (textValue != fileInfo.BackupName) @@ -376,8 +517,8 @@ private void ShowAddBackupForm() { //鐢熸垚涓�涓脊绐楃敾闈� - var dialogForm = new DialogInputFrameControl(this, DialogFrameMode.OnlyInput); - + var dialogForm = new DialogInputForm(); + dialogForm.AddForm(DialogFrameMode.OnlyInput); //娣诲姞澶囦唤 dialogForm.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddBackup)); //璇疯緭鍏ュ娉ㄥ悕绉� @@ -393,7 +534,7 @@ } //鐢婚潰鍏抽棴 - dialogForm.CloseDialog(); + dialogForm.CloseForm(); //涓婁紶澶囦唤 this.UpLoadBackInfo(textValue); @@ -409,7 +550,7 @@ /// </summary> private void CopyLocationAllFileToAutoBackDirectory() { - List<string> listAllFile = Global.FileListByHomeId(); + List<string> listAllFile = Shared.Common.Global.FileListByHomeId(); string strroot = Common.Config.Instance.FullPath; string autoPath = System.IO.Path.Combine(strroot, DirNameResourse.LocalMemoryDirectory, DirNameResourse.AutoBackupDirectory); -- Gitblit v1.8.0