From dee21bf452a8979d0515d13e534fbb69ed9715dd Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期二, 01 九月 2020 15:33:13 +0800
Subject: [PATCH] 上传一个版本

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs |   74 +++++++++++++++++++++++-------------
 1 files changed, 47 insertions(+), 27 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
index d799cb9..3fade11 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
@@ -197,33 +197,6 @@
         }
 
         /// <summary>
-        ///璁惧缁戝畾銆愪竴瀵逛竴 缁戝畾锛屼竴涓寜閿洖璺彧鑳界粦瀹氫竴涓澶囥��
-        /// </summary>
-        public BindObj.AddedDeviceBindResponseAllData AddDeviceSingleBindAsync(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/SetSingleBind", sendData, "Bind/SetSingleBind_Respon", 20);
-            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
-            {
-                return null;
-            }
-            //淇敼缂撳瓨
-            TemplateData.TemplateDeviceDataLogic.Current.AddDeviceBindList(addBindData, result.JsonData[0]);
-
-            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.AddedDeviceBindResponseData>(result.ReceiptData);
-            return new BindObj.AddedDeviceBindResponseAllData() { addedDeviceBindResponseData = tempData };
-        }
-
-        /// <summary>
         /// 鑾峰彇娣诲姞璁惧缁戝畾鐨勫懡浠ゅ瓧绗�
         /// </summary>
         /// <param name="addBindData"></param>
@@ -252,6 +225,53 @@
             return jObject.ToString();
         }
 
+        /// <summary>
+        ///璁惧缁戝畾銆愪竴瀵逛竴 缁戝畾锛屼竴涓寜閿洖璺彧鑳界粦瀹氫竴涓澶囥��
+        /// </summary>
+        public BindObj.AddedDeviceSingleBindResponseAllData AddDeviceSingleBindAsync(BindObj.AddSingleBindData addSingleBindData)
+        {
+            var device = Common.LocalDevice.Current.GetDevice(addSingleBindData.DeviceAddr, addSingleBindData.Epoint);
+            //鑾峰彇鍙戦�佺殑鍛戒护瀛楃
+            var sendData = this.GetAddDeviceListSingleBindCommandText(addSingleBindData);
+            //鍙戦�� 
+            var result = HdlDeviceCommonLogic.Current.SendJobjectDataToGateway(device, "Bind/SetSingleBind", sendData, "Bind/SetSingleBind_Respon", 20);
+            if (result.ErrorMsg != null || result.ErrorMsgDiv == 0)
+            {
+                return null;
+            }
+
+            var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.AddedDeviceSingleBindResponseData>(result.ReceiptData);
+            return new BindObj.AddedDeviceSingleBindResponseAllData() { addedDeviceSingleBindResponseData = tempData };
+        }
+
+        /// <summary>
+        /// 鑾峰彇娣诲姞璁惧缁戝畾鐨勫懡浠ゅ瓧绗�
+        /// </summary>
+        /// <param name="addBindData"></param>
+        /// <returns></returns>
+        public string GetAddDeviceListSingleBindCommandText(BindObj.AddSingleBindData addSingleBindData)
+        {
+            var jObject = new JObject { { "DeviceAddr", addSingleBindData.DeviceAddr }, { "Epoint", addSingleBindData.Epoint }, { "Cluster_ID", 0 }, { "Command", 5020 } };
+            var data = new JObject { };
+            var bindClusterList = new JArray { };
+            foreach (var cluster in addSingleBindData.BindClusterList)
+            {
+                bindClusterList.Add(cluster);
+            }
+            if (addSingleBindData.BindType == 0)
+            {
+                data = new JObject { { "BindName", addSingleBindData.BindName }, { "BindType", addSingleBindData.BindType }, { "BindClusterList", bindClusterList }, { "BindMacAddr", addSingleBindData.BindMacAddr }, { "BindEpoint", addSingleBindData.BindEpoint } };
+            }
+            else if (addSingleBindData.BindType == 1)
+            {
+                data = new JObject { { "BindName", addSingleBindData.BindName }, { "BindType", addSingleBindData.BindType }, { "BindClusterList", bindClusterList }, { "BindScenesId", addSingleBindData.BindScenesId } };
+
+            }
+            jObject.Add("Data", data);
+            return jObject.ToString();
+        }
+
+
         #endregion
 
         #region 鈻� 鍒犻櫎璁惧缁戝畾鐨勭洰鏍嘷________________

--
Gitblit v1.8.0