From eb424d24e39bab4a245725f35deab3f234ea0f13 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期五, 13 十二月 2019 10:48:50 +0800
Subject: [PATCH] 2019.12.13

---
 ZigbeeApp/Shared/Common/Room.cs |   44 +++++++++++++++++++++++++++++++++-----------
 1 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/Room.cs b/ZigbeeApp/Shared/Common/Room.cs
old mode 100755
new mode 100644
index 495100a..4d255ea
--- a/ZigbeeApp/Shared/Common/Room.cs
+++ b/ZigbeeApp/Shared/Common/Room.cs
@@ -436,8 +436,21 @@
                     //璁惧锛坉eviceUI锛�
                     beforeRoom.DeviceUIList.Clear();
                     foreach (var deviceFilePath in beforeRoom.DeviceUIFilePathList)
-                    {
-                        beforeRoom.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(deviceFilePath));
+                    {
+                        var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(deviceFilePath));
+                        var tempDeviceUI = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceUI>(jsonInfo);
+                        if (tempDeviceUI != null)
+                        {
+                            var delCommon = tempDeviceUIList.Find((obj) => obj.CommonDevice != null && tempDeviceUI.CommonDevice != null && obj.CommonDevice.Type == tempDeviceUI.CommonDevice.Type && obj.CommonDevice.CommonDeviceAddrEpoint == tempDeviceUI.CommonDevice.CommonDeviceAddrEpoint);
+                            if (delCommon != null)
+                            {
+                                beforeRoom.DeviceUIList.Add(delCommon);
+                            }
+                            else
+                            {
+                                beforeRoom.AddDevice(deviceFilePath);
+                            }
+                        }
                     }
                     //鍦烘櫙(SceneUI)
                     beforeRoom.SceneUIList.Clear();
@@ -589,21 +602,25 @@
         /// </summary>
         /// <param name="id"></param>
         /// <returns></returns>
-        public  List<Room> GetRoomsByFloorId(string id)
+        public List<Room> GetRoomsByFloorId(string id)
         {
-            return Lists.FindAll((obj) => obj.FloorId==id);
+            if (Config.Instance.Home.FloorDics.Count == 0)
+            {
+                return Lists;
+            }
+            return Lists.FindAll((obj) => obj.FloorId == id);
         }
         /// <summary>
         /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂村悕绉�
         /// </summary>
         /// <param name="id"></param>
         /// <returns></returns>
-        public  List<string> GetRoomNamesByFloorId(string id)
+        public List<string> GetRoomNamesByFloorId(string id)
         {
             List<string> names = new List<string> { };
-            foreach(var r in Lists)
+            foreach (var r in Lists)
             {
-                if(r.FloorId==id)
+                if (r.FloorId == id)
                 {
                     names.Add(r.Name);
                 }
@@ -618,6 +635,10 @@
         /// <returns></returns>
         public  List<Room> GetRoomsByFloorIdAppendLoveRoom(string id)
         {
+            if (Config.Instance.Home.FloorDics.Count == 0)
+            {
+                return Lists;
+            }
             var r= Lists.FindAll((obj) => obj.FloorId == id);
             r.Insert(0, GetLoveRoom());
             return r;
@@ -757,8 +778,9 @@
         public void AddDevice(string deviceUIFilePath)
         {
             if (string.IsNullOrEmpty(deviceUIFilePath))
-            {
-                return;
+
+             {
+                 return;
             }
             var deviceUI = Common.LocalDevice.Current.GetDeviceUI(deviceUIFilePath);
             if (null == deviceUI.CommonDevice)
@@ -989,7 +1011,7 @@
                     return -1;
                 }
             }
-            
+
             var getSceneIdAllData = await ZigBee.Device.Scene.GetSceneNewIdAsync(sceneName);
             if (getSceneIdAllData == null || getSceneIdAllData.getSceneIdData == null)
             {
@@ -1474,6 +1496,6 @@
         }
 
         #endregion
-       
+
     }
 }

--
Gitblit v1.8.0