| | |
| | | /// </summary>
|
| | | private async void SetBackupInfoToForm()
|
| | | {
|
| | | this.nowSelectBackId = string.Empty;
|
| | | this.nowbtnSelect = null;
|
| | |
|
| | | //进度条
|
| | | this.ShowProgressBar();
|
| | |
|
| | | //获取自动备份的数据
|
| | | var pageAuto = await HdlBackupLogic.Current.GetBackupListNameFromDB(3, realGateway.GwId);
|
| | | if (pageAuto == null)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar(ShowReLoadMode.YES);
|
| | | return;
|
| | | }
|
| | |
|
| | | //从云端获取数据
|
| | | var pageData = await HdlBackupLogic.Current.GetBackupListNameFromDB(2, HdlGatewayLogic.Current.GetGatewayId(realGateway));
|
| | | var pageData = await HdlBackupLogic.Current.GetBackupListNameFromDB(2, realGateway.GwId);
|
| | | if (pageData == null)
|
| | | {
|
| | | //关闭进度条
|
| | |
| | | {
|
| | | listView.RemoveAll();
|
| | | listView.RecoverHeight();
|
| | |
|
| | | //自动备份的ID
|
| | | string autoID = string.Empty;
|
| | | if (pageAuto.Count > 0)
|
| | | {
|
| | | autoID = pageAuto[0].Id;
|
| | | //添加自动备份行
|
| | | this.AddRowlayout(pageAuto[0], pageData.Count > 0, true);
|
| | | }
|
| | |
|
| | | for (int i = 0; i < pageData.Count; i++)
|
| | | {
|
| | | //添加备份行
|
| | | this.AddRowlayout(pageData[i], i != pageData.Count - 1);
|
| | | this.AddRowlayout(pageData[i], i != pageData.Count - 1, false);
|
| | | }
|
| | |
|
| | | this.btnDownload?.RemoveFromParent();
|
| | | if (pageData.Count > 0)
|
| | | if (pageData.Count > 0 || pageAuto.Count > 0)
|
| | | {
|
| | | //下载
|
| | | this.btnDownload = new BottomClickButton();
|
| | |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDownLoadAndRecoverMsg);
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
| | | {
|
| | | this.LoadBackupInfo(this.nowSelectBackId);
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //读取备份文档
|
| | | bool result = HdlGatewayBackupLogic.Current.RecoverGateway(this.realGateway, this.nowSelectBackId, autoID == this.nowSelectBackId ? 1 : 0);
|
| | | if (result == true)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //关闭这个界面
|
| | | this.CloseForm();
|
| | | });
|
| | | }
|
| | | });
|
| | | });
|
| | | };
|
| | | //调整真实高度
|
| | | listView.AdjustRealHeightByBottomButton(Application.GetRealHeight(23));
|
| | | }
|
| | |
|
| | | });
|
| | | }
|
| | |
|
| | |
| | | /// </summary>
|
| | | /// <param name="fileInfo"></param>
|
| | | /// <param name="addLine"></param>
|
| | | private void AddRowlayout(BackupListNameInfo fileInfo, bool addLine)
|
| | | /// <param name="isAuto"></param>
|
| | | private void AddRowlayout(BackupListNameInfo fileInfo, bool addLine, bool isAuto)
|
| | | {
|
| | | var rowLayout = new RowLayoutControl(listView.rowSpace / 2);
|
| | | listView.AddChidren(rowLayout);
|
| | |
|
| | | //备份名字
|
| | | var txtText = rowLayout.frameTable.AddLeftCaption(fileInfo.BackupName, 700, 60);
|
| | | txtText.TextSize = 15;
|
| | | txtText.Y = Application.GetRealHeight(12) + rowLayout.chidrenYaxis;
|
| | | rowLayout.frameTable.AddChidren(txtText, ChidrenBindMode.BindEventOnly);
|
| | | var txtText = rowLayout.frameTable.AddTopView(fileInfo.BackupName, 700);
|
| | | if (isAuto == true)
|
| | | {
|
| | | txtText.TextID = R.MyInternationalizationString.uAutoBackup;
|
| | | }
|
| | |
|
| | | //时间 2019-11-11T11:31:01
|
| | | 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);
|
| | | var btnTime = rowLayout.frameTable.AddBottomView("", 600);
|
| | | if (fileInfo.CreatedOnUtc.Length >= 19)
|
| | | {
|
| | | btnTime.Text = fileInfo.CreatedOnUtc.Replace("-", ".").Replace("T", " ");
|
| | | btnTime.Text = UserCenterLogic.ConvertUtcTimeToLocalTime(fileInfo.CreatedOnUtc).ToString("yyyy.MM.dd HH:mm:ss");
|
| | | }
|
| | | //底线
|
| | | if (addLine == true)
|
| | |
| | | }
|
| | | };
|
| | |
|
| | | //编辑
|
| | | var btnEditor = rowLayout.AddEditorControl();
|
| | | btnEditor.ButtonClickEvent += (sender, e) =>
|
| | | //自动备份不允许编辑
|
| | | if (isAuto == false)
|
| | | {
|
| | | //显示编辑备考名画面
|
| | | this.ShowEditorBackupForm(fileInfo);
|
| | | };
|
| | |
|
| | | //删除
|
| | | var btnDelete = rowLayout.AddDeleteControl();
|
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //确认删除该备份数据?
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDoDeleteBackupMsg);
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
| | | //编辑
|
| | | var btnEditor = rowLayout.AddEditorControl();
|
| | | btnEditor.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //删除备份文档
|
| | | this.DeleteBackInfo(fileInfo.Id);
|
| | | });
|
| | | };
|
| | | }
|
| | | //显示编辑备考名画面
|
| | | this.ShowEditorBackupForm(fileInfo);
|
| | | };
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 读取备份文档_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 读取备份文档
|
| | | /// </summary>
|
| | | /// <param name="BackupClassId"></param>
|
| | | private void LoadBackupInfo(string BackupClassId)
|
| | | {
|
| | | HdlThreadLogic.Current.RunThread(async () =>
|
| | | {
|
| | | //获取网关上面存在的全部文件
|
| | | var listFile = await this.GetGatewayFileFromGateway();
|
| | | if (listFile == null)
|
| | | //删除
|
| | | var btnDelete = rowLayout.AddDeleteControl();
|
| | | btnDelete.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | return;
|
| | | }
|
| | | //从云端获取备份的文件
|
| | | bool result = await HdlBackupLogic.Current.LoadGatewayBackupInfo(BackupClassId, realGateway, listFile);
|
| | | if (result == false)
|
| | | {
|
| | | //网关恢复失败
|
| | | string msg2 = Language.StringByID(R.MyInternationalizationString.uGatewayFileRecoverFail);
|
| | | this.ShowMassage(ShowMsgType.Error, msg2);
|
| | | return;
|
| | | }
|
| | |
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | //关闭自身
|
| | | this.CloseForm();
|
| | | });
|
| | |
|
| | | //网关恢复成功
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uGatewayFileRecoverSuccess);
|
| | | this.ShowMassage(ShowMsgType.Normal, msg);
|
| | | });
|
| | | //确认删除该备份数据?
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDoDeleteBackupMsg);
|
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
| | | {
|
| | | //删除备份文档
|
| | | this.DeleteBackInfo(fileInfo.Id);
|
| | | });
|
| | | };
|
| | | }
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | private void ShowEditorBackupForm(BackupListNameInfo fileInfo)
|
| | | {
|
| | | //生成一个弹窗画面
|
| | | var dialogForm = new DialogInputForm();
|
| | | dialogForm.AddForm(DialogFrameMode.OnlyInput);
|
| | | var dialogForm = new DialogInputControl();
|
| | |
|
| | | //编辑备份
|
| | | dialogForm.SetTitleText(Language.StringByID(R.MyInternationalizationString.uEditorBackup));
|
| | | //请输入备注名称
|
| | | dialogForm.SetTipText(Language.StringByID(R.MyInternationalizationString.uPleaseInpuBackup));
|
| | | //请输入备份名称
|
| | | dialogForm.SetTipText(Language.StringByID(R.MyInternationalizationString.uPleaseInpuBackupName));
|
| | | dialogForm.Text = fileInfo.BackupName;
|
| | |
|
| | | //按下确认按钮
|
| | | dialogForm.ComfirmClickEvent += ((txtvalue) =>
|
| | | {
|
| | | //画面关闭
|
| | | dialogForm.CloseForm();
|
| | | dialogForm.CloseDialog();
|
| | | //名字一样时,不处理
|
| | | if (txtvalue != fileInfo.BackupName)
|
| | | {
|
| | |
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 获取网关文件_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 从网关获取它的文件
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | private async System.Threading.Tasks.Task<List<string>> GetGatewayFileFromGateway()
|
| | | {
|
| | | var fileData = await realGateway.FileTransferLsDirAsync();
|
| | | //检测网关返回的共通错误状态码
|
| | | string error = HdlCheckLogic.Current.CheckCommonErrorCode(fileData);
|
| | | if (error != null)
|
| | | {
|
| | | this.ShowMassage(ShowMsgType.Error, error);
|
| | | return null;
|
| | | }
|
| | |
|
| | | if (fileData == null || fileData.fileTransferLsDiResponseData == null || fileData.fileTransferLsDiResponseData.Result != 0)
|
| | | {
|
| | | //获取网关文件失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uGetGatewayFileFail);
|
| | | this.ShowMassage(ShowMsgType.Error, msg);
|
| | | return null;
|
| | | }
|
| | | var listFile = new List<string>();
|
| | | foreach (var filedata in fileData.fileTransferLsDiResponseData.Dir)
|
| | | {
|
| | | listFile.Add(filedata.File);
|
| | | }
|
| | | return listFile;
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|
| | |
|
| | | #endregion
|
| | | }
|