From a41a96b555f3aabf243741352bded5f28cd0ced5 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期二, 21 七月 2020 15:56:32 +0800
Subject: [PATCH] 新版本

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs |   54 +++++++++++++++++++++++++++++++++---------------------
 1 files changed, 33 insertions(+), 21 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs
index b428f18..7073c99 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceSearchForm.cs
@@ -175,7 +175,6 @@
             device.CurrentGateWayId = this.realGateway.GwId;
             //灏咲eviceInfo鐨勫睘鎬ц缃埌涓诲睘鎬т腑
             Common.LocalDevice.Current.SetDeviceInfoToMain(device, device);
-            Common.LocalDevice.Current.RefreshDeviceFunctionType(device, device, true);
 
             //娣诲姞璁惧鐨勭紦瀛�
             device.IsOnline = 1;
@@ -183,9 +182,6 @@
 
             //鍒锋柊瓒呮椂鏃堕棿
             this.waitDeviceTimeOut = 20;
-
-            //鑾峰彇璁惧鐨勫浐瀹氬睘鎬�
-            HdlDeviceFixedAttributeLogic.Current.SetAllFixedAttributeToDevice(device);
 
             //涓嶉渶瑕�200绔偣鐨勯偅涓澶�  2020.01.13 鍙樻洿:ota涔熷姞杩涙潵
             this.listNewDevice.Add(device);
@@ -222,26 +218,33 @@
                 this.realGateway.GwResDataAction -= this.AdjustGatewayResultData;
                 System.Threading.Thread.Sleep(200);
 
+                var listDevice = new List<CommonDevice>();
+                for (int i = 0; i < this.listNewDevice.Count; i++)
+                {
+                    var device = this.listNewDevice[i];
+                    if (device.DeviceAddr != this.listNewDevice[0].DeviceAddr)
+                    {
+                        continue;
+                    }
+                    listDevice.Add(device);
+                    //閲嶆柊鍙樻洿UI
+                    if (device is OTADevice)
+                    {
+                        continue;
+                    }
+                    device.IconPath = string.Empty;
+                    device.ReSave();
+
+                    //璁剧疆璁惧鍔熻兘绫诲瀷 (涓嶈兘鍦ㄦ帴鏀跺洖璺殑鍦版柟鍐欏叆,涓嶇劧缃戝叧鍙兘浼氳秴璐熻嵎)
+                    Common.LocalDevice.Current.RefreshDeviceFunctionType(device, device, true);
+                    //鑾峰彇璁惧鐨勫浐瀹氬睘鎬�
+                    HdlDeviceFixedAttributeLogic.Current.SetAllFixedAttributeToDevice(device);
+                    System.Threading.Thread.Sleep(100);
+                }
+
                 //鐩墠灏卞紕涓�涓�
                 HdlThreadLogic.Current.RunMain(() =>
                 {
-                    var listDevice = new List<CommonDevice>();
-                    for (int i = 0; i < this.listNewDevice.Count; i++)
-                    {
-                        var device = this.listNewDevice[i];
-                        if (device.DeviceAddr != this.listNewDevice[0].DeviceAddr)
-                        {
-                            continue;
-                        }
-                        listDevice.Add(device);
-                        //閲嶆柊鍙樻洿UI
-                        if (device is OTADevice)
-                        {
-                            continue;
-                        }
-                        device.IconPath = string.Empty;
-                        device.ReSave();
-                    }
                     //鏄剧ず璁惧淇℃伅鐢婚潰
                     this.ShowDeviceAddSuccessForm(listDevice);
                 });
@@ -440,6 +443,15 @@
             else if (topic == gatewayId + "/DeviceInComingRespon")
             {
                 this.topTimeOut = topMaxTime;
+
+                //璁惧鍏ョ綉鏃�,鏈夋椂鍊欑綉鍏充細涓婃姤铏氭嫙璁惧
+                var jobject = Newtonsoft.Json.Linq.JObject.Parse(resultData);
+                CommonDevice.DeviceInfoData info = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice.DeviceInfoData>(jobject["Data"].ToString());
+                if (info.DriveCode != 0)
+                {
+                    //涓嶉渶瑕佽櫄鎷熻澶�
+                    return 0;
+                }
                 //缃戝叧鏈�缁堜笂鎶ヨ妭鐐硅澶囦俊鎭�
                 this.btnProgressBar.SetValue(6, 6);
                 return 1;

--
Gitblit v1.8.0