| | |
| | | /// <summary>
|
| | | /// 网关备份的界面
|
| | | /// </summary>
|
| | | public class HdlGatewayBackUpForm : UserCenterCommonForm
|
| | | public class HdlGatewayBackUpForm : EditorCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | |
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uBackupAndRecover));
|
| | |
|
| | | //右上添加按钮
|
| | | var btnTopIcon = new TopLayoutMostRightView();
|
| | | var btnTopIcon = new MostRightIconControl(69, 69);
|
| | | btnTopIcon.UnSelectedImagePath = "Item/Add.png";
|
| | | btnTopIcon.SelectedImagePath = "Item/AddSelected.png"; |
| | | topFrameLayout.AddChidren(btnTopIcon); |
| | | btnTopIcon.MouseUpEventHandler += (sender, e) => |
| | | btnTopIcon.InitControl();
|
| | | btnTopIcon.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //显示添加备考名画面
|
| | | this.ShowAddBackupForm(); |
| | | //this.ShowAddBackupForm();
|
| | | }; |
| | | |
| | | //初始化中部控件 |
| | | this.InitMiddleFrame(); |
| | | //this.InitMiddleFrame();
|
| | | } |
| | | |
| | | /// <summary> |
| | | /// 初始化中部控件 |
| | | /// </summary> |
| | | private void InitMiddleFrame() |
| | | {
|
| | | listView = new VerticalScrolViewLayout();
|
| | | listView.Height = bodyFrameLayout.Height;
|
| | | bodyFrameLayout.AddChidren(listView);
|
| | | ///// <summary>
|
| | | ///// 初始化中部控件
|
| | | ///// </summary>
|
| | | //private void InitMiddleFrame()
|
| | | //{
|
| | | // //清空bodyFrame
|
| | | // this.ClearBodyFrame();
|
| | |
|
| | | new System.Threading.Thread(() =>
|
| | | {
|
| | | //从云端获取数据
|
| | | this.SetBackupInfoToForm();
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | }
|
| | | // listView = new VerticalScrolViewLayout();
|
| | | // listView.Height = bodyFrameLayout.Height;
|
| | | // bodyFrameLayout.AddChidren(listView);
|
| | |
|
| | | // new System.Threading.Thread(() =>
|
| | | // {
|
| | | // //从云端获取数据
|
| | | // this.SetBackupInfoToForm();
|
| | | // })
|
| | | // { IsBackground = true }.Start();
|
| | | //}
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 从云端获取数据_____________________
|
| | | //#region ■ 从云端获取数据_____________________
|
| | |
|
| | | /// <summary>
|
| | | /// 从云端获取数据
|
| | | /// </summary>
|
| | | private async void SetBackupInfoToForm()
|
| | | {
|
| | | //进度条
|
| | | this.ShowProgressBar();
|
| | | ///// <summary>
|
| | | ///// 从云端获取数据
|
| | | ///// </summary>
|
| | | //private async void SetBackupInfoToForm()
|
| | | //{
|
| | | // //进度条
|
| | | // this.ShowProgressBar();
|
| | |
|
| | | //从云端获取数据 |
| | | var pageData = await HdlBackupLogic.Current.GetBackupListNameFromDB(2, Common.LocalGateway.Current.GetGatewayId(zbRealGateway));
|
| | | //关闭
|
| | | this.CloseProgressBar();
|
| | | // //从云端获取数据 |
| | | // var pageData = await HdlBackupLogic.Current.GetBackupListNameFromDB(2, Common.LocalGateway.Current.GetGatewayId(zbRealGateway));
|
| | | // //关闭
|
| | | // this.CloseProgressBar();
|
| | |
|
| | | if (pageData == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | // if (pageData == null)
|
| | | // {
|
| | | // return;
|
| | | // }
|
| | |
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | listView.RemoveAll();
|
| | | });
|
| | | // Application.RunOnMainThread(() =>
|
| | | // {
|
| | | // if (listView != null)
|
| | | // {
|
| | | // listView.RemoveAll();
|
| | | // }
|
| | | // });
|
| | |
|
| | | foreach (BackupListNameInfo fileInfo in pageData)
|
| | | {
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | //添加备份行
|
| | | this.AddRowlayout(fileInfo);
|
| | | });
|
| | | }
|
| | | }
|
| | | // foreach (BackupListNameInfo fileInfo in pageData)
|
| | | // {
|
| | | // Application.RunOnMainThread(() =>
|
| | | // {
|
| | | // if (this.Parent != null)
|
| | | // {
|
| | | // //添加备份行
|
| | | // this.AddRowlayout(fileInfo);
|
| | | // }
|
| | | // });
|
| | | // }
|
| | | //}
|
| | |
|
| | | #endregion
|
| | | //#endregion
|
| | |
|
| | | #region ■ 添加备份行_________________________
|
| | | //#region ■ 添加备份行_________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 添加备份行
|
| | | /// </summary>
|
| | | /// <param name="fileInfo"></param>
|
| | | private void AddRowlayout(BackupListNameInfo fileInfo)
|
| | | {
|
| | | //行
|
| | | var rowLayout = new StatuRowLayout(listView);
|
| | | //图标
|
| | | var btnPoint = new RowLeftIconView();
|
| | | btnPoint.SelectedImagePath = "Center/BackupSelected.png";
|
| | | btnPoint.UnSelectedImagePath = "Center/Backup.png";
|
| | | rowLayout.AddChidren(btnPoint);
|
| | | ///// <summary>
|
| | | ///// 添加备份行
|
| | | ///// </summary>
|
| | | ///// <param name="fileInfo"></param>
|
| | | //private void AddRowlayout(BackupListNameInfo fileInfo)
|
| | | //{
|
| | | // //行
|
| | | // var rowLayout = new StatuRowLayout(listView);
|
| | | // //图标
|
| | | // var btnPoint = new RowLeftIconView();
|
| | | // btnPoint.SelectedImagePath = "Center/BackupSelected.png";
|
| | | // btnPoint.UnSelectedImagePath = "Center/Backup.png";
|
| | | // rowLayout.AddChidren(btnPoint);
|
| | |
|
| | | //备份名字
|
| | | var txtText = new RowCenterView();
|
| | | txtText.Text = fileInfo.BackupName;
|
| | | rowLayout.AddChidren(txtText);
|
| | | txtText.X -= ControlCommonResourse.PointXXLeft;
|
| | | // //备份名字
|
| | | // var txtText = new RowCenterView();
|
| | | // txtText.Text = fileInfo.BackupName;
|
| | | // rowLayout.AddChidren(txtText);
|
| | | // txtText.X -= ControlCommonResourse.PointXXLeft;
|
| | |
|
| | | //编辑备注名
|
| | | rowLayout.MouseUpEvent += (sender, e) =>
|
| | | {
|
| | | //显示编辑备考名画面
|
| | | this.ShowEditorBackupForm(fileInfo);
|
| | | };
|
| | | // //编辑备注名
|
| | | // rowLayout.MouseUpEvent += (sender, e) =>
|
| | | // {
|
| | | // //显示编辑备考名画面
|
| | | // this.ShowEditorBackupForm(fileInfo);
|
| | | // };
|
| | |
|
| | | //下载图标
|
| | | var btnLoad = new MostRightEmptyView();
|
| | | //启用点亮功能
|
| | | btnLoad.UseClickStatu = true;
|
| | | btnLoad.UnSelectedImagePath = "Item/DownLoad.png";
|
| | | btnLoad.SelectedImagePath = "Item/DownLoadSelected.png";
|
| | | rowLayout.AddChidren(btnLoad, ChidrenBindMode.NotBind);
|
| | | //下载图标太右边不好看 |
| | | btnLoad.X -= Application.GetRealWidth(50);
|
| | | btnLoad.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | //是否要下载并恢复数据?
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDownLoadAndRecoverMsg);
|
| | | this.ShowConfirmMsg(msg, "LoadBackupInfo", fileInfo.Id);
|
| | | };
|
| | | // //下载图标
|
| | | // var btnLoad = new MostRightEmptyView();
|
| | | // //启用点亮功能
|
| | | // btnLoad.UseClickStatu = true;
|
| | | // btnLoad.UnSelectedImagePath = "Item/DownLoad.png";
|
| | | // btnLoad.SelectedImagePath = "Item/DownLoadSelected.png";
|
| | | // rowLayout.AddChidren(btnLoad, ChidrenBindMode.NotBind);
|
| | | // //下载图标太右边不好看 |
| | | // btnLoad.X -= Application.GetRealWidth(50);
|
| | | // btnLoad.MouseUpEventHandler += (sender, e) =>
|
| | | // {
|
| | | // //是否要下载并恢复数据?
|
| | | // string msg = Language.StringByID(R.MyInternationalizationString.uDownLoadAndRecoverMsg);
|
| | | // this.ShowConfirmMsg(msg, "LoadBackupInfo", fileInfo.Id);
|
| | | // };
|
| | |
|
| | | //删除
|
| | | var btnDelete = new RowDeleteButton();
|
| | | rowLayout.AddRightView(btnDelete);
|
| | | btnDelete.MouseUpEventHandler += (sender, e) =>
|
| | | {
|
| | | //确定要删除文件吗?
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDoDeleteFileMsg);
|
| | | this.ShowConfirmMsg(msg, "DeleteBackInfo", fileInfo.Id, ShowErrorMode.YES);
|
| | | };
|
| | | }
|
| | | // //删除
|
| | | // var btnDelete = new RowDeleteButton();
|
| | | // rowLayout.AddRightView(btnDelete);
|
| | | // btnDelete.MouseUpEventHandler += (sender, e) =>
|
| | | // {
|
| | | // //确定要删除文件吗?
|
| | | // string msg = Language.StringByID(R.MyInternationalizationString.uDoDeleteFileMsg);
|
| | | // this.ShowConfirmMsg(msg, "DeleteBackInfo", fileInfo.Id, ShowErrorMode.YES);
|
| | | // };
|
| | | //}
|
| | |
|
| | | #endregion
|
| | | //#endregion
|
| | |
|
| | | #region ■ 读取备份文档_______________________
|
| | | //#region ■ 读取备份文档_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 读取备份文档
|
| | | /// </summary>
|
| | | /// <param name="BackupClassId"></param>
|
| | | public void LoadBackupInfo(string BackupClassId)
|
| | | {
|
| | | new System.Threading.Thread(async () =>
|
| | | {
|
| | | //获取网关上面存在的全部文件
|
| | | var listFile = await this.GetGatewayFileFromGateway();
|
| | | if (listFile == null)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //从云端获取备份的文件
|
| | | bool result = await HdlBackupLogic.Current.LoadGatewayBackupInfo(BackupClassId, zbRealGateway, listFile);
|
| | | if (result == false)
|
| | | {
|
| | | //网关恢复失败
|
| | | string msg2 = Language.StringByID(R.MyInternationalizationString.uGatewayFileRecoverFail);
|
| | | this.ShowNormalMsg(msg2);
|
| | | return;
|
| | | }
|
| | | ///// <summary>
|
| | | ///// 读取备份文档
|
| | | ///// </summary>
|
| | | ///// <param name="BackupClassId"></param>
|
| | | //public void LoadBackupInfo(string BackupClassId)
|
| | | //{
|
| | | // new System.Threading.Thread(async () =>
|
| | | // {
|
| | | // //获取网关上面存在的全部文件
|
| | | // var listFile = await this.GetGatewayFileFromGateway();
|
| | | // if (listFile == null)
|
| | | // {
|
| | | // return;
|
| | | // }
|
| | | // //从云端获取备份的文件
|
| | | // bool result = await HdlBackupLogic.Current.LoadGatewayBackupInfo(BackupClassId, zbRealGateway, listFile);
|
| | | // if (result == false)
|
| | | // {
|
| | | // //网关恢复失败
|
| | | // string msg2 = Language.StringByID(R.MyInternationalizationString.uGatewayFileRecoverFail);
|
| | | // this.ShowNormalMsg(msg2);
|
| | | // return;
|
| | | // }
|
| | |
|
| | | Application.RunOnMainThread(() =>
|
| | | {
|
| | | //关闭自身
|
| | | this.CloseForm();
|
| | | });
|
| | | // Application.RunOnMainThread(() =>
|
| | | // {
|
| | | // //关闭自身
|
| | | // this.CloseForm();
|
| | | // });
|
| | |
|
| | | //网关恢复成功
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uGatewayFileRecoverSuccess);
|
| | | this.ShowNormalMsg(msg);
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | }
|
| | | // //网关恢复成功
|
| | | // string msg = Language.StringByID(R.MyInternationalizationString.uGatewayFileRecoverSuccess);
|
| | | // this.ShowNormalMsg(msg);
|
| | | // })
|
| | | // { IsBackground = true }.Start();
|
| | | //}
|
| | |
|
| | | #endregion
|
| | | //#endregion
|
| | |
|
| | | #region ■ 上传数据___________________________
|
| | | //#region ■ 上传数据___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 上传数据
|
| | | /// </summary>
|
| | | /// <param name="backName"></param>
|
| | | private async void UpLoadBackInfo(string backName)
|
| | | {
|
| | | //展开进度条
|
| | | this.ShowProgressBar();
|
| | | ///// <summary>
|
| | | ///// 上传数据
|
| | | ///// </summary>
|
| | | ///// <param name="backName"></param>
|
| | | //private async void UpLoadBackInfo(string backName)
|
| | | //{
|
| | | // //展开进度条
|
| | | // this.ShowProgressBar();
|
| | |
|
| | | //创建一个备份名字
|
| | | string backupClassId = await HdlBackupLogic.Current.CreatNewBackupNameToDB(backName, 2, Common.LocalGateway.Current.GetGatewayId(zbRealGateway));
|
| | | if (backupClassId == null)
|
| | | {
|
| | | //创建备份名字失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uCreatBackupNameFail);
|
| | | this.ShowErrorMsg(msg);
|
| | | // //创建一个备份名字
|
| | | // string backupClassId = await HdlBackupLogic.Current.CreatNewBackupNameToDB(backName, 2, Common.LocalGateway.Current.GetGatewayId(zbRealGateway));
|
| | | // if (backupClassId == null)
|
| | | // {
|
| | | // //创建备份名字失败
|
| | | // string msg = Language.StringByID(R.MyInternationalizationString.uCreatBackupNameFail);
|
| | | // this.ShowErrorMsg(msg);
|
| | |
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | return;
|
| | | }
|
| | | //添加附加情报:获取网关数据
|
| | | string appendText = Language.StringByID(R.MyInternationalizationString.uGetGatewayData);
|
| | | ProgressBar.SetAppendText(appendText);
|
| | | // //关闭进度条
|
| | | // this.CloseProgressBar();
|
| | | // return;
|
| | | // }
|
| | | // //添加附加情报:获取网关数据
|
| | | // string appendText = Language.StringByID(R.MyInternationalizationString.uGetGatewayData);
|
| | | // ProgressBar.SetAppendText(appendText);
|
| | |
|
| | | //这里是从网关获取备份文件:将网关文件存入到指定的路径下
|
| | | string directory = await this.SetGatewayFileInDirectory();
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | if (directory == null)
|
| | | {
|
| | | //如果上传失败的话,就把它删除
|
| | | this.DeleteBackInfo(backupClassId, ShowErrorMode.NO);
|
| | | return;
|
| | | }
|
| | | // //这里是从网关获取备份文件:将网关文件存入到指定的路径下
|
| | | // string directory = await this.SetGatewayFileInDirectory();
|
| | | // //关闭进度条
|
| | | // this.CloseProgressBar();
|
| | | // if (directory == null)
|
| | | // {
|
| | | // //如果上传失败的话,就把它删除
|
| | | // this.DeleteBackInfo(backupClassId, ShowErrorMode.NO);
|
| | | // return;
|
| | | // }
|
| | |
|
| | | //添加附加情报:上传数据
|
| | | appendText = Language.StringByID(R.MyInternationalizationString.uDataUpLoad);
|
| | | ProgressBar.SetAppendText(appendText);
|
| | | // //添加附加情报:上传数据
|
| | | // appendText = Language.StringByID(R.MyInternationalizationString.uDataUpLoad);
|
| | | // ProgressBar.SetAppendText(appendText);
|
| | |
|
| | | new System.Threading.Thread(async () =>
|
| | | {
|
| | | //上传数据到云端
|
| | | directory = UserCenterLogic.CombinePath(directory);
|
| | | bool result = await HdlBackupLogic.Current.UpLoadBackupFileToDB(backupClassId, 2, directory);
|
| | | //清空附加情报
|
| | | ProgressBar.SetAppendText(string.Empty);
|
| | | // new System.Threading.Thread(async () =>
|
| | | // {
|
| | | // //上传数据到云端
|
| | | // directory = UserCenterLogic.CombinePath(directory);
|
| | | // bool result = await HdlBackupLogic.Current.UpLoadBackupFileToDB(backupClassId, 2, directory);
|
| | | // //清空附加情报
|
| | | // ProgressBar.SetAppendText(string.Empty);
|
| | |
|
| | | if (result == false)
|
| | | {
|
| | | //文件上传失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uFileUpLoadFail);
|
| | | this.ShowErrorMsg(msg);
|
| | | // if (result == false)
|
| | | // {
|
| | | // //文件上传失败
|
| | | // string msg = Language.StringByID(R.MyInternationalizationString.uFileUpLoadFail);
|
| | | // this.ShowErrorMsg(msg);
|
| | |
|
| | | //如果上传失败的话,就把它删除
|
| | | this.DeleteBackInfo(backupClassId, ShowErrorMode.NO);
|
| | | // //如果上传失败的话,就把它删除
|
| | | // this.DeleteBackInfo(backupClassId, ShowErrorMode.NO);
|
| | |
|
| | | return;
|
| | | }
|
| | | // return;
|
| | | // }
|
| | |
|
| | | //刷新画面
|
| | | this.SetBackupInfoToForm();
|
| | | })
|
| | | { IsBackground = true }.Start();
|
| | | }
|
| | | // //刷新画面
|
| | | // this.SetBackupInfoToForm();
|
| | | // })
|
| | | // { IsBackground = true }.Start();
|
| | | //}
|
| | |
|
| | | #endregion
|
| | | //#endregion
|
| | |
|
| | | #region ■ 编辑备份名称_______________________
|
| | | //#region ■ 编辑备份名称_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 编辑备份名称
|
| | | /// </summary>
|
| | | /// <param name="BackupClassId"></param>
|
| | | /// <param name="backName"></param>
|
| | | private async void EditorBackInfo(string BackupClassId, string backName)
|
| | | {
|
| | | //开启进度条
|
| | | this.ShowProgressBar();
|
| | | ///// <summary>
|
| | | ///// 编辑备份名称
|
| | | ///// </summary>
|
| | | ///// <param name="BackupClassId"></param>
|
| | | ///// <param name="backName"></param>
|
| | | //private async void EditorBackInfo(string BackupClassId, string backName)
|
| | | //{
|
| | | // //开启进度条
|
| | | // this.ShowProgressBar();
|
| | |
|
| | | var Pra = new EditorBackUpNamePra();
|
| | | Pra.BackupClassId = BackupClassId;
|
| | | Pra.BackupName = backName;
|
| | | // var Pra = new EditorBackUpNamePra();
|
| | | // Pra.BackupClassId = BackupClassId;
|
| | | // Pra.BackupName = backName;
|
| | | // //获取控制主人账号的Token
|
| | | // Pra.LoginAccessToken = UserCenterLogic.GetConnectMainToken();
|
| | |
|
| | | bool result = await UserCenterLogic.GetResultStatuByRequestHttps("App/UpdateHomeAppGatewayName", Pra);
|
| | | if (result == false)
|
| | | {
|
| | | //编辑备份名称失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uEditorBackupNameFail);
|
| | | this.ShowErrorMsg(msg);
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | return;
|
| | | }
|
| | | // bool result = await UserCenterLogic.GetResultStatuByRequestHttps("App/UpdateHomeAppGatewayName", true, Pra);
|
| | | // if (result == false)
|
| | | // {
|
| | | // //编辑备份名称失败
|
| | | // string msg = Language.StringByID(R.MyInternationalizationString.uEditorBackupNameFail);
|
| | | // this.ShowErrorMsg(msg);
|
| | | // //关闭进度条
|
| | | // this.CloseProgressBar();
|
| | | // return;
|
| | | // }
|
| | |
|
| | | this.SetBackupInfoToForm();
|
| | | }
|
| | | // this.SetBackupInfoToForm();
|
| | | //}
|
| | |
|
| | | #endregion
|
| | | //#endregion
|
| | |
|
| | | #region ■ 删除备份文档_______________________
|
| | | //#region ■ 删除备份文档_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 删除备份文档
|
| | | /// </summary>
|
| | | /// <param name="BackupClassId"></param>
|
| | | /// <param name="showMode"></param>
|
| | | public async void DeleteBackInfo(string BackupClassId, ShowErrorMode showMode = ShowErrorMode.YES)
|
| | | {
|
| | | //进度条
|
| | | this.ShowProgressBar();
|
| | | ///// <summary>
|
| | | ///// 删除备份文档
|
| | | ///// </summary>
|
| | | ///// <param name="BackupClassId"></param>
|
| | | ///// <param name="showMode"></param>
|
| | | //public async void DeleteBackInfo(string BackupClassId, ShowErrorMode showMode = ShowErrorMode.YES)
|
| | | //{
|
| | | // //进度条
|
| | | // this.ShowProgressBar();
|
| | |
|
| | | bool success = await HdlBackupLogic.Current.DeleteDbBackupData(BackupClassId);
|
| | | // bool success = await HdlBackupLogic.Current.DeleteDbBackupData(BackupClassId);
|
| | |
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | // //关闭进度条
|
| | | // this.CloseProgressBar();
|
| | |
|
| | | if (success == false)
|
| | | {
|
| | | if (showMode == ShowErrorMode.YES)
|
| | | {
|
| | | //删除备份失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDeleteBackupFail);
|
| | | this.ShowErrorMsg(msg);
|
| | | }
|
| | | return;
|
| | | }
|
| | | // if (success == false)
|
| | | // {
|
| | | // if (showMode == ShowErrorMode.YES)
|
| | | // {
|
| | | // //删除备份失败
|
| | | // string msg = Language.StringByID(R.MyInternationalizationString.uDeleteBackupFail);
|
| | | // this.ShowErrorMsg(msg);
|
| | | // }
|
| | | // return;
|
| | | // }
|
| | |
|
| | | this.SetBackupInfoToForm();
|
| | | }
|
| | | // this.SetBackupInfoToForm();
|
| | | //}
|
| | |
|
| | | #endregion
|
| | | //#endregion
|
| | |
|
| | | #region ■ 显示编辑备考名画面_________________
|
| | | //#region ■ 显示编辑备考名画面_________________
|
| | |
|
| | | /// <summary>
|
| | | /// 显示编辑备考名画面
|
| | | /// </summary>
|
| | | /// <param name="fileInfo"></param>
|
| | | /// <returns></returns>
|
| | | private void ShowEditorBackupForm(BackupListNameInfo fileInfo)
|
| | | {
|
| | | //生成一个弹窗画面
|
| | | var dialogForm = new DialogInputFrameControl(this, DialogFrameMode.OnlyInput);
|
| | | ///// <summary>
|
| | | ///// 显示编辑备考名画面
|
| | | ///// </summary>
|
| | | ///// <param name="fileInfo"></param>
|
| | | ///// <returns></returns>
|
| | | //private void ShowEditorBackupForm(BackupListNameInfo fileInfo)
|
| | | //{
|
| | | // //生成一个弹窗画面
|
| | | // var dialogForm = new DialogInputFrameControl(this, DialogFrameMode.OnlyInput);
|
| | |
|
| | | //编辑备份
|
| | | dialogForm.SetTitleText(Language.StringByID(R.MyInternationalizationString.uEditorBackup));
|
| | | //请输入备注名称
|
| | | dialogForm.SetTipText(Language.StringByID(R.MyInternationalizationString.uPleaseInpuBackup));
|
| | | dialogForm.InputText = fileInfo.BackupName;
|
| | | // //编辑备份
|
| | | // dialogForm.SetTitleText(Language.StringByID(R.MyInternationalizationString.uEditorBackup));
|
| | | // //请输入备注名称
|
| | | // dialogForm.SetTipText(Language.StringByID(R.MyInternationalizationString.uPleaseInpuBackup));
|
| | | // dialogForm.InputText = fileInfo.BackupName;
|
| | |
|
| | | //按下确认按钮
|
| | | dialogForm.ComfirmClickEvent += (() =>
|
| | | {
|
| | | string txtvalue = dialogForm.InputText;
|
| | | //检测备考名称
|
| | | if (this.CheckBackupName(txtvalue) == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | // //按下确认按钮
|
| | | // dialogForm.ComfirmClickEvent += (() =>
|
| | | // {
|
| | | // string txtvalue = dialogForm.InputText;
|
| | | // //检测备考名称
|
| | | // if (this.CheckBackupName(txtvalue) == false)
|
| | | // {
|
| | | // return;
|
| | | // }
|
| | |
|
| | | //画面关闭
|
| | | dialogForm.CloseDialog();
|
| | | // //画面关闭
|
| | | // dialogForm.CloseDialog();
|
| | |
|
| | | //名字一样时,不处理
|
| | | if (txtvalue != fileInfo.BackupName)
|
| | | {
|
| | | //编辑备份名称
|
| | | this.EditorBackInfo(fileInfo.Id, txtvalue);
|
| | | }
|
| | | });
|
| | | }
|
| | | // //名字一样时,不处理
|
| | | // if (txtvalue != fileInfo.BackupName)
|
| | | // {
|
| | | // //编辑备份名称
|
| | | // this.EditorBackInfo(fileInfo.Id, txtvalue);
|
| | | // }
|
| | | // });
|
| | | //}
|
| | |
|
| | | /// <summary>
|
| | | /// 显示添加备考名画面
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | private void ShowAddBackupForm()
|
| | | {
|
| | | //生成一个弹窗画面
|
| | | var dialogForm = new DialogInputFrameControl(this, DialogFrameMode.OnlyInput);
|
| | | ///// <summary>
|
| | | ///// 显示添加备考名画面
|
| | | ///// </summary>
|
| | | ///// <returns></returns>
|
| | | //private void ShowAddBackupForm()
|
| | | //{
|
| | | // //生成一个弹窗画面
|
| | | // var dialogForm = new DialogInputFrameControl(this, DialogFrameMode.OnlyInput);
|
| | |
|
| | | //添加备份
|
| | | dialogForm.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddBackup));
|
| | | //请输入备注名称
|
| | | dialogForm.SetTipText(Language.StringByID(R.MyInternationalizationString.uPleaseInpuBackup));
|
| | | // //添加备份
|
| | | // dialogForm.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddBackup));
|
| | | // //请输入备注名称
|
| | | // dialogForm.SetTipText(Language.StringByID(R.MyInternationalizationString.uPleaseInpuBackup));
|
| | |
|
| | | //按下确认按钮
|
| | | dialogForm.ComfirmClickEvent += (() =>
|
| | | {
|
| | | string txtvalue = dialogForm.InputText;
|
| | | //检测备考名称
|
| | | if (this.CheckBackupName(txtvalue) == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | // //按下确认按钮
|
| | | // dialogForm.ComfirmClickEvent += (() =>
|
| | | // {
|
| | | // string txtvalue = dialogForm.InputText;
|
| | | // //检测备考名称
|
| | | // if (this.CheckBackupName(txtvalue) == false)
|
| | | // {
|
| | | // return;
|
| | | // }
|
| | |
|
| | | //画面关闭
|
| | | dialogForm.CloseDialog();
|
| | | // //画面关闭
|
| | | // dialogForm.CloseDialog();
|
| | |
|
| | | //上传备份
|
| | | this.UpLoadBackInfo(txtvalue);
|
| | | });
|
| | | }
|
| | | // //上传备份
|
| | | // this.UpLoadBackInfo(txtvalue);
|
| | | // });
|
| | | //}
|
| | |
|
| | | #endregion
|
| | | //#endregion
|
| | |
|
| | | #region ■ 获取网关文件_______________________
|
| | | //#region ■ 获取网关文件_______________________
|
| | |
|
| | | /// <summary>
|
| | | /// 将网关文件存入到指定的路径下
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | private async Task<string> SetGatewayFileInDirectory()
|
| | | {
|
| | | //上传网关备份文件到云端的临时【文件夹】
|
| | | string dir = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.GatewayBackupDirectory);
|
| | | Global.CreateEmptyDirectory(dir, true);
|
| | | ///// <summary>
|
| | | ///// 将网关文件存入到指定的路径下
|
| | | ///// </summary>
|
| | | ///// <returns></returns>
|
| | | //private async Task<string> SetGatewayFileInDirectory()
|
| | | //{
|
| | | // //上传网关备份文件到云端的临时【文件夹】
|
| | | // string dir = System.IO.Path.Combine(DirNameResourse.LocalMemoryDirectory, DirNameResourse.GatewayBackupDirectory);
|
| | | // Global.CreateEmptyDirectory(dir, true);
|
| | |
|
| | | //从网关获取它的文件
|
| | | var listFile = await this.GetGatewayFileFromGateway();
|
| | | if (listFile == null)
|
| | | {
|
| | | return null;
|
| | | }
|
| | | // //从网关获取它的文件
|
| | | // var listFile = await this.GetGatewayFileFromGateway();
|
| | | // if (listFile == null)
|
| | | // {
|
| | | // return null;
|
| | | // }
|
| | |
|
| | | int timeOutCount = 0;
|
| | | bool receiving = false;
|
| | | // int timeOutCount = 0;
|
| | | // bool receiving = false;
|
| | |
|
| | | string checkTopic = Common.LocalGateway.Current.GetGatewayId(zbRealGateway) + "/FileTransfer/DownloadFile";
|
| | | var listByteSource = new List<byte>();
|
| | | //接收数据
|
| | | Action<string, byte[]> action = (topic, dataContent) =>
|
| | | {
|
| | | string[] arry = topic.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | string checkValue = arry[0] + "/" + arry[1] + "/" + arry[2];
|
| | | if (arry.Length < 3 || checkValue != checkTopic)
|
| | | {
|
| | | return;
|
| | | }
|
| | | //刷新超时时间
|
| | | timeOutCount = 0;
|
| | | byte[] fileBytes = dataContent;
|
| | | if (fileBytes[5] != 1)
|
| | | {
|
| | | if (fileBytes.Length == 2056)
|
| | | {
|
| | | var tempBytes = new byte[2048];
|
| | | System.Array.Copy(fileBytes, 8, tempBytes, 0, 2048);
|
| | | listByteSource.AddRange(tempBytes);
|
| | | }
|
| | | else
|
| | | {
|
| | | var tempBytes = new byte[fileBytes.Length - 8];
|
| | | System.Array.Copy(fileBytes, 8, tempBytes, 0, tempBytes.Length);
|
| | | listByteSource.AddRange(tempBytes);
|
| | | }
|
| | | }
|
| | | else
|
| | | {
|
| | | var tempBytes = new byte[fileBytes.Length - 8];
|
| | | System.Array.Copy(fileBytes, 8, tempBytes, 0, tempBytes.Length);
|
| | | listByteSource.AddRange(tempBytes);
|
| | | // string checkTopic = Common.LocalGateway.Current.GetGatewayId(zbRealGateway) + "/FileTransfer/DownloadFile";
|
| | | // var listByteSource = new List<byte>();
|
| | | // //接收数据
|
| | | // Action<string, byte[]> action = (topic, dataContent) =>
|
| | | // {
|
| | | // string[] arry = topic.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
|
| | | // string checkValue = arry[0] + "/" + arry[1] + "/" + arry[2];
|
| | | // if (arry.Length < 3 || checkValue != checkTopic)
|
| | | // {
|
| | | // return;
|
| | | // }
|
| | | // //刷新超时时间
|
| | | // timeOutCount = 0;
|
| | | // byte[] fileBytes = dataContent;
|
| | | // if (fileBytes[5] != 1)
|
| | | // {
|
| | | // if (fileBytes.Length == 2056)
|
| | | // {
|
| | | // var tempBytes = new byte[2048];
|
| | | // System.Array.Copy(fileBytes, 8, tempBytes, 0, 2048);
|
| | | // listByteSource.AddRange(tempBytes);
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // var tempBytes = new byte[fileBytes.Length - 8];
|
| | | // System.Array.Copy(fileBytes, 8, tempBytes, 0, tempBytes.Length);
|
| | | // listByteSource.AddRange(tempBytes);
|
| | | // }
|
| | | // }
|
| | | // else
|
| | | // {
|
| | | // var tempBytes = new byte[fileBytes.Length - 8];
|
| | | // System.Array.Copy(fileBytes, 8, tempBytes, 0, tempBytes.Length);
|
| | | // listByteSource.AddRange(tempBytes);
|
| | |
|
| | | string [] Arryfile = listFile[0].Split(new string[] { "/" }, StringSplitOptions.None);
|
| | | string fileName = Arryfile[Arryfile.Length - 1];
|
| | | //将输入写入本地的临时文件夹
|
| | | Global.WriteFileToDirectoryByBytes(dir, fileName, listByteSource.ToArray());
|
| | | listByteSource.Clear();
|
| | | // string [] Arryfile = listFile[0].Split(new string[] { "/" }, StringSplitOptions.None);
|
| | | // string fileName = Arryfile[Arryfile.Length - 1];
|
| | | // //将输入写入本地的临时文件夹
|
| | | // Global.WriteFileToDirectoryByBytes(dir, fileName, listByteSource.ToArray());
|
| | | // listByteSource.Clear();
|
| | |
|
| | | //移除死循环内的指定目标
|
| | | listFile.RemoveAt(0);
|
| | | receiving = false;
|
| | | }
|
| | | };
|
| | | zbRealGateway.FileContentAction += action;
|
| | | // //移除死循环内的指定目标
|
| | | // listFile.RemoveAt(0);
|
| | | // receiving = false;
|
| | | // }
|
| | | // };
|
| | | // zbRealGateway.FileContentAction += action;
|
| | |
|
| | | //设置进度条的最大值
|
| | | this.SetProgressMax(listFile.Count);
|
| | | // //设置进度条的最大值
|
| | | // this.SetProgressMax(listFile.Count);
|
| | |
|
| | | while (listFile.Count > 0)
|
| | | {
|
| | | timeOutCount++;
|
| | | if (timeOutCount == 150)
|
| | | {
|
| | | //30秒超时:响应超时,获取网关文件失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uResponseTimeoutsAndGetGatewayFileFail);
|
| | | this.ShowErrorMsg(msg);
|
| | | zbRealGateway.FileContentAction -= action;
|
| | | return null;
|
| | | }
|
| | | // while (listFile.Count > 0)
|
| | | // {
|
| | | // timeOutCount++;
|
| | | // if (timeOutCount == 150)
|
| | | // {
|
| | | // //30秒超时:响应超时,获取网关文件失败
|
| | | // string msg = Language.StringByID(R.MyInternationalizationString.uResponseTimeoutsAndGetGatewayFileFail);
|
| | | // this.ShowErrorMsg(msg);
|
| | | // zbRealGateway.FileContentAction -= action;
|
| | | // return null;
|
| | | // }
|
| | |
|
| | | //接收中
|
| | | if (receiving == true)
|
| | | {
|
| | | await Task.Delay(200);
|
| | | continue;
|
| | | }
|
| | | receiving = true;
|
| | | // //接收中
|
| | | // if (receiving == true)
|
| | | // {
|
| | | // await Task.Delay(200);
|
| | | // continue;
|
| | | // }
|
| | | // receiving = true;
|
| | |
|
| | | string[] Arryfile = listFile[0].Split(new string[] { "/" }, StringSplitOptions.None);
|
| | | string fileName = Arryfile[Arryfile.Length - 1];
|
| | | //下载文件
|
| | | var saveFileName = await zbRealGateway.SetDownloadFileAsync(fileName);
|
| | | //检测网关返回的共通错误状态码
|
| | | var error = UserCenterLogic.CheckCommonErrorCode(saveFileName);
|
| | | if (error != null)
|
| | | {
|
| | | this.ShowTip(error);
|
| | | zbRealGateway.FileContentAction -= action;
|
| | | return null;
|
| | | }
|
| | | if (saveFileName == null || saveFileName.setDownloadFileResponseData == null || saveFileName.setDownloadFileResponseData.Result != 0)
|
| | | {
|
| | | //获取网关文件失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uGetGatewayFileFail);
|
| | | this.ShowErrorMsg(msg);
|
| | | zbRealGateway.FileContentAction -= action;
|
| | | return null;
|
| | | }
|
| | | //设置进度值
|
| | | this.SetProgressValue(1);
|
| | | }
|
| | | zbRealGateway.FileContentAction -= action;
|
| | | // string[] Arryfile = listFile[0].Split(new string[] { "/" }, StringSplitOptions.None);
|
| | | // string fileName = Arryfile[Arryfile.Length - 1];
|
| | | // //下载文件
|
| | | // var saveFileName = await zbRealGateway.SetDownloadFileAsync(fileName);
|
| | | // //检测网关返回的共通错误状态码
|
| | | // var error = HdlCheckLogic.Current.CheckCommonErrorCode(saveFileName);
|
| | | // if (error != null)
|
| | | // {
|
| | | // this.ShowMassage(error);
|
| | | // zbRealGateway.FileContentAction -= action;
|
| | | // return null;
|
| | | // }
|
| | | // if (saveFileName == null || saveFileName.setDownloadFileResponseData == null || saveFileName.setDownloadFileResponseData.Result != 0)
|
| | | // {
|
| | | // //获取网关文件失败
|
| | | // string msg = Language.StringByID(R.MyInternationalizationString.uGetGatewayFileFail);
|
| | | // this.ShowErrorMsg(msg);
|
| | | // zbRealGateway.FileContentAction -= action;
|
| | | // return null;
|
| | | // }
|
| | | // //设置进度值
|
| | | // this.SetProgressValue(1);
|
| | | // }
|
| | | // zbRealGateway.FileContentAction -= action;
|
| | | // action = null;
|
| | |
|
| | | return dir;
|
| | | }
|
| | | // return dir;
|
| | | //}
|
| | |
|
| | | /// <summary>
|
| | | /// 从网关获取它的文件
|
| | | /// </summary>
|
| | | /// <returns></returns>
|
| | | private async Task<List<string>> GetGatewayFileFromGateway()
|
| | | {
|
| | | var fileData = await zbRealGateway.FileTransferLsDirAsync();
|
| | | //检测网关返回的共通错误状态码
|
| | | string error = UserCenterLogic.CheckCommonErrorCode(fileData);
|
| | | if (error != null)
|
| | | {
|
| | | this.ShowErrorMsg(error);
|
| | | return null;
|
| | | }
|
| | | ///// <summary>
|
| | | ///// 从网关获取它的文件
|
| | | ///// </summary>
|
| | | ///// <returns></returns>
|
| | | //private async Task<List<string>> GetGatewayFileFromGateway()
|
| | | //{
|
| | | // var fileData = await zbRealGateway.FileTransferLsDirAsync();
|
| | | // //检测网关返回的共通错误状态码
|
| | | // string error = HdlCheckLogic.Current.CheckCommonErrorCode(fileData);
|
| | | // if (error != null)
|
| | | // {
|
| | | // this.ShowErrorMsg(error);
|
| | | // return null;
|
| | | // }
|
| | |
|
| | | if (fileData == null || fileData.fileTransferLsDiResponseData == null || fileData.fileTransferLsDiResponseData.Result != 0)
|
| | | {
|
| | | //获取网关文件失败
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uGetGatewayFileFail);
|
| | | this.ShowErrorMsg(msg);
|
| | | return null;
|
| | | }
|
| | | var listFile = new List<string>();
|
| | | foreach (var filedata in fileData.fileTransferLsDiResponseData.Dir)
|
| | | {
|
| | | listFile.Add(filedata.File);
|
| | | }
|
| | | return listFile;
|
| | | }
|
| | | // if (fileData == null || fileData.fileTransferLsDiResponseData == null || fileData.fileTransferLsDiResponseData.Result != 0)
|
| | | // {
|
| | | // //获取网关文件失败
|
| | | // string msg = Language.StringByID(R.MyInternationalizationString.uGetGatewayFileFail);
|
| | | // this.ShowErrorMsg(msg);
|
| | | // return null;
|
| | | // }
|
| | | // var listFile = new List<string>();
|
| | | // foreach (var filedata in fileData.fileTransferLsDiResponseData.Dir)
|
| | | // {
|
| | | // listFile.Add(filedata.File);
|
| | | // }
|
| | | // return listFile;
|
| | | //}
|
| | |
|
| | | #endregion
|
| | | //#endregion
|
| | |
|
| | | #region ■ 一般方法___________________________
|
| | | //#region ■ 一般方法___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 检测备考名称
|
| | | /// </summary>
|
| | | /// <param name="backName"></param>
|
| | | /// <returns></returns>
|
| | | private bool CheckBackupName(string backName)
|
| | | {
|
| | | if (backName == string.Empty)
|
| | | {
|
| | | //请输入备注名称
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uPleaseInpuBackup);
|
| | | this.ShowErrorMsg(msg);
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | }
|
| | | #endregion
|
| | | ///// <summary>
|
| | | ///// 检测备考名称
|
| | | ///// </summary>
|
| | | ///// <param name="backName"></param>
|
| | | ///// <returns></returns>
|
| | | //private bool CheckBackupName(string backName)
|
| | | //{
|
| | | // if (backName == string.Empty)
|
| | | // {
|
| | | // //请输入备注名称
|
| | | // string msg = Language.StringByID(R.MyInternationalizationString.uPleaseInpuBackup);
|
| | | // this.ShowErrorMsg(msg);
|
| | | // return false;
|
| | | // }
|
| | | // return true;
|
| | | //}
|
| | | //#endregion
|
| | | }
|
| | | }
|