New file |
| | |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | | using ZigBee.Device;
|
| | |
|
| | | namespace Shared.Phone.UserCenter.GatewayManage
|
| | | {
|
| | | /// <summary>
|
| | | /// 网关数据上传及下载界面
|
| | | /// </summary>
|
| | | public class GatewayUploadAndDownLoadForm : EditorCommonForm
|
| | | {
|
| | | #region ■ 变量声明___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 网关ID
|
| | | /// </summary>
|
| | | private string gatewayId = string.Empty;
|
| | | /// <summary>
|
| | | /// 网关对象
|
| | | /// </summary>
|
| | | private ZbGateway realGateway = null;
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 初始化_____________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 画面显示(底层会固定调用此方法,借以完成画面创建)
|
| | | /// </summary>
|
| | | /// <param name="i_gatewayId">网关ID</param>
|
| | | public void ShowForm(string i_gatewayId)
|
| | | {
|
| | | this.gatewayId = i_gatewayId;
|
| | | HdlGatewayLogic.Current.GetRealGateway(ref this.realGateway, gatewayId);
|
| | |
|
| | | //设置头部信息
|
| | | base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uDataUploadAndDownLoad));
|
| | |
|
| | | //初始化中部信息
|
| | | this.InitMiddleFrame();
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 初始化中部信息
|
| | | /// </summary>
|
| | | private void InitMiddleFrame()
|
| | | {
|
| | | //清空bodyFrame
|
| | | this.ClearBodyFrame();
|
| | |
|
| | | var frameBack = new FrameLayout();
|
| | | frameBack.Height = Application.GetRealHeight(11);
|
| | | frameBack.BackgroundColor = UserCenterColor.Current.White;
|
| | | bodyFrameLayout.AddChidren(frameBack);
|
| | |
|
| | | var listView = new VerticalListControl(12);
|
| | | listView.Y = frameBack.Bottom;
|
| | | listView.Height = bodyFrameLayout.Height - frameBack.Height;
|
| | | listView.BackgroundColor = UserCenterColor.Current.White;
|
| | | bodyFrameLayout.AddChidren(listView);
|
| | |
|
| | | //自动备份
|
| | | var frameAuto = new FrameRowControl(listView.rowSpace / 2);
|
| | | frameAuto.UseClickStatu = false;
|
| | | listView.AddChidren(frameAuto);
|
| | | frameAuto.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uAutoBackup), 700);
|
| | | frameAuto.AddBottomLine();
|
| | | var btnSwicth = frameAuto.AddMostRightSwitchIcon();
|
| | | btnSwicth.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | //设置状态
|
| | | if (HdlGatewayLogic.Current.SetGatewayAutoBackupStatu(this.realGateway, !btnSwicth.IsSelected) == true)
|
| | | {
|
| | | btnSwicth.IsSelected = !btnSwicth.IsSelected;
|
| | | }
|
| | | };
|
| | |
|
| | | //上传数据至云端
|
| | | var frameUp = new FrameRowControl(listView.rowSpace / 2);
|
| | | listView.AddChidren(frameUp);
|
| | | frameUp.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uUploadDataToDb), 700);
|
| | | frameUp.AddRightArrow();
|
| | | frameUp.AddBottomLine();
|
| | | frameUp.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (this.realGateway == null)
|
| | | {
|
| | | //错误:网关对象丢失
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg);
|
| | | this.ShowMassage(ShowMsgType.Error, msg);
|
| | | return;
|
| | | }
|
| | | //生成一个弹窗画面
|
| | | var dialogForm = new DialogInputControl();
|
| | | //上传数据
|
| | | dialogForm.SetTitleText(Language.StringByID(R.MyInternationalizationString.uUploadData));
|
| | | //请输入备份名称
|
| | | dialogForm.SetTipText(Language.StringByID(R.MyInternationalizationString.uPleaseInpuBackupName));
|
| | | //按下确认按钮
|
| | | dialogForm.ComfirmClickEvent += ((textValue) =>
|
| | | {
|
| | | //画面关闭
|
| | | dialogForm.CloseDialog();
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //上传备份
|
| | | HdlGatewayBackupLogic.Current.DoBackupGateway(this.realGateway, textValue);
|
| | | });
|
| | | });
|
| | | };
|
| | |
|
| | | //从云端下载数据
|
| | | var frameDown = new FrameRowControl(listView.rowSpace / 2);
|
| | | listView.AddChidren(frameDown);
|
| | | frameDown.AddLeftCaption(Language.StringByID(R.MyInternationalizationString.uDwonloadDataFromDb), 700);
|
| | | frameDown.AddRightArrow();
|
| | | frameDown.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | if (this.realGateway == null)
|
| | | {
|
| | | //错误:网关对象丢失
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg);
|
| | | this.ShowMassage(ShowMsgType.Error, msg);
|
| | | return;
|
| | | }
|
| | | var form = new GatewayBackUpListForm();
|
| | | form.AddForm(this.realGateway);
|
| | | };
|
| | | //调整真实高度
|
| | | listView.AdjustRealHeight(Application.GetRealHeight(23));
|
| | |
|
| | | HdlThreadLogic.Current.RunThread(() =>
|
| | | {
|
| | | //获取网关数据
|
| | | this.GetGatewayData(btnSwicth);
|
| | | });
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
|
| | | #region ■ 获取数据___________________________
|
| | |
|
| | | /// <summary>
|
| | | /// 获取网关数据
|
| | | /// </summary>
|
| | | /// <param name="btnSwitch"></param>
|
| | | private void GetGatewayData(MostRightIconControl btnSwitch)
|
| | | {
|
| | | //打开进度条
|
| | | this.ShowProgressBar();
|
| | |
|
| | | //获取网关自动设置状态
|
| | | var statu = HdlGatewayLogic.Current.GetGatewayAutoBackupStatu(realGateway);
|
| | | if (statu == -1)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar(ShowReLoadMode.YES);
|
| | | return;
|
| | | }
|
| | | if (statu == 1)
|
| | | {
|
| | | HdlThreadLogic.Current.RunMain(() =>
|
| | | {
|
| | | btnSwitch.IsSelected = true;
|
| | | });
|
| | | }
|
| | |
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | }
|
| | |
|
| | | #endregion
|
| | | }
|
| | | }
|