From d87400af518ebc9274f4447f06476959c3aa5102 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期二, 14 七月 2020 16:29:42 +0800
Subject: [PATCH] Merge branch 'dev-tzy' into dev-2020xm

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs |   50 +++++++++++++++++++++++++++++---------------------
 1 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs
index 3683150..1c30f0e 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs
@@ -151,7 +151,7 @@
             listView.BeginHeaderRefreshingAction += () =>
             {
                 //鍒锋柊璁惧鐨勮瘽,涓婚〉闇�瑕侀噸鏂板埛鏂�
-                UserView.UserPage.Instance.RefreshForm = true;
+                UserView.UserPage.Instance.RefreshAllForm = true;
 
                 HdlThreadLogic.Current.RunThread(() =>
                 {
@@ -826,18 +826,31 @@
             string gwId = GatewayResourse.NowSelectGatewayId;
             HdlThreadLogic.Current.RunThread(() =>
             {
-                System.Threading.Thread.Sleep(2000);
-                //杩欓噷涓昏鍙槸鑾峰彇鍦ㄧ嚎鐘舵��
-                var list = LocalDevice.Current.GetDeviceOnlineList(gwId);
-                HdlThreadLogic.Current.RunMain(() =>
+                if (this.Parent == null) { return; }
+                //鑾峰彇璁惧鍒楄〃
+                var listDevice = Common.LocalDevice.Current.GetDeviceByGatewayID(gwId);
+                var listCheck = new List<string>();
+                foreach (var device in listDevice)
                 {
-                    for (int i = 0; i < list.Count; i++)
+                    if (this.Parent == null) { return; }
+                    if (listCheck.Contains(device.DeviceAddr) == false)
                     {
-                        //璁剧疆璁惧鍦ㄧ嚎鐘舵��
-                        this.ReceiveDeviceStatu(list[i]);
+                        //鍙涓�涓洖璺嵆鍙�
+                        listCheck.Add(device.DeviceAddr);
+                        var deviceInfo = Common.LocalDevice.Current.ReadDeviceEpointDeviceInfo(device);
+                        if (deviceInfo != null)
+                        {
+                            //鍙樻洿鍦ㄧ嚎鐘舵��
+                            device.IsOnline = deviceInfo.IsOnline;
+                            HdlThreadLogic.Current.RunMain(() =>
+                            {
+                                //璁剧疆璁惧鍦ㄧ嚎鐘舵��
+                                this.ReceiveDeviceStatu(device);
+                            }, ShowErrorMode.NO);
+                        }
+                        System.Threading.Thread.Sleep(30);
                     }
-
-                }, ShowErrorMode.NO);
+                }
             });
         }
 
@@ -861,13 +874,8 @@
             var localDevice = Common.LocalDevice.Current.GetDevice(mainkeys);
             if (localDevice != null)
             {
-                //鍦ㄧ嚎鐘舵�佷竴鏍风殑璇濓紝涓嶉渶瑕佸埛鏂�
-                if (localDevice.IsOnline != device.IsOnline)
-                {
-                    //淇濆瓨鐘舵��
-                    localDevice.IsOnline = device.IsOnline;
-                    localDevice.ReSave();
-                }
+                //淇濆瓨鐘舵��
+                localDevice.IsOnline = device.IsOnline;
             }
 
             rowInfo.MenuRow.IsOnline = Common.LocalDevice.Current.CheckDeviceIsOnline(device);
@@ -936,9 +944,9 @@
         /// <param name="list">ota璁惧</param>
         private void CheckDeviceNewVersion(List<OTADevice> list)
         {
-            HdlThreadLogic.Current.RunThread(async () =>
+            HdlThreadLogic.Current.RunThread(() =>
             {
-                await System.Threading.Tasks.Task.Delay(2000);
+                System.Threading.Thread.Sleep(2000);
                 foreach (var ota in list)
                 {
                     if (this.Parent == null)
@@ -946,7 +954,7 @@
                         return;
                     }
                     //娣诲姞鍗囩骇鍥轰欢淇℃伅(鎴愪笉鎴愬姛閮芥棤鎵�璋�)
-                    var result = await HdlFirmwareUpdateLogic.AddFirmwareVersionInfo(FirmwareLevelType.ZigbeeDevice, ota.HwVersion.ToString(), ota.ImgTypeId.ToString());
+                    var result = HdlFirmwareUpdateLogic.AddFirmwareVersionInfo(FirmwareLevelType.ZigbeeDevice, ota.HwVersion.ToString(), ota.ImgTypeId.ToString());
 
                     //鑾峰彇璁惧鏈�鏂扮増鏈�
                     var deviceFirmware = HdlFirmwareUpdateLogic.GetFirmwareMostVersionInfo(FirmwareLevelType.ZigbeeDevice,
@@ -960,7 +968,7 @@
                     }
 
                     //鎷ユ湁鏂扮増鏈�
-                    Application.RunOnMainThread(() =>
+                    HdlThreadLogic.Current.RunMain(() =>
                     {
                         if (this.dicRowInfo.ContainsKey(ota.DeviceAddr) == true)
                         {

--
Gitblit v1.8.0