From 081ea8d273048fd03756718ac6fb48a3c09218e9 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期二, 29 十月 2019 13:10:00 +0800
Subject: [PATCH] Merge branch 'dev-tzy' into DEV_GXC

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs |  101 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 98 insertions(+), 3 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
index d59f95d..c2f7d13 100755
--- 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)
         {
@@ -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