| | |
| | | }
|
| | |
|
| | | //设置住宅ID到网关
|
| | | bool flage2 = await this.SetHomeIdToGateway(zbGateway, Common.Config.Instance.HomeId);
|
| | | bool flage2 = await this.SetHomeIdToGateway(zbGateway, Common.Config.Instance.HomeId, mode);
|
| | | if (flage2 == false)
|
| | | {
|
| | | if (mode == ShowErrorMode.YES)
|
| | |
| | | if (flage1 == -1)
|
| | | {
|
| | | //备份失败的网关ID
|
| | | HdlGatewayLogic.Current.BackupGatewayIdOnNotNetwork(zbGateway);
|
| | | this.BackupGatewayIdOnNotNetwork(zbGateway);
|
| | | }
|
| | |
|
| | | //是否已经存在
|
| | | string gwID = zbGateway.GwId;
|
| | | bool isEsist = HdlGatewayLogic.Current.IsGatewayExist(zbGateway); |
| | | bool isEsist = this.IsGatewayExist(zbGateway); |
| | | if (isEsist == false)
|
| | | {
|
| | | //新建一个虚拟的网关出来
|
| | |
| | | /// <param name="zbGateway"></param>
|
| | | /// <param name="HomeId"></param>
|
| | | /// <returns></returns> |
| | | public async Task<bool> SetHomeIdToGateway(ZbGateway zbGateway, string HomeId)
|
| | | public async Task<bool> SetHomeIdToGateway(ZbGateway zbGateway, string HomeId, ShowErrorMode mode)
|
| | | {
|
| | | var info = await zbGateway.GwSetHomeIdAsync(HomeId);
|
| | | ZbGateway realWay = null;
|
| | | if (this.GetRealGateway(ref realWay, zbGateway) == false)
|
| | | {
|
| | | if (mode == ShowErrorMode.YES)
|
| | | {
|
| | | //错误:网关对象丢失
|
| | | string msg = Language.StringByID(R.MyInternationalizationString.uErrorGatewayLostMsg);
|
| | | this.ShowTipMsg(msg);
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | var info = await realWay.GwSetHomeIdAsync(HomeId);
|
| | | if (info != null && info.gwSetHomeIdData != null)
|
| | | {
|
| | | return true;
|
| | |
| | | }
|
| | |
|
| | | //设置住宅ID到网关
|
| | | bool flage2 = await this.SetHomeIdToGateway(zbGateway, Common.Config.Instance.HomeId);
|
| | | bool flage2 = await this.SetHomeIdToGateway(zbGateway, Common.Config.Instance.HomeId, ShowErrorMode.YES);
|
| | | if (flage2 == false)
|
| | | {
|
| | | //向网关设置住宅ID失败
|
| | |
| | | if (hadReal == true && realWay.GatewayOnlineFlage == true)
|
| | | {
|
| | | //清空网关的住宅ID
|
| | | bool result = await this.SetHomeIdToGateway(realWay, string.Empty);
|
| | | bool result = await this.SetHomeIdToGateway(realWay, string.Empty, ShowErrorMode.YES);
|
| | | if (result == false)
|
| | | {
|
| | | //网关解绑失败 不理它,因为网关可以按按键强制搜索得到
|