From 4b378188ce972df432b23d9cb73babb6cc0679c6 Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期五, 17 一月 2020 14:56:15 +0800
Subject: [PATCH] 合并代码 ver.10086

---
 ZigbeeApp/Shared/Common/Room.cs |  105 ++++++++++++++++++++++++++--------------------------
 1 files changed, 52 insertions(+), 53 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/Room.cs b/ZigbeeApp/Shared/Common/Room.cs
index d5612e4..02204db 100755
--- a/ZigbeeApp/Shared/Common/Room.cs
+++ b/ZigbeeApp/Shared/Common/Room.cs
@@ -448,6 +448,7 @@
             }
             Save();
             HdlAutoBackupLogic.AddOrEditorFile(room.FileName);
+            CurrentRoom.RefreshRoomListView();
             return true;
         }
 
@@ -688,6 +689,10 @@
         {
             foreach (var r in Lists)
             {
+                if(r.IsLove)
+                {
+                    continue;
+                }
                 foreach (var scene in r.SceneUIList)
                 {
                     if (scene.Id == sceneId)
@@ -723,7 +728,7 @@
                 System.Console.WriteLine(ex.Message);
                 return null;
             }
-            
+
         }
         /// <summary>
         /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂村悕绉�
@@ -1101,14 +1106,10 @@
             List<DeviceUI> deviceUIs = new List<DeviceUI> { };
             var dList = AllRoomDeviceUIList;
             var commonDeviceList = Common.LocalDevice.Current.listAllDevice;
-
-            if (dList.Count == 0)
-            {
-                return null;
-            }
+            
             foreach (var device in commonDeviceList)
             {
-                if (dList.Find((obj) => obj.CommonDevice == device) == null)
+                if (dList.Find((obj) => obj.CommonDevice.DeviceEpoint == device.DeviceEpoint && obj.CommonDevice.DeviceAddr == device.DeviceAddr) == null)
                 {
                     deviceUIs.Add(Common.LocalDevice.Current.GetDeviceUI(device));
                 }
@@ -1404,7 +1405,7 @@
             SceneUIList.Remove(sceneUI);
             SceneUIFilePathList.Remove(sceneUI.FileName);
             Save();
-            
+
             Global.DeleteFilebyHomeId(sceneUI.FileName);
             HdlAutoBackupLogic.DeleteFile(sceneUI.FileName);
         }
@@ -1422,6 +1423,10 @@
         {
             foreach (var r in Lists)
             {
+                if (r.IsLove)
+                {
+                    continue;
+                }
                 foreach (var sceneUI in r.SceneUIList)
                 {
                     if (sceneUI.Id == sceneId)
@@ -1525,51 +1530,45 @@
         /// </summary>
         public async System.Threading.Tasks.Task<bool> RefreshSceneUIList()
         {
-            return false;
-            //System.Console.WriteLine($"寮�濮嬭姹傜綉鍏冲満鏅�****{DateTime.Now.ToString("yyMMdd hhmmss fff")}*****");
-            //bool result = true;
-            //var sceneList = await ZigBee.Device.Scene.GetSceneListAsync();
-            //System.Console.WriteLine($"缁撴潫璇锋眰缃戝叧鍦烘櫙****{DateTime.Now.ToString("yyMMdd hhmmss fff")}*****");
-            //if (sceneList == null)
-            //{
-            //    return false;
-            //}
-            //List<int> sceneIDList = new List<int> { };
-            //System.Console.WriteLine($"寮�濮嬫湰鍦板満鏅�****{DateTime.Now.ToString("yyMMdd hhmmss fff")}*****");
-            //foreach (var scene in sceneList)
-            //{
-            //    if (scene == null)
-            //    {
-            //        continue;
-            //    }
-            //    sceneIDList.Add(scene.ScenesId);
-            //}
-            //foreach(var r in Lists)
-            //{
-            //    if(r.SceneUIList==null || r.SceneUIList.Count==0)
-            //    {
-            //        continue;
-            //    }
-            //    foreach(var rScene in r.SceneUIList)
-            //    {
-            //        if(rScene==null)
-            //        {
-            //            continue;
-            //        }
-            //        //var scene = sceneList.Find((obj) => rScene.ScenesId == obj.ScenesId);
-            //        if(sceneIDList.Contains(rScene.ScenesId)==false)
-            //        {
-            //            var removeResult = r.SceneUIList.Remove(rScene);
-            //            r.Save();
-            //            if (removeResult == false)
-            //            {
-            //                result = false;
-            //            }
-            //        }
-            //    }
-            //}
-            //System.Console.WriteLine($"缁撴潫鏈湴鍦烘櫙****{DateTime.Now.ToString("yyMMdd hhmmss fff")}*****");
-            //return result;
+            bool result = true;
+            var sceneList = await ZigBee.Device.Scene.GetSceneListAsync();
+            if (sceneList == null)
+            {
+                return false;
+            }
+            List<int> sceneIDList = new List<int> { };
+            foreach (var scene in sceneList)
+            {
+                if (scene == null)
+                {
+                    continue;
+                }
+                sceneIDList.Add(scene.ScenesId);
+            }
+            foreach (var r in Lists)
+            {
+                if(r.IsLove)
+                {
+                    continue;
+                }
+                if (r.SceneUIList == null || r.SceneUIList.Count == 0)
+                {
+                    continue;
+                }
+                foreach (var rScene in r.SceneUIList)
+                {
+                    if (rScene == null)
+                    {
+                        continue;
+                    }
+                    if (sceneIDList.Contains(rScene.Id) == false)
+                    { 
+                        r.RemoveScene(rScene);
+                        result = true;
+                    }
+                }
+            }
+            return result;
         }
 
         #endregion

--
Gitblit v1.8.0