From acb2b278663952ce555b06a2e821f359225f15e0 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期五, 10 七月 2020 09:41:15 +0800
Subject: [PATCH] 备份

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs |  762 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 379 insertions(+), 383 deletions(-)

diff --git a/Home0630/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
old mode 100644
new mode 100755
similarity index 99%
rename from Home0630/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
rename to ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
index 34f9db9..24b9780
--- a/Home0630/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
@@ -1,325 +1,321 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Text;
-using ZigBee.Device;
-using System.Threading.Tasks;
-using Newtonsoft.Json.Linq;
-
-namespace Shared.Phone.UserCenter
-{
-    /// <summary>
-    /// 璁惧缁戝畾鐨勯�昏緫
-    /// </summary>
-    public class HdlDeviceBindLogic
-    {
-        #region 鈻� 鍙橀噺澹版槑___________________________
-
-        /// <summary>
-        /// 璁惧缁戝畾鐨勯�昏緫
+锘縰sing System;
+using System.Collections.Generic;
+using System.Text;
+using ZigBee.Device;
+using System.Threading.Tasks;
+using Newtonsoft.Json.Linq;
+
+namespace Shared.Phone.UserCenter
+{
+    /// <summary>
+    /// 璁惧缁戝畾鐨勯�昏緫
+    /// </summary>
+    public class HdlDeviceBindLogic
+    {
+        #region 鈻� 鍙橀噺澹版槑___________________________
+
+        /// <summary>
+        /// 璁惧缁戝畾鐨勯�昏緫
         /// </summary>
         private static HdlDeviceBindLogic m_Current = null;
-        /// <summary>
-        /// 璁惧缁戝畾鐨勯�昏緫
+        /// <summary>
+        /// 璁惧缁戝畾鐨勯�昏緫
         /// </summary>
-        public static HdlDeviceBindLogic Current
-        {
-            get
-            {
-                if (m_Current == null)
-                {
-                    m_Current = new HdlDeviceBindLogic();
-                }
-                return m_Current;
-            }
-        }
-
-        #endregion
-
-        #region 鈻� 鑾峰彇璁惧涓嬮潰缁戝畾鐨勮澶嘷____________
-
-        /// <summary>
-        /// 鑾峰彇璁惧涓嬮潰缁戝畾鐨勮澶�(閿欒鏃惰繑鍥瀗ull),杩欎釜鏄粰pir浼犳劅鍣ㄧ敤鐨�
-        /// </summary>
-        /// <param name="mainDevice">璁惧瀵硅薄</param>
-        /// <returns></returns>
-        public List<CommonDevice> GetBindTargetDevice(CommonDevice mainDevice)
-        {
-            var result = this.GetDeviceBindAsync(mainDevice);
-            if (result == null || result.getAllBindResponseData == null)
-            {
-                //鑾峰彇璁惧鐨勭粦瀹氱洰鏍囧け璐�
-                string msg = Language.StringByID(R.MyInternationalizationString.uGetDeviceBindTargetFail);
-                //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
-                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
-
-                this.ShowErrorMsg(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);
-                if (deviceTemp == null)
-                {
-                    continue;
-                }
-                listDevice.Add(deviceTemp);
-            }
-            return listDevice;
-        }
-
-        /// <summary>
-        ///鑾峰彇鎵�鏈夌粦瀹�
-        /// </summary>
-        public BindObj.GetDeviceBindResponseAllData GetDeviceBindAsync(CommonDevice device)
-        {
-            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
-            if (Common.Config.Instance.Home.IsVirtually == true)
-            {
-                var listBind = ModelData.DeviceModelDataLogic.Current.GetDeviceBindList(device, "Bind/GetDeviceBind");
-                return new BindObj.GetDeviceBindResponseAllData()
-                {
-                    getAllBindResponseData = new BindObj.GetDeviceBindResponseData
-                    {
-                        Result = 0,
-                        BindList = listBind
-                    }
-                };
-            }
-
-            var jObject = new JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5007 } };
-            string sendData = jObject.ToString();
-            //鍙戦��
-            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Bind/GetDeviceBind", sendData, "Bind/GetDeviceBind_Respon", 6);
-            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
-            {
-                return null;
-            }
-            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.GetDeviceBindResponseData>(result.ReceiptData);
-            return new BindObj.GetDeviceBindResponseAllData() { getAllBindResponseData = tempData };
-        }
-
-        #endregion
-
-        #region 鈻� 鎵ц缁戝畾璁惧鐩爣___________________
-
-        /// <summary>
-        /// 缁戝畾璁惧鐨勭洰鏍�(杩斿洖鎴愬姛璁剧疆鐨勮澶�,閿欒鏃讹紝杩斿洖null)
-        /// </summary>
-        /// <param name="mainDevice">璁惧瀵硅薄</param>
-        /// <param name="listDevice">瑕佺粦瀹氱殑鐩爣璁惧</param>
-        /// <param name="BindCluster">BindCluster</param>
-        /// <returns></returns>
-        public List<CommonDevice> BindDeviceTarget(CommonDevice mainDevice, List<CommonDevice> listDevice, int BindCluster = 6)
-        {
-            if (listDevice.Count == 0)
-            {
-                return new List<CommonDevice>();
-            }
-
-            var dicDevice = new Dictionary<string, CommonDevice>();
-
-            //缁勮鏁版嵁
-            var addData = new IASZone.AddBindData();
-            addData.DeviceAddr = mainDevice.DeviceAddr;
-            addData.Epoint = mainDevice.DeviceEpoint;
-            foreach (var device in listDevice)
-            {
-                var info = new IASZone.AddBindListObj();
-                info.BindCluster = BindCluster;
-                info.BindMacAddr = device.DeviceAddr;
-                info.BindEpoint = device.DeviceEpoint;
-                info.BindType = 0;
-
-                addData.BindList.Add(info);
-
-                //杩斿洖鎴愬姛璁惧鐨勬椂鍊欎娇鐢�
-                string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
-                dicDevice[mainkeys] = device;
-            }
-            //鎵ц缁戝畾
-            var result = this.AddDeviceBindAsync(addData);
-            if (result == null || result.addedDeviceBindResponseData == null)
-            {
-                //缁戝畾鐩爣璁剧疆澶辫触
-                string msg = Language.StringByID(R.MyInternationalizationString.uSetBindTargetsFail);
-                //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
-                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
-
-                this.ShowErrorMsg(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);
-                if (dicDevice.ContainsKey(mainkeys) == true)
-                {
-                    listSuccess.Add(dicDevice[mainkeys]);
-                }
-            }
-
-            if (listSuccess.Count == 0)
-            {
-                //缁戝畾鐩爣璁剧疆澶辫触
-                string msg = Language.StringByID(R.MyInternationalizationString.uSetBindTargetsFail);
-                this.ShowTipMsg(msg);
-            }
-            return listSuccess;
-        }
-
-        /// <summary>
-        ///璁惧缁戝畾
-        /// </summary>
-        public BindObj.AddedDeviceBindResponseAllData AddDeviceBindAsync(BindObj.AddBindData addBindData)
-        {
-            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
-            if (Common.Config.Instance.Home.IsVirtually == true)
-            {
-                return ModelData.DeviceModelDataLogic.Current.AddDeviceBindList(addBindData, "Bind/GetDeviceBind");
-            }
-
-            var device = Common.LocalDevice.Current.GetDevice(addBindData.DeviceAddr, addBindData.Epoint);
-            //鑾峰彇鍙戦�佺殑鍛戒护瀛楃
-            var sendData = this.GetAddDeviceListBindCommandText(addBindData);
-            //鍙戦��
-            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Bind/SetBind", sendData, "Bind/SetBind_Respon", 20);
-            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
-            {
-                return null;
-            }
-
-            //淇敼缂撳瓨
-            ModelData.DeviceModelDataLogic.Current.AddDeviceBindList(addBindData, "Bind/GetDeviceBind");
-
-            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.AddedDeviceBindResponseData>(result.ReceiptData);
-            return new BindObj.AddedDeviceBindResponseAllData() { addedDeviceBindResponseData = tempData };
-        }
-
-        /// <summary>
-        /// 鑾峰彇娣诲姞璁惧缁戝畾鐨勫懡浠ゅ瓧绗�
-        /// </summary>
-        /// <param name="addBindData"></param>
-        /// <returns></returns>
-        public string GetAddDeviceListBindCommandText(BindObj.AddBindData addBindData)
-        {
-            var jObject = new JObject { { "DeviceAddr", addBindData.DeviceAddr }, { "Epoint", addBindData.Epoint }, { "Cluster_ID", 0 }, { "Command", 5001 } };
-            var bindList = new JArray { };
-            foreach (var bindInfo in addBindData.BindList)
-            {
-                if (bindInfo.BindType == 0)
-                {
-                    var dInfo = new JObject{{ "BindMacAddr",bindInfo.BindMacAddr},{ "BindEpoint", bindInfo.BindEpoint} ,
-                            { "BindCluster", bindInfo.BindCluster} ,{ "BindType",bindInfo.BindType}};
-                    bindList.Add(dInfo);
-                }
-                else if (bindInfo.BindType == 1)
-                {
-                    var dInfo = new JObject{{ "BindCluster", bindInfo.BindCluster} ,{ "BindType",bindInfo.BindType},
-                            { "BindScenesId", bindInfo.BindScenesId}};
-                    bindList.Add(dInfo);
-                }
-            }
-            var data = new JObject { { "BindName", addBindData.BindName }, { "BindList", bindList } };
-            jObject.Add("Data", data);
-            return jObject.ToString();
-        }
-
-        #endregion
-
-        #region 鈻� 鍒犻櫎璁惧缁戝畾鐨勭洰鏍嘷________________
-
-        /// <summary>
-        /// 鍒犻櫎璁惧缁戝畾鐨勭洰鏍�
-        /// </summary>
-        /// <param name="mainDevice">璁惧瀵硅薄</param>
-        /// <param name="deleteDevice">瑕佸垹闄ょ殑缁戝畾鐩爣璁惧</param>
-        /// <param name="BindCluster">BindCluster</param>
-        /// <returns></returns>
-        public bool DeleteDeviceTarget(CommonDevice mainDevice, CommonDevice deleteDevice, int BindCluster = 6)
-        {
-            //缁勮鏁版嵁
-            var deleteData = new IASZone.DelDeviceBindData();
-            deleteData.DeviceAddr = mainDevice.DeviceAddr;
-            deleteData.Epoint = mainDevice.DeviceEpoint;
-
-            var info = new IASZone.RemoveBindListObj();
-            info.BindCluster = BindCluster;
-            info.BindMacAddr = deleteDevice.DeviceAddr;
-            info.BindEpoint = deleteDevice.DeviceEpoint;
-            info.BindType = 0;
-
-            deleteData.RemoveBindList.Add(info);
-
-            //鎵ц鍒犻櫎
-            var result = this.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 false;
-            }
-
-            foreach (var data in result.delDeviceBindResponseData.RemoveBindList)
-            {
-                //0:鎴愬姛  1:璁惧涓嶅湪缁戝畾鍒楄〃涓� 锛屼篃鍙互浠h〃鎴愬姛
-                if (data.Result == 0 || data.Result == 1 || data.Result == 5)
-                {
-                    return true;
-                }
-                //3:澶辫触锛屽湪绛夊緟鑺傜偣璁惧纭鏄惁瑙i櫎缁戝畾鎴愬姛
-                else if (data.Result == 3)
-                {
-                    //鍏朵粬缁戝畾鐩爣姝e湪鍒犻櫎涓紝璇风◢鍚庡啀璇�
-                    string msg = Language.StringByID(R.MyInternationalizationString.uOtherBindTargetsIsDelettingPleaseWait);
-                    this.ShowErrorMsg(msg);
-                    return false;
-                }
-                //2锛氭湭鐭ワ紝鐢辫妭鐐硅澶囧弽棣堝彂閫佲�淏ind/BindResult鈥濅富棰樻秷鎭‘瀹氭槸鍚︽垚鍔�
-                else if (data.Result == 2)
-                {
-                    if (result.removeBindResultResponseData == null)
-                    {
-                        //鍒犻櫎缁戝畾鐩爣澶辫触
-                        string msg = Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail);
-                        this.ShowErrorMsg(msg);
-                        return false;
-                    }
-                    else
-                    {
-                        //鎴愬姛
-                        if (result.removeBindResultResponseData.Result == 0)
-                        {
-                            return true;
-                        }
-                        //136锛氭帶鍒惰澶囨湰鍦扮粦瀹氬垪琛ㄤ腑鏃犳缁戝畾
-                        else if (result.removeBindResultResponseData.Result == 136)
-                        {
-                            //杩欎釜鍙互褰撳仛鎴愬姛
-                            return true;
-                        }
-                        else
-                        {
-                            //鍒犻櫎缁戝畾鐩爣澶辫触
-                            string msg = Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail);
-                            this.ShowErrorMsg(msg);
-                            return false;
-                        }
-                    }
-                }
-            }
-            return false;
-        }
-
+        public static HdlDeviceBindLogic Current
+        {
+            get
+            {
+                if (m_Current == null)
+                {
+                    m_Current = new HdlDeviceBindLogic();
+                }
+                return m_Current;
+            }
+        }
+
         #endregion
-
+
+        #region 鈻� 鑾峰彇璁惧涓嬮潰缁戝畾鐨勮澶嘷____________
+
+        /// <summary>
+        /// 鑾峰彇璁惧涓嬮潰缁戝畾鐨勮澶�(閿欒鏃惰繑鍥瀗ull),杩欎釜鏄粰pir浼犳劅鍣ㄧ敤鐨�
+        /// </summary>
+        /// <param name="mainDevice">璁惧瀵硅薄</param>
+        /// <returns></returns>
+        public List<CommonDevice> GetBindTargetDevice(CommonDevice mainDevice)
+        {
+            var result = this.GetDeviceBindAsync(mainDevice);
+            if (result == null || result.getAllBindResponseData == null)
+            {
+                //鑾峰彇璁惧鐨勭粦瀹氱洰鏍囧け璐�
+                string msg = Language.StringByID(R.MyInternationalizationString.uGetDeviceBindTargetFail);
+                //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+
+                this.ShowErrorMsg(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);
+                if (deviceTemp == null)
+                {
+                    continue;
+                }
+                listDevice.Add(deviceTemp);
+            }
+            return listDevice;
+        }
+
+        /// <summary>
+        ///鑾峰彇鎵�鏈夌粦瀹�
+        /// </summary>
+        public BindObj.GetDeviceBindResponseAllData GetDeviceBindAsync(CommonDevice device)
+        {
+            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                var listBind = ModelData.DeviceModelDataLogic.Current.GetDeviceBindList(device, "Bind/GetDeviceBind");
+                return new BindObj.GetDeviceBindResponseAllData()
+                {
+                    getAllBindResponseData = new BindObj.GetDeviceBindResponseData
+                    {
+                        Result = 0,
+                        BindList = listBind
+                    }
+                };
+            }
+
+            var jObject = new JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5007 } };
+            string sendData = jObject.ToString();
+            //鍙戦��
+            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Bind/GetDeviceBind", sendData, "Bind/GetDeviceBind_Respon", 6);
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return null;
+            }
+            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.GetDeviceBindResponseData>(result.ReceiptData);
+            return new BindObj.GetDeviceBindResponseAllData() { getAllBindResponseData = tempData };
+        }
+
+        #endregion
+
+        #region 鈻� 鎵ц缁戝畾璁惧鐩爣___________________
+
+        /// <summary>
+        /// 缁戝畾璁惧鐨勭洰鏍�(杩斿洖鎴愬姛璁剧疆鐨勮澶�,閿欒鏃讹紝杩斿洖null)
+        /// </summary>
+        /// <param name="mainDevice">璁惧瀵硅薄</param>
+        /// <param name="listDevice">瑕佺粦瀹氱殑鐩爣璁惧</param>
+        /// <param name="BindCluster">BindCluster</param>
+        /// <returns></returns>
+        public List<CommonDevice> BindDeviceTarget(CommonDevice mainDevice, List<CommonDevice> listDevice, int BindCluster = 6)
+        {
+            if (listDevice.Count == 0)
+            {
+                return new List<CommonDevice>();
+            }
+
+            var dicDevice = new Dictionary<string, CommonDevice>();
+
+            //缁勮鏁版嵁
+            var addData = new IASZone.AddBindData();
+            addData.DeviceAddr = mainDevice.DeviceAddr;
+            addData.Epoint = mainDevice.DeviceEpoint;
+            foreach (var device in listDevice)
+            {
+                var info = new IASZone.AddBindListObj();
+                info.BindCluster = BindCluster;
+                info.BindMacAddr = device.DeviceAddr;
+                info.BindEpoint = device.DeviceEpoint;
+                info.BindType = 0;
+
+                addData.BindList.Add(info);
+
+                //杩斿洖鎴愬姛璁惧鐨勬椂鍊欎娇鐢�
+                string mainkeys = Common.LocalDevice.Current.GetDeviceMainKeys(device);
+                dicDevice[mainkeys] = device;
+            }
+            //鎵ц缁戝畾
+            var result = this.AddDeviceBindAsync(addData);
+            if (result == null || result.addedDeviceBindResponseData == null)
+            {
+                //缁戝畾鐩爣璁剧疆澶辫触
+                string msg = Language.StringByID(R.MyInternationalizationString.uSetBindTargetsFail);
+                //鎷兼帴涓娿�愮綉鍏冲洖澶嶈秴鏃躲�戠殑Msg
+                msg = UserCenterLogic.CombineGatewayTimeOutMsg(msg, result);
+
+                this.ShowErrorMsg(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);
+                if (dicDevice.ContainsKey(mainkeys) == true)
+                {
+                    listSuccess.Add(dicDevice[mainkeys]);
+                }
+            }
+
+            if (listSuccess.Count == 0)
+            {
+                //缁戝畾鐩爣璁剧疆澶辫触
+                string msg = Language.StringByID(R.MyInternationalizationString.uSetBindTargetsFail);
+                this.ShowTipMsg(msg);
+            }
+            return listSuccess;
+        }
+
+        /// <summary>
+        ///璁惧缁戝畾
+        /// </summary>
+        public BindObj.AddedDeviceBindResponseAllData AddDeviceBindAsync(BindObj.AddBindData addBindData)
+        {
+            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                return ModelData.DeviceModelDataLogic.Current.AddDeviceBindList(addBindData, "Bind/GetDeviceBind");
+            }
+
+            var device = Common.LocalDevice.Current.GetDevice(addBindData.DeviceAddr, addBindData.Epoint);
+            //鑾峰彇鍙戦�佺殑鍛戒护瀛楃
+            var sendData = this.GetAddDeviceListBindCommandText(addBindData);
+            //鍙戦��
+            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Bind/SetBind", sendData, "Bind/SetBind_Respon", 20);
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return null;
+            }
+
+            //淇敼缂撳瓨
+            ModelData.DeviceModelDataLogic.Current.AddDeviceBindList(addBindData, "Bind/GetDeviceBind");
+
+            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.AddedDeviceBindResponseData>(result.ReceiptData);
+            return new BindObj.AddedDeviceBindResponseAllData() { addedDeviceBindResponseData = tempData };
+        }
+
+        /// <summary>
+        /// 鑾峰彇娣诲姞璁惧缁戝畾鐨勫懡浠ゅ瓧绗�
+        /// </summary>
+        /// <param name="addBindData"></param>
+        /// <returns></returns>
+        public string GetAddDeviceListBindCommandText(BindObj.AddBindData addBindData)
+        {
+            var jObject = new JObject { { "DeviceAddr", addBindData.DeviceAddr }, { "Epoint", addBindData.Epoint }, { "Cluster_ID", 0 }, { "Command", 5001 } };
+            var bindList = new JArray { };
+            foreach (var bindInfo in addBindData.BindList)
+            {
+                if (bindInfo.BindType == 0)
+                {
+                    var dInfo = new JObject{{ "BindMacAddr",bindInfo.BindMacAddr},{ "BindEpoint", bindInfo.BindEpoint} ,
+                            { "BindCluster", bindInfo.BindCluster} ,{ "BindType",bindInfo.BindType}};
+                    bindList.Add(dInfo);
+                }
+                else if (bindInfo.BindType == 1)
+                {
+                    var dInfo = new JObject{{ "BindCluster", bindInfo.BindCluster} ,{ "BindType",bindInfo.BindType},
+                            { "BindScenesId", bindInfo.BindScenesId}};
+                    bindList.Add(dInfo);
+                }
+            }
+            var data = new JObject { { "BindName", addBindData.BindName }, { "BindList", bindList } };
+            jObject.Add("Data", data);
+            return jObject.ToString();
+        }
+
+        #endregion
+
         #region 鈻� 鍒犻櫎璁惧缁戝畾鐨勭洰鏍嘷________________
-
+
+        /// <summary>
+        /// 鍒犻櫎璁惧缁戝畾鐨勭洰鏍�
+        /// </summary>
+        /// <param name="mainDevice">璁惧瀵硅薄</param>
+        /// <param name="deleteDevice">瑕佸垹闄ょ殑缁戝畾鐩爣璁惧</param>
+        /// <param name="BindCluster">BindCluster</param>
+        /// <returns></returns>
+        public bool DeleteDeviceTarget(CommonDevice mainDevice, CommonDevice deleteDevice, int BindCluster = 6)
+        {
+            //缁勮鏁版嵁
+            var deleteData = new IASZone.DelDeviceBindData();
+            deleteData.DeviceAddr = mainDevice.DeviceAddr;
+            deleteData.Epoint = mainDevice.DeviceEpoint;
+
+            var info = new IASZone.RemoveBindListObj();
+            info.BindCluster = BindCluster;
+            info.BindMacAddr = deleteDevice.DeviceAddr;
+            info.BindEpoint = deleteDevice.DeviceEpoint;
+            info.BindType = 0;
+
+            deleteData.RemoveBindList.Add(info);
+
+            //鎵ц鍒犻櫎
+            var result = this.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 false;
+            }
+
+            foreach (var data in result.delDeviceBindResponseData.RemoveBindList)
+            {
+                //0:鎴愬姛  1:璁惧涓嶅湪缁戝畾鍒楄〃涓� 锛屼篃鍙互浠h〃鎴愬姛
+                if (data.Result == 0 || data.Result == 1 || data.Result == 5)
+                {
+                    return true;
+                }
+                //3:澶辫触锛屽湪绛夊緟鑺傜偣璁惧纭鏄惁瑙i櫎缁戝畾鎴愬姛
+                else if (data.Result == 3)
+                {
+                    //鍏朵粬缁戝畾鐩爣姝e湪鍒犻櫎涓紝璇风◢鍚庡啀璇�
+                    string msg = Language.StringByID(R.MyInternationalizationString.uOtherBindTargetsIsDelettingPleaseWait);
+                    this.ShowErrorMsg(msg);
+                    return false;
+                }
+                //2锛氭湭鐭ワ紝鐢辫妭鐐硅澶囧弽棣堝彂閫佲�淏ind/BindResult鈥濅富棰樻秷鎭‘瀹氭槸鍚︽垚鍔�
+                else if (data.Result == 2)
+                {
+                    if (result.removeBindResultResponseData == null)
+                    {
+                        //鍒犻櫎缁戝畾鐩爣澶辫触
+                        string msg = Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail);
+                        this.ShowErrorMsg(msg);
+                        return false;
+                    }
+                    else
+                    {
+                        //鎴愬姛
+                        if (result.removeBindResultResponseData.Result == 0)
+                        {
+                            return true;
+                        }
+                        //136锛氭帶鍒惰澶囨湰鍦扮粦瀹氬垪琛ㄤ腑鏃犳缁戝畾
+                        else if (result.removeBindResultResponseData.Result == 136)
+                        {
+                            //杩欎釜鍙互褰撳仛鎴愬姛
+                            return true;
+                        }
+                        else
+                        {
+                            //鍒犻櫎缁戝畾鐩爣澶辫触
+                            string msg = Language.StringByID(R.MyInternationalizationString.uDeleteBindTargetsFail);
+                            this.ShowErrorMsg(msg);
+                            return false;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+
         /// <summary>
         /// 鍒犻櫎璁惧缁戝畾鐨勭洰鏍�
         /// </summary>
@@ -684,78 +680,78 @@
         /// <summary>
         /// 璇诲彇闈㈡澘鐨勯厤缃俊鎭�
         /// </summary>
-        public Panel.PanelConfigureInfoResponAllData ReadPanelConfigureInfoAsync(CommonDevice device)
-        {
-            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
-            if (Common.Config.Instance.Home.IsVirtually == true)
-            {
-                return ModelData.DeviceModelDataLogic.Current.ReadPanelConfigureKeyModel(device);
-            }
-
-            var JObject = new JObject {{ "DeviceAddr",device.DeviceAddr },{ "Epoint", device.DeviceEpoint },
-                { "Cluster_ID", (int)Cluster_ID.HdlKey },{ "Command", 108 }};
-            var attriBute = new JArray { new JObject { { "AttriButeId", (int)AttriButeId.HdlKey } } };
-            var data = new JObject { { "AttriBute", attriBute } };
-            JObject.Add("Data", data);
-
-            //鍙戦�佹暟鎹�
-            var sendData = JObject.ToString();
-            string receiptTopic = "DeviceStatusReport/" + device.DeviceAddr + "/" + device.DeviceEpoint + "/" + (int)Cluster_ID.HdlKey + "/" + (int)AttriButeId.HdlKey;
-            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "GetDeviceStatus", sendData, receiptTopic);
-            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
-            {
-                return null;
-            }
-
-            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceStatusReportData>(result.ReceiptData);
-            return new Panel.PanelConfigureInfoResponAllData { deviceStatusReportData = tempData };
-        }
-
-        /// <summary>
-        /// 鑾峰彇閰嶇疆闈㈡澘鍔熻兘鐨勫懡浠ゅ瓧绗�
-        /// </summary>
+        public Panel.PanelConfigureInfoResponAllData ReadPanelConfigureInfoAsync(CommonDevice device)
+        {
+            //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
+            if (Common.Config.Instance.Home.IsVirtually == true)
+            {
+                return ModelData.DeviceModelDataLogic.Current.ReadPanelConfigureKeyModel(device);
+            }
+
+            var JObject = new JObject {{ "DeviceAddr",device.DeviceAddr },{ "Epoint", device.DeviceEpoint },
+                { "Cluster_ID", (int)Cluster_ID.HdlKey },{ "Command", 108 }};
+            var attriBute = new JArray { new JObject { { "AttriButeId", (int)AttriButeId.HdlKey } } };
+            var data = new JObject { { "AttriBute", attriBute } };
+            JObject.Add("Data", data);
+
+            //鍙戦�佹暟鎹�
+            var sendData = JObject.ToString();
+            string receiptTopic = "DeviceStatusReport/" + device.DeviceAddr + "/" + device.DeviceEpoint + "/" + (int)Cluster_ID.HdlKey + "/" + (int)AttriButeId.HdlKey;
+            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "GetDeviceStatus", sendData, receiptTopic);
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return null;
+            }
+
+            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<Panel.DeviceStatusReportData>(result.ReceiptData);
+            return new Panel.PanelConfigureInfoResponAllData { deviceStatusReportData = tempData };
+        }
+
+        /// <summary>
+        /// 鑾峰彇閰嶇疆闈㈡澘鍔熻兘鐨勫懡浠ゅ瓧绗�
+        /// </summary>
         /// <param name="device">璁惧瀵硅薄</param>
         /// <param name="value">閿��</param>
         /// <param name="clusterID">闀濱D</param>
-        /// <returns></returns>
+        /// <returns></returns>
         public string GetConfigureHdlKeyCommandText(string DeviceAddr, int DeviceEpoint, Panel.KeyMode value, int clusterID = 6)
-        {
+        {
             var jObject = new JObject { { "DeviceAddr", DeviceAddr }, { "Epoint", DeviceEpoint }, { "Cluster_ID", clusterID }, { "Command", 120 } };
             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
-    }
+        }
+
+        #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
+    }
 }

--
Gitblit v1.8.0