From ecba45c93391066bc30c7bd602c3a7683fbb99a7 Mon Sep 17 00:00:00 2001
From: xm <1271024303@qq.com>
Date: 星期五, 31 七月 2020 10:56:12 +0800
Subject: [PATCH] 临时备份

---
 ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs |  109 +++++++++++++++++++++++++++---------------------------
 1 files changed, 54 insertions(+), 55 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/Device/DeviceListMainForm.cs
index 3683150..568ce9c 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(() =>
                 {
@@ -625,7 +625,7 @@
         {
             lock (dicRowInfo)
             {
-                Application.RunOnMainThread(() =>
+                HdlThreadLogic.Current.RunMain(() =>
                 {
                     if (this.listView == null)
                     {
@@ -717,7 +717,7 @@
             }
 
             //鑾峰彇鍏ㄩ儴璁惧
-            int result = LocalDevice.Current.SetDeviceToMemmoryByGateway(nowGateway);
+            int result = LocalDevice.Current.SetDeviceToMemmoryByGateway(nowGateway, false);
             if (this.Parent == null)
             {
                 return;
@@ -754,7 +754,7 @@
                 //鍒锋柊缃戝叧鍦ㄧ嚎鐘舵��
                 HdlGatewayLogic.Current.RefreshGatewayOnlineStatu(new List<ZbGateway>() { zbGateway });
 
-                Application.RunOnMainThread(() =>
+                HdlThreadLogic.Current.RunMain(() =>
                 {
                     if (this.gatewayViewRow != null && this.gatewayViewRow.zbGatewayId == selectGwId)
                     {
@@ -782,7 +782,7 @@
             }
             if (gateWay.GwId == this.gatewayViewRow.zbGatewayId)
             {
-                Application.RunOnMainThread(() =>
+                HdlThreadLogic.Current.RunMain(() =>
                 {
                     //鐩稿悓鐨勭姸鎬�,涓嶉渶瑕佸啀娆″埛鏂�
                     if (this.gatewayViewRow.isOnline != online)
@@ -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(50);
                     }
-
-                }, 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)
                         {
@@ -1026,14 +1034,27 @@
         {
             if (this.dicRowInfo.ContainsKey(deviceAddr) == true)
             {
-                var row = this.dicRowInfo[deviceAddr];
-                row.MenuRow?.RefreshControlInfo(true);
-                //鏄庣粏
-                if (row.dicDetailRow != null)
+                var rowInfo = this.dicRowInfo[deviceAddr];
+                //妫�娴嬭繖涓澶囨槸鍚﹁鍒犻櫎 2020.01.13鍙樻洿:杩藉姞Ota璁惧鐨勫垽鏂�
+                if (LocalDevice.Current.GetDevicesByMac(deviceAddr).Count == 0
+                    && LocalDevice.Current.GetOTADevice(deviceAddr) == null)
                 {
-                    foreach (var detailRow in row.dicDetailRow.Values)
+                    //绉婚櫎鎺т欢
+                    rowInfo.dicDetailRow = null;
+                    rowInfo.frameTable.RemoveFromParent();
+
+                    this.dicRowInfo.Remove(deviceAddr);
+                }
+                else
+                {
+                    //鍒锋柊璁惧淇℃伅
+                    rowInfo.MenuRow?.RefreshControlInfo(true);
+                    if (rowInfo.dicDetailRow != null)
                     {
-                        detailRow.RefreshControlInfo();
+                        foreach (var contr in rowInfo.dicDetailRow.Values)
+                        {
+                            contr?.RefreshControlInfo();
+                        }
                     }
                 }
             }
@@ -1099,30 +1120,8 @@
         {
             if (this.nowActionDeviceMac != null)
             {
-                var rowInfo = this.dicRowInfo[nowActionDeviceMac];
-                //妫�娴嬭繖涓澶囨槸鍚﹁鍒犻櫎 2020.01.13鍙樻洿:杩藉姞Ota璁惧鐨勫垽鏂�
-                if (Common.LocalDevice.Current.GetDevicesByMac(nowActionDeviceMac).Count == 0
-                    && Common.LocalDevice.Current.GetOTADevice(nowActionDeviceMac) == null)
-                {
-                    //绉婚櫎鎺т欢
-                    rowInfo.dicDetailRow = null;
-                    rowInfo.frameTable.RemoveFromParent();
-
-                    this.dicRowInfo.Remove(nowActionDeviceMac);
-                    rowInfo = null;
-                }
-                else
-                {
-                    //鍒锋柊璁惧淇℃伅
-                    rowInfo.MenuRow?.RefreshControlInfo(true);
-                    if (rowInfo.dicDetailRow != null)
-                    {
-                        foreach (var contr in rowInfo.dicDetailRow.Values)
-                        {
-                            contr?.RefreshControlInfo();
-                        }
-                    }
-                }
+                //鍒锋柊鎸囧畾璁惧琛岀殑淇℃伅
+                this.RefreshDeviceRow(this.nowActionDeviceMac);
             }
             //娓呯┖璁板綍
             this.nowActionDeviceMac = null;

--
Gitblit v1.8.0