| | |
| | | {
|
| | | gatewayRow.frameTable.AddBottomLine();
|
| | | }
|
| | | //提示有新版本
|
| | | var btnNew = new RowNewVersionTipView();
|
| | | //提示新版本
|
| | | var btnNew = new InformationTipView(gatewayRow.btnIcon);
|
| | | btnNew.Visible = false;
|
| | | gatewayRow.frameTable.AddChidren(btnNew, ChidrenBindMode.BindEventOnly);
|
| | | gatewayRow.AddTag("btnNew", btnNew);
|
| | | //单击事件
|
| | | gatewayRow.frameTable.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | |
|
| | | var form = new GatewayInfoEditorForm();
|
| | | form.AddForm(gateway);
|
| | | };
|
| | |
|
| | | //切换
|
| | |
| | | this.ShowMassage(ShowMsgType.Confirm, msg, () =>
|
| | | {
|
| | | //执行切换网关操作
|
| | | this.DoSwitchGateway(strWayId, gatewayRow.IsOnline);
|
| | | this.DoSwitchGateway(strWayId);
|
| | | });
|
| | | };
|
| | |
|
| | |
| | |
|
| | | this.dicRowContr[strWayId] = gatewayRow;
|
| | | //设置一个选择网关的默认值
|
| | | if (string.IsNullOrEmpty(GatewayResourse.AppOldSelectGatewayId) == true && gatewayRow.IsOnline == true)
|
| | | if (string.IsNullOrEmpty(GatewayResourse.AppOldSelectGatewayId) == true)
|
| | | {
|
| | | this.SaveGatewayIdToLocation(strWayId);
|
| | | HdlGatewayLogic.Current.SaveGatewayIdToLocation(strWayId);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | //如果解除绑定的网关是当前所选择的网关的话,则关闭设备管理界面
|
| | | this.closeDeviceManagForm = true;
|
| | | this.SaveGatewayIdToLocation(string.Empty);
|
| | | HdlGatewayLogic.Current.SaveGatewayIdToLocation(string.Empty);
|
| | | }
|
| | |
|
| | | //移除
|
| | |
| | | /// </summary>
|
| | | /// <param name="gatewayId"></param>
|
| | | /// <param name="online"></param>
|
| | | private async void DoSwitchGateway(string gatewayId,bool online)
|
| | | private async void DoSwitchGateway(string gatewayId)
|
| | | {
|
| | | if (online == true)
|
| | | var result = await HdlGatewayLogic.Current.DoSwitchGateway(gatewayId);
|
| | | if (result == false)
|
| | | {
|
| | | //重新获取在线网关的信息
|
| | | var result = await this.GetOnlineGatewayInfo(gatewayId);
|
| | | if (result == false)
|
| | | {
|
| | | return;
|
| | | }
|
| | | return;
|
| | | }
|
| | | //切换网关,保存缓存
|
| | | this.SaveGatewayIdToLocation(gatewayId);
|
| | | //如果选择了刷新的网关,则不关闭管理界面
|
| | | this.closeDeviceManagForm = false;
|
| | |
|
| | |
| | | //刷新主画面(不重新获取设备状态)
|
| | | this.LoadFormMethodByName("DeviceListMainForm", "InitMiddleFrame", false);
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 获取在线网关信息
|
| | | /// </summary>
|
| | | /// <param name="gatewayId"></param>
|
| | | /// <returns></returns>
|
| | | private async Task<bool> GetOnlineGatewayInfo(string gatewayId)
|
| | | {
|
| | | //显示进度条
|
| | | this.ShowProgressBar();
|
| | | //获取网关
|
| | | var gateway = HdlGatewayLogic.Current.GetLocalGateway(gatewayId);
|
| | |
|
| | | //检测广播到的这个网关是否拥有住宅ID
|
| | | ZbGateway realWay = null;
|
| | | bool getGatewayInfo = true;
|
| | | if (HdlGatewayLogic.Current.GetRealGateway(ref realWay, gatewayId) == true)
|
| | | {
|
| | | //重新设置住宅ID(这个应该是不经过APP,直接把网关恢复了出厂设置)
|
| | | if (HdlGatewayLogic.Current.HomeIdIsEmpty(realWay.getGatewayBaseInfo.HomeId) == true)
|
| | | {
|
| | | int result2 = await HdlGatewayLogic.Current.ReBindNewGateway(realWay);
|
| | | if (result2 == 0)
|
| | | {
|
| | | //出现未知错误,请稍后再试
|
| | | this.ShowMassage(ShowMsgType.Tip, Language.StringByID(R.MyInternationalizationString.uUnKnowErrorAndResetAgain));
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | }
|
| | | else if (result2 == -1)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | return false;
|
| | | }
|
| | | //重新绑定网关里面已经重新获取了网关信息
|
| | | getGatewayInfo = false;
|
| | | }
|
| | | }
|
| | |
|
| | | if (getGatewayInfo == true)
|
| | | {
|
| | | //获取网关信息
|
| | | var info = await HdlGatewayLogic.Current.GetGatewayNewInfoAsync(gateway);
|
| | | if (info == null)
|
| | | {
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | //获取全部设备
|
| | | bool result = await Common.LocalDevice.Current.SetDeviceToMemmoryByGateway(gateway);
|
| | | //关闭进度条
|
| | | this.CloseProgressBar();
|
| | | if (result == false)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 保存选择的网关ID到本地
|
| | | /// </summary>
|
| | | /// <param name="gatewayId"></param>
|
| | | private void SaveGatewayIdToLocation(string gatewayId)
|
| | | {
|
| | | GatewayResourse.AppOldSelectGatewayId = gatewayId;
|
| | | byte[] data = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(GatewayResourse.AppOldSelectGatewayId));
|
| | | Global.WriteFileToDirectoryByBytes(DirNameResourse.LocalMemoryDirectory, DirNameResourse.AppOldSelectGatewayFile, data);
|
| | | }
|
| | |
|
| | | #endregion
|
| | |
| | | {
|
| | | if (this.dicRowContr.ContainsKey(gwid) == true && this.dicRowContr[gwid] != null)
|
| | | {
|
| | | var btnNew = (RowNewVersionTipView)this.dicRowContr[gwid].GetTagByKey("btnNew");
|
| | | var btnNew = (InformationTipView)this.dicRowContr[gwid].GetTagByKey("btnNew");
|
| | | if (btnNew != null)
|
| | | {
|
| | | btnNew.Visible = true;
|
| | |
| | | {
|
| | | base.CloseForm();
|
| | |
|
| | | if (string.IsNullOrEmpty(GatewayResourse.AppOldSelectGatewayId) == true && this.closeDeviceManagForm == true)
|
| | | if (this.closeDeviceManagForm == true)
|
| | | {
|
| | | //关闭界面
|
| | | HdlGatewayLogic.Current.RefreshAppOldSelectGatewayId();
|
| | |
| | | /// </summary>
|
| | | public override int FormActionAgainEvent()
|
| | | {
|
| | | //进到这个界面,理论上前回的网关id是有的,如果为空了,应该是当前的网关被解绑了
|
| | | if (GatewayResourse.AppOldSelectGatewayId == string.Empty)
|
| | | {
|
| | | //关闭设备列表
|
| | | this.closeDeviceManagForm = true;
|
| | | }
|
| | | //初始化中部控件
|
| | | this.InitMiddleFrame();
|
| | | return 1;
|