From ec34983e291d1c85284472a27109d55891f9a6b5 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期五, 07 八月 2020 16:20:16 +0800
Subject: [PATCH] 不是新代码,别 合并

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs |   56 ++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 44 insertions(+), 12 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
index 97a36c8..f5ac6ec 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlDeviceBindLogic.cs
@@ -76,7 +76,7 @@
             //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
             if (Common.Config.Instance.Home.IsVirtually == true)
             {
-                var listBind = ModelData.DeviceModelDataLogic.Current.GetDeviceBindList(device, "Bind/GetDeviceBind");
+                var listBind = TemplateData.TemplateDeviceDataLogic.Current.GetDeviceBindList(device);
                 return new BindObj.GetDeviceBindResponseAllData()
                 {
                     getAllBindResponseData = new BindObj.GetDeviceBindResponseData
@@ -177,7 +177,7 @@
             //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
             if (Common.Config.Instance.Home.IsVirtually == true)
             {
-                return ModelData.DeviceModelDataLogic.Current.AddDeviceBindList(addBindData, "Bind/GetDeviceBind");
+                return TemplateData.TemplateDeviceDataLogic.Current.AddDeviceBindList(addBindData, null);
             }
 
             var device = Common.LocalDevice.Current.GetDevice(addBindData.DeviceAddr, addBindData.Epoint);
@@ -191,7 +191,7 @@
             }
 
             //淇敼缂撳瓨
-            ModelData.DeviceModelDataLogic.Current.AddDeviceBindList(addBindData, "Bind/GetDeviceBind");
+            TemplateData.TemplateDeviceDataLogic.Current.AddDeviceBindList(addBindData, result.JsonData[0]);
 
             var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.AddedDeviceBindResponseData>(result.ReceiptData);
             return new BindObj.AddedDeviceBindResponseAllData() { addedDeviceBindResponseData = tempData };
@@ -420,7 +420,7 @@
             //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
             if (Common.Config.Instance.Home.IsVirtually == true)
             {
-                return ModelData.DeviceModelDataLogic.Current.DeleteDeviceBindList(delDeviceBindData);
+                return TemplateData.TemplateDeviceDataLogic.Current.DeleteDeviceBindList(delDeviceBindData);
             }
             var device = Common.LocalDevice.Current.GetDevice(delDeviceBindData.DeviceAddr, delDeviceBindData.Epoint);
             //鑾峰彇闇�瑕佸彂閫佺殑鏁版嵁
@@ -447,7 +447,7 @@
             }
 
             //淇敼缂撳瓨
-            ModelData.DeviceModelDataLogic.Current.DeleteDeviceBindList(delDeviceBindData);
+            TemplateData.TemplateDeviceDataLogic.Current.DeleteDeviceBindList(delDeviceBindData);
 
             return responseData;
         }
@@ -460,7 +460,7 @@
             //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
             if (Common.Config.Instance.Home.IsVirtually == true)
             {
-                return ModelData.DeviceModelDataLogic.Current.ClearDeviceAllBind(device);
+                return TemplateData.TemplateDeviceDataLogic.Current.ClearDeviceAllBind(device);
             }
 
             var jObject = new JObject { { "DeviceAddr", device.DeviceAddr }, { "Epoint", device.DeviceEpoint }, { "Cluster_ID", 0 }, { "Command", 5006 } };
@@ -472,7 +472,7 @@
             }
 
             //淇敼缂撳瓨
-            ModelData.DeviceModelDataLogic.Current.ClearDeviceAllBind(device);
+            TemplateData.TemplateDeviceDataLogic.Current.ClearDeviceAllBind(device);
 
             var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.ClearBindInfoResponseData>(result.ReceiptData);
             return new BindObj.ClearBindInfoResponseAllData { clearBindInfoResponseData = tempData };
@@ -533,7 +533,7 @@
                 return reResult;
             }
             //缃戝叧ID
-            string gatewayID = HdlGatewayLogic.Current.GetGatewayId(device.Gateway);
+            string gatewayID = device.Gateway.GwId;
             //閿欒涓婚
             string errorTopic = gatewayID + "/" + "Error_Respon";
             //妫�娴嬪璞$殑涓婚
@@ -543,6 +543,9 @@
             }
 
             bool canbreak = false;
+            BindObj.DelDeviceBindResponseData delDeviceBindData = null;
+            BindObj.RemoveBindResultResponseData removeBindResult = null;
+
             Action<string, string> receiptAction = (topic, message) =>
             {
                 var jobject = Newtonsoft.Json.Linq.JObject.Parse(message);
@@ -571,9 +574,38 @@
                             return;
                         }
                         reResult.listReceiptData[i] = jobject["Data"].ToString();
+
                         if (i == 0)
                         {
-                            //鍙湁鏄疊ind/RemoveBind_Respon涓婚,鎵嶈兘涓柇
+                            //"Bind/RemoveBind_Respon"涓婚
+                            delDeviceBindData = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.DelDeviceBindResponseData>(reResult.listReceiptData[i]);
+                        }
+                        else if (i == 1)
+                        {
+                            //"Bind/RemoveBindResult"涓婚
+                            removeBindResult = Newtonsoft.Json.JsonConvert.DeserializeObject<BindObj.RemoveBindResultResponseData>(reResult.listReceiptData[i]);
+                        }
+
+                        if (0 < delDeviceBindData.RemoveBindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 1).Count)
+                        {
+                            canbreak = true;
+                        }
+                        else if (0 < delDeviceBindData.RemoveBindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 3).Count)
+                        {
+                            if (removeBindResult != null)
+                            {
+                                canbreak = true;
+                            }
+                        }
+                        else if (0 < delDeviceBindData.RemoveBindList.FindAll((obj) => obj.BindType == 0 && obj.Result == 2).Count)
+                        {
+                            if (removeBindResult != null)
+                            {
+                                canbreak = true;
+                            }
+                        }
+                        else
+                        {
                             canbreak = true;
                         }
                     }
@@ -628,7 +660,7 @@
             //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
             if (Common.Config.Instance.Home.IsVirtually == true)
             {
-                return ModelData.DeviceModelDataLogic.Current.ConfigurePanelKeyModel(device, value, clusterID, "SetWritableValue");
+                return TemplateData.TemplateDeviceDataLogic.Current.ConfigurePanelKeyModel(device, value, clusterID, null);
             }
             //鑾峰彇鍙戦�佹暟鎹�
             var sendData = this.GetConfigureHdlKeyCommandText(device.DeviceAddr, device.DeviceEpoint, value, clusterID);
@@ -639,7 +671,7 @@
             }
 
             //淇敼缂撳瓨
-            ModelData.DeviceModelDataLogic.Current.ConfigurePanelKeyModel(device, value, clusterID, "SetWritableValue");
+            TemplateData.TemplateDeviceDataLogic.Current.ConfigurePanelKeyModel(device, value, clusterID, result.JsonData[0]);
 
             var tempData = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.SetWritableValueResponData>(result.ReceiptData);
             return new CommonDevice.SetWritableValueResponAllData { setWritableValueResponData = tempData };
@@ -653,7 +685,7 @@
             //濡傛灉褰撳墠浣忓畢鏄櫄鎷熶綇瀹�
             if (Common.Config.Instance.Home.IsVirtually == true)
             {
-                return ModelData.DeviceModelDataLogic.Current.ReadPanelConfigureKeyModel(device);
+                return TemplateData.TemplateDeviceDataLogic.Current.ReadPanelConfigureKeyModel(device);
             }
 
             var JObject = new JObject {{ "DeviceAddr",device.DeviceAddr },{ "Epoint", device.DeviceEpoint },

--
Gitblit v1.8.0