From 9d61367c1fd278f58f721d4c0e69999f89e4485d Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期四, 12 十二月 2019 14:14:30 +0800
Subject: [PATCH] 添加最新绑定机制
---
ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs | 205 +++++++++++++++++++++++++++++++++++++-------------
1 files changed, 150 insertions(+), 55 deletions(-)
diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
old mode 100755
new mode 100644
index d59f95d..31aca50
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
@@ -76,7 +76,7 @@
/// </summary>
/// <param name="mainDevice">璁惧瀵硅薄</param>
/// <param name="listDevice">瑕佺粦瀹氱殑鐩爣璁惧</param>
- /// <param name="BindCluster">瑕佺粦瀹氱殑鐩爣璁惧</param>
+ /// <param name="BindCluster">BindCluster</param>
/// <returns></returns>
public async Task<List<CommonDevice>> BindDeviceTarget(CommonDevice mainDevice, List<CommonDevice> listDevice, int BindCluster = 6)
{
@@ -123,60 +123,60 @@
{
string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(data.BindMacAddr, data.BindEpoint);
//0:娣诲姞鎴愬姛 3:宸茬粡瀛樺湪锛屼篃鍙互浠h〃鎴愬姛
- if (data.Result == 0 || data.Result == 3)
- {
- if (dicDevice.ContainsKey(mainkeys) == true)
- {
- listSuccess.Add(dicDevice[mainkeys]);
- }
- }
+ //if (data.Result == 0 || data.Result == 3)
+ //{
+ // if (dicDevice.ContainsKey(mainkeys) == true)
+ // {
+ // listSuccess.Add(dicDevice[mainkeys]);
+ // }
+ //}
//1锛氬け璐ワ紝鑺傜偣璁惧鎴栧満鏅笉瀛樺湪
- else if (data.Result == 1)
- {
- if (dicDevice.ContainsKey(mainkeys) == true)
- {
- //璁惧鍚嶇О 缁戝畾澶辫触
- string msg = Common.LocalDevice.Current.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n";
- msg += Language.StringByID(R.MyInternationalizationString.BindFailed);
- this.ShowTipMsg(msg);
- }
- }
+ //else if (data.Result == 1)
+ //{
+ // if (dicDevice.ContainsKey(mainkeys) == true)
+ // {
+ // //璁惧鍚嶇О 缁戝畾澶辫触
+ // string msg = Common.LocalDevice.Current.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n";
+ // msg += Language.StringByID(R.MyInternationalizationString.BindFailed);
+ // this.ShowTipMsg(msg);
+ // }
+ //}
//2锛氭湭鐭ワ紝鐢辫妭鐐硅澶囧弽棣堝彂閫佲�淏ind/BindResult鈥濅富棰樻秷鎭‘瀹氭槸鍚︽垚鍔�
- else if (data.Result == 2)
- {
- if (result.addBindResultResponseData == null)
- {
- //璁惧鍚嶇О 缁戝畾澶辫触
- string msg = Common.LocalDevice.Current.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n";
- msg += Language.StringByID(R.MyInternationalizationString.BindFailed);
- this.ShowTipMsg(msg);
- }
- else
- {
- //娣诲姞鎴愬姛
- if (result.addBindResultResponseData.Result == 0)
- {
- if (dicDevice.ContainsKey(mainkeys) == true)
- {
- listSuccess.Add(dicDevice[mainkeys]);
- }
- }
- //璁惧鍚嶇О 缁戝畾鍒楄〃宸叉弧
- else if (result.addBindResultResponseData.Result == 140)
- {
- string msg = Common.LocalDevice.Current.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n";
- msg += Language.StringByID(R.MyInternationalizationString.uBindListIsFull);
- this.ShowTipMsg(msg);
- }
- else
- {
- //璁惧鍚嶇О 缁戝畾澶辫触
- string msg = Common.LocalDevice.Current.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n";
- msg += Language.StringByID(R.MyInternationalizationString.BindFailed);
- this.ShowTipMsg(msg);
- }
- }
- }
+ //else if (data.Result == 2)
+ //{
+ // if (result.addBindResultResponseData == null)
+ // {
+ // //璁惧鍚嶇О 缁戝畾澶辫触
+ // string msg = Common.LocalDevice.Current.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n";
+ // msg += Language.StringByID(R.MyInternationalizationString.BindFailed);
+ // this.ShowTipMsg(msg);
+ // }
+ // else
+ // {
+ // //娣诲姞鎴愬姛
+ // if (result.addBindResultResponseData.Result == 0)
+ // {
+ // if (dicDevice.ContainsKey(mainkeys) == true)
+ // {
+ // listSuccess.Add(dicDevice[mainkeys]);
+ // }
+ // }
+ // //璁惧鍚嶇О 缁戝畾鍒楄〃宸叉弧
+ // else if (result.addBindResultResponseData.Result == 140)
+ // {
+ // string msg = Common.LocalDevice.Current.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n";
+ // msg += Language.StringByID(R.MyInternationalizationString.uBindListIsFull);
+ // this.ShowTipMsg(msg);
+ // }
+ // else
+ // {
+ // //璁惧鍚嶇О 缁戝畾澶辫触
+ // string msg = Common.LocalDevice.Current.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n";
+ // msg += Language.StringByID(R.MyInternationalizationString.BindFailed);
+ // this.ShowTipMsg(msg);
+ // }
+ // }
+ //}
}
return listSuccess;
@@ -191,7 +191,7 @@
/// </summary>
/// <param name="mainDevice">璁惧瀵硅薄</param>
/// <param name="deleteDevice">瑕佸垹闄ょ殑缁戝畾鐩爣璁惧</param>
- /// <param name="BindCluster">瑕佺粦瀹氱殑鐩爣璁惧</param>
+ /// <param name="BindCluster">BindCluster</param>
/// <returns></returns>
public async Task<bool> DeleteDeviceTarget(CommonDevice mainDevice, CommonDevice deleteDevice, int BindCluster = 6)
{
@@ -201,7 +201,7 @@
deleteData.Epoint = mainDevice.DeviceEpoint;
var info = new IASZone.RemoveBindListObj();
- info.BindCluster = 6;
+ info.BindCluster = BindCluster;
info.BindMacAddr = deleteDevice.DeviceAddr;
info.BindEpoint = deleteDevice.DeviceEpoint;
info.BindType = 0;
@@ -271,6 +271,101 @@
return false;
}
+ /// <summary>
+ /// 鍒犻櫎璁惧缁戝畾鐨勭洰鏍�
+ /// </summary>
+ /// <param name="mainDevice">璁惧瀵硅薄</param>
+ /// <param name="listDeleteDevice">瑕佸垹闄ょ殑缁戝畾鐩爣璁惧</param>
+ /// <param name="BindCluster">BindCluster</param>
+ /// <returns>杩斿洖鐨勬槸鎴愬姛鍒犻櫎鐨勮澶�</returns>
+ public async Task<List<CommonDevice>> DeleteDeviceTarget(CommonDevice mainDevice, List<CommonDevice> listDeleteDevice, int BindCluster = 6)
+ {
+ //缁勮鏁版嵁
+ var deleteData = new IASZone.DelDeviceBindData();
+ deleteData.DeviceAddr = mainDevice.DeviceAddr;
+ deleteData.Epoint = mainDevice.DeviceEpoint;
+
+ var dicDevice = new Dictionary<string, CommonDevice>();
+ foreach (var device in listDeleteDevice)
+ {
+ var info = new IASZone.RemoveBindListObj();
+ info.BindCluster = BindCluster;
+ info.BindMacAddr = device.DeviceAddr;
+ info.BindEpoint = device.DeviceEpoint;
+ info.BindType = 0;
+
+ deleteData.RemoveBindList.Add(info);
+ //杩斿洖鎴愬姛璁惧鐨勬椂鍊欎娇鐢�
+ string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
+ dicDevice[mainkeys] = device;
+ }
+ var listSuccess = new List<CommonDevice>();
+
+ var result = (BindObj.DelDeviceBindResponseAllData)await this.LoadDeviceMethodByNameAsync(mainDevice, "DelDeviceBindAsync", deleteData);
+ if (result == null || result.delDeviceBindResponseData == null)
+ {
+ //鍒犻櫎缁戝畾鐩爣澶辫触
+ string msg = Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail);
+ //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+ msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+
+ this.ShowErrorMsg(msg);
+ return listSuccess;
+ }
+
+ foreach (var data in result.delDeviceBindResponseData.RemoveBindList)
+ {
+ string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(data.BindMacAddr, data.BindEpoint);
+ //0:鎴愬姛 1:璁惧涓嶅湪缁戝畾鍒楄〃涓� 锛屼篃鍙互浠h〃鎴愬姛
+ if (data.Result == 0 || data.Result == 1)
+ {
+ listSuccess.Add(dicDevice[mainkeys]);
+ }
+ //3:澶辫触锛屽湪绛夊緟鑺傜偣璁惧纭鏄惁瑙i櫎缁戝畾鎴愬姛
+ else if (data.Result == 3)
+ {
+ //璁惧鍚嶇О 鍏朵粬缁戝畾鐩爣姝e湪鍒犻櫎涓紝璇风◢鍚庡啀璇�
+ string msg = Common.LocalDevice.Current.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n";
+ msg += Language.StringByID(R.MyInternationalizationString.uOtherBindTargetsIsDelettingPleaseWait);
+ this.ShowErrorMsg(msg);
+ }
+ //4锛氭湭鐭ワ紝鐢辫妭鐐硅澶囧弽棣堝彂閫佲�淏ind/BindResult鈥濅富棰樻秷鎭‘瀹氭槸鍚︽垚鍔�
+ else if (data.Result == 4)
+ {
+ if (result.removeBindResultResponseData == null)
+ {
+ //璁惧鍚嶇О 鍒犻櫎缁戝畾鐩爣澶辫触
+ string msg = Common.LocalDevice.Current.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n";
+ msg += Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail);
+ this.ShowErrorMsg(msg);
+ }
+ else
+ {
+ //鎴愬姛
+ if (result.removeBindResultResponseData.Result == 0)
+ {
+ listSuccess.Add(dicDevice[mainkeys]);
+ }
+ //136锛氭帶鍒惰澶囨湰鍦扮粦瀹氬垪琛ㄤ腑鏃犳缁戝畾
+ else if (result.removeBindResultResponseData.Result == 136)
+ {
+ //杩欎釜鍙互褰撳仛鎴愬姛
+ listSuccess.Add(dicDevice[mainkeys]);
+ }
+ else
+ {
+ //璁惧鍚嶇О 鍒犻櫎缁戝畾鐩爣澶辫触
+ string msg = Common.LocalDevice.Current.GetDeviceEpointName(dicDevice[mainkeys]) + "\r\n";
+ msg += Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail);
+ this.ShowErrorMsg(msg);
+ }
+ }
+ }
+ }
+ return listSuccess;
+ }
+
+
#endregion
#region 鈻� 涓�鑸柟娉昣__________________________
--
Gitblit v1.8.0