File was renamed from ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs |
| | |
| | | using System.Threading.Tasks; |
| | | using Newtonsoft.Json.Linq; |
| | | |
| | | namespace Shared.Phone.UserCenter |
| | | namespace Shared.Phone |
| | | { |
| | | /// <summary> |
| | | /// 设备绑定的逻辑 |
| | |
| | | //获取设备的绑定目标失败 |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uGetDeviceBindTargetFail); |
| | | //拼接上【网关回复超时】的Msg |
| | | msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result); |
| | | msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result); |
| | | |
| | | this.ShowErrorMsg(msg); |
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Error, msg); |
| | | return null; |
| | | } |
| | | var listDevice = new List<CommonDevice>(); |
| | | foreach (var data in result.getAllBindResponseData.BindList) |
| | | { |
| | | CommonDevice deviceTemp = Common.LocalDevice.Current.GetDevice(data.BindMacAddr, data.BindEpoint); |
| | | CommonDevice deviceTemp = HdlDeviceCommonLogic.Current.GetDevice(data.BindMacAddr, data.BindEpoint); |
| | | if (deviceTemp == null) |
| | | { |
| | | continue; |
| | |
| | | //如果当前住宅是虚拟住宅 |
| | | if (Common.Config.Instance.Home.IsVirtually == true) |
| | | { |
| | | var listBind = TemplateData.TemplateDeviceDataLogic.Current.GetDeviceBindList(device); |
| | | var listBind = HdlTemplateDeviceDataLogic.Current.GetDeviceBindList(device); |
| | | return new BindObj.GetDeviceBindResponseAllData() |
| | | { |
| | | getAllBindResponseData = new BindObj.GetDeviceBindResponseData |
| | |
| | | addData.BindList.Add(info); |
| | | |
| | | //返回成功设备的时候使用 |
| | | string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device); |
| | | string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device); |
| | | dicDevice[mainkeys] = device; |
| | | } |
| | | //执行绑定 |
| | |
| | | //绑定目标设置失败 |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uSetBindTargetsFail); |
| | | //拼接上【网关回复超时】的Msg |
| | | msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result); |
| | | msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result); |
| | | |
| | | this.ShowErrorMsg(msg); |
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Error, msg); |
| | | return null; |
| | | } |
| | | |
| | | var listSuccess = new List<CommonDevice>(); |
| | | foreach (var data in result.addedDeviceBindResponseData.BindList) |
| | | { |
| | | string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(data.BindMacAddr, data.BindEpoint); |
| | | string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(data.BindMacAddr, data.BindEpoint); |
| | | if (dicDevice.ContainsKey(mainkeys) == true) |
| | | { |
| | | listSuccess.Add(dicDevice[mainkeys]); |
| | |
| | | { |
| | | //绑定目标设置失败 |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uSetBindTargetsFail); |
| | | this.ShowTipMsg(msg); |
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Tip, msg); |
| | | } |
| | | return listSuccess; |
| | | } |
| | |
| | | //如果当前住宅是虚拟住宅 |
| | | if (Common.Config.Instance.Home.IsVirtually == true) |
| | | { |
| | | return TemplateData.TemplateDeviceDataLogic.Current.AddDeviceBindList(addBindData, null); |
| | | return HdlTemplateDeviceDataLogic.Current.AddDeviceBindList(addBindData, null); |
| | | } |
| | | |
| | | var device = Common.LocalDevice.Current.GetDevice(addBindData.DeviceAddr, addBindData.Epoint); |
| | | var device = HdlDeviceCommonLogic.Current.GetDevice(addBindData.DeviceAddr, addBindData.Epoint); |
| | | //获取发送的命令字符 |
| | | var sendData = this.GetAddDeviceListBindCommandText(addBindData); |
| | | //发送 |
| | |
| | | } |
| | | |
| | | //修改缓存 |
| | | TemplateData.TemplateDeviceDataLogic.Current.AddDeviceBindList(addBindData, result.JsonData[0]); |
| | | HdlTemplateDeviceDataLogic.Current.AddDeviceBindList(addBindData, result.JsonData[0]); |
| | | var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.AddedDeviceBindResponseData>(result.ReceiptData); |
| | | return new BindObj.AddedDeviceBindResponseAllData() { addedDeviceBindResponseData = tempData }; |
| | | } |
| | |
| | | /// </summary> |
| | | public BindObj.AddedDeviceSingleBindResponseAllData AddDeviceSingleBindAsync(BindObj.AddSingleBindData addSingleBindData) |
| | | { |
| | | var device = Common.LocalDevice.Current.GetDevice(addSingleBindData.DeviceAddr, addSingleBindData.Epoint); |
| | | var device = HdlDeviceCommonLogic.Current.GetDevice(addSingleBindData.DeviceAddr, addSingleBindData.Epoint); |
| | | //获取发送的命令字符 |
| | | var sendData = this.GetAddDeviceListSingleBindCommandText(addSingleBindData); |
| | | //发送 |
| | |
| | | //删除绑定目标失败 |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail); |
| | | //拼接上【网关回复超时】的Msg |
| | | msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result); |
| | | msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result); |
| | | |
| | | this.ShowErrorMsg(msg); |
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Error, msg); |
| | | return false; |
| | | } |
| | | |
| | |
| | | { |
| | | //其他绑定目标正在删除中,请稍后再试 |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uOtherBindTargetsIsDelettingPleaseWait); |
| | | this.ShowErrorMsg(msg); |
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Error, msg); |
| | | return false; |
| | | } |
| | | //2:未知,由节点设备反馈发送“Bind/BindResult”主题消息确定是否成功 |
| | |
| | | { |
| | | //删除绑定目标失败 |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail); |
| | | this.ShowErrorMsg(msg); |
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Error, msg); |
| | | return false; |
| | | } |
| | | else |
| | |
| | | { |
| | | //删除绑定目标失败 |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail); |
| | | this.ShowErrorMsg(msg); |
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Error, msg); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | |
| | | deleteData.RemoveBindList.Add(info); |
| | | //返回成功设备的时候使用 |
| | | string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device); |
| | | string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device); |
| | | dicDevice[mainkeys] = device; |
| | | } |
| | | var listSuccess = new List<CommonDevice>(); |
| | |
| | | //删除绑定目标失败 |
| | | string msg = Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail); |
| | | //拼接上【网关回复超时】的Msg |
| | | msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result); |
| | | msg = HdlCommonLogic.Current.CombineGatewayTimeOutMsg(msg, result); |
| | | |
| | | this.ShowErrorMsg(msg); |
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Error, msg); |
| | | return listSuccess; |
| | | } |
| | | |
| | | foreach (var data in result.delDeviceBindResponseData.RemoveBindList) |
| | | { |
| | | string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(data.BindMacAddr, data.BindEpoint); |
| | | string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(data.BindMacAddr, data.BindEpoint); |
| | | //0:成功 1:设备不在绑定列表中 ,也可以代表成功 |
| | | if (data.Result == 0 || data.Result == 1) |
| | | { |
| | |
| | | else if (data.Result == 3) |
| | | { |
| | | //设备名称 其他绑定目标正在删除中,请稍后再试 |
| | | string msg = Common.LocalDevice.Current.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n"; |
| | | string msg = HdlDeviceCommonLogic.Current.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n"; |
| | | msg += Language.StringByID(R.MyInternationalizationString.uOtherBindTargetsIsDelettingPleaseWait); |
| | | this.ShowErrorMsg(msg); |
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Error, msg); |
| | | } |
| | | //2:未知,由节点设备反馈发送“Bind/BindResult”主题消息确定是否成功 |
| | | else if (data.Result == 2) |
| | |
| | | if (result.removeBindResultResponseData == null) |
| | | { |
| | | //设备名称 删除绑定目标失败 |
| | | string msg = Common.LocalDevice.Current.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n"; |
| | | string msg = HdlDeviceCommonLogic.Current.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n"; |
| | | msg += Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail); |
| | | this.ShowErrorMsg(msg); |
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Error, msg); |
| | | } |
| | | else |
| | | { |
| | |
| | | else |
| | | { |
| | | //设备名称 删除绑定目标失败 |
| | | string msg = Common.LocalDevice.Current.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n"; |
| | | string msg = HdlDeviceCommonLogic.Current.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n"; |
| | | msg += Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail); |
| | | this.ShowErrorMsg(msg); |
| | | HdlMessageLogic.Current.ShowMassage(ShowMsgType.Error, msg); |
| | | } |
| | | } |
| | | } |
| | |
| | | //如果当前住宅是虚拟住宅 |
| | | if (Common.Config.Instance.Home.IsVirtually == true) |
| | | { |
| | | return TemplateData.TemplateDeviceDataLogic.Current.DeleteDeviceBindList(delDeviceBindData); |
| | | return HdlTemplateDeviceDataLogic.Current.DeleteDeviceBindList(delDeviceBindData); |
| | | } |
| | | var device = Common.LocalDevice.Current.GetDevice(delDeviceBindData.DeviceAddr, delDeviceBindData.Epoint); |
| | | var device = HdlDeviceCommonLogic.Current.GetDevice(delDeviceBindData.DeviceAddr, delDeviceBindData.Epoint); |
| | | //获取需要发送的数据 |
| | | var sendData = this.GetDeleteDeviceBindCommandText(delDeviceBindData); |
| | | //发送命令 |
| | |
| | | } |
| | | |
| | | //修改缓存 |
| | | TemplateData.TemplateDeviceDataLogic.Current.DeleteDeviceBindList(delDeviceBindData); |
| | | HdlTemplateDeviceDataLogic.Current.DeleteDeviceBindList(delDeviceBindData); |
| | | |
| | | return responseData; |
| | | } |
| | |
| | | //如果当前住宅是虚拟住宅 |
| | | if (Common.Config.Instance.Home.IsVirtually == true) |
| | | { |
| | | return TemplateData.TemplateDeviceDataLogic.Current.ClearDeviceAllBind(device); |
| | | return HdlTemplateDeviceDataLogic.Current.ClearDeviceAllBind(device); |
| | | } |
| | | |
| | | var jObject = new JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5006 } }; |
| | |
| | | } |
| | | |
| | | //修改缓存 |
| | | TemplateData.TemplateDeviceDataLogic.Current.ClearDeviceAllBind(device); |
| | | HdlTemplateDeviceDataLogic.Current.ClearDeviceAllBind(device); |
| | | |
| | | var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.ClearBindInfoResponseData>(result.ReceiptData); |
| | | return new BindObj.ClearBindInfoResponseAllData { clearBindInfoResponseData = tempData }; |
| | |
| | | if (topic == errorTopic) |
| | | { |
| | | var temp = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.ErrorResponData>(jobject["Data"].ToString()); |
| | | reResult.ErrorMsg = HdlCheckLogic.Current.CheckCommonErrorCode(temp.Error); |
| | | reResult.ErrorMsg = HdlCheckLogic.Current.CheckGatewayErrorCode(temp.Error); |
| | | } |
| | | //如果是指定的主题 |
| | | for (int i = 0; i < listReceiptTopic.Count; i++) |
| | |
| | | //如果当前住宅是虚拟住宅 |
| | | if (Common.Config.Instance.Home.IsVirtually == true) |
| | | { |
| | | return TemplateData.TemplateDeviceDataLogic.Current.ConfigurePanelKeyModel(device, value, clusterID, null); |
| | | return HdlTemplateDeviceDataLogic.Current.ConfigurePanelKeyModel(device, value, clusterID, null); |
| | | } |
| | | //获取发送数据 |
| | | var sendData = this.GetConfigureHdlKeyCommandText(device.DeviceAddr, device.DeviceEpoint, value, clusterID); |
| | |
| | | } |
| | | |
| | | //修改缓存 |
| | | TemplateData.TemplateDeviceDataLogic.Current.ConfigurePanelKeyModel(device, value, clusterID, result.JsonData[0]); |
| | | HdlTemplateDeviceDataLogic.Current.ConfigurePanelKeyModel(device, value, clusterID, result.JsonData[0]); |
| | | |
| | | var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.SetWritableValueResponData>(result.ReceiptData); |
| | | return new CommonDevice.SetWritableValueResponAllData { setWritableValueResponData = tempData }; |
| | |
| | | //如果当前住宅是虚拟住宅 |
| | | if (Common.Config.Instance.Home.IsVirtually == true || Common.Config.Instance.Home.IsShowTemplate == true) |
| | | { |
| | | return TemplateData.TemplateDeviceDataLogic.Current.ReadPanelConfigureKeyModel(device); |
| | | return HdlTemplateDeviceDataLogic.Current.ReadPanelConfigureKeyModel(device); |
| | | } |
| | | |
| | | var JObject = new JObject {{ "DeviceAddr",device.DeviceAddr },{ "Epoint", device.DeviceEpoint }, |
| | |
| | | var data = new JObject { { "Undivided", 0 }, { "AttributeId", 6533 }, { "AttributeDataType", 33 }, { "AttributeData", (int)value } }; |
| | | jObject.Add("Data", data); |
| | | return jObject.ToString(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 一般方法___________________________ |
| | | |
| | | /// <summary> |
| | | /// 显示错误信息窗口 |
| | | /// </summary> |
| | | /// <param name="msg"></param> |
| | | private void ShowErrorMsg(string msg) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | var contr = new ShowMsgControl(ShowMsgType.Error, msg); |
| | | contr.Show(); |
| | | }); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 显示Tip信息窗口 |
| | | /// </summary> |
| | | /// <param name="msg"></param> |
| | | private void ShowTipMsg(string msg) |
| | | { |
| | | Application.RunOnMainThread(() => |
| | | { |
| | | var contr = new UserCenter.ShowMsgControl(ShowMsgType.Tip, msg); |
| | | contr.Show(); |
| | | }); |
| | | } |
| | | |
| | | #endregion |