From 34e965100d635346e2d4cd6e6013bdaed66b3004 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期四, 02 一月 2020 19:52:13 +0800
Subject: [PATCH] 2019.1.2-3

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

diff --git a/ZigbeeApp/Shared/Common/Room.cs b/ZigbeeApp/Shared/Common/Room.cs
old mode 100755
new mode 100644
index 0c202a7..9db970d
--- a/ZigbeeApp/Shared/Common/Room.cs
+++ b/ZigbeeApp/Shared/Common/Room.cs
@@ -69,7 +69,7 @@
 
         /// <summary>
         /// 娓╁害浼犳劅鍣�(璁惧涓婚敭)
-        /// </summary>   
+        /// </summary>
         public string TemperatrueDevice = string.Empty;
         /// <summary>
         /// 婀垮害浼犳劅鍣�(璁惧涓婚敭)
@@ -78,11 +78,11 @@
         /// <summary>
         /// 娓╁害
         /// </summary>
-        public double Temperatrue;
+        public decimal Temperatrue;
         /// <summary>
         /// 婀垮害
         /// </summary>
-        public double Humidity;
+        public decimal Humidity;
 
         /// <summary>
         /// 褰撳墠閫夋嫨鐨勬埧闂�
@@ -332,7 +332,7 @@
                         room.Name = $"{room.Name}";
                     }
                     Lists.Add(room);
-                   
+
                 }
             }
             Config.Instance.Home.InitFloor();
@@ -538,8 +538,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();
@@ -943,6 +956,31 @@
             this.DeleteDevice(device);
         }
 
+        /// <summary>
+        /// 鍒犻櫎鎴戠殑鍠滅埍鐨勮澶�
+        /// </summary>
+        /// <param name="device">瑕佸垹闄ょ殑璁惧瀵硅薄</param>
+        public void DeleteLoveDevice(CommonDevice device)
+        {
+            if (device == null)
+            {
+                return;
+            }
+            //鎴戠殑鍠滅埍
+            var loveRoom = this.GetLoveRoom();
+            if (loveRoom != null)
+            {
+                string deviceFile = device.FilePath;
+                //绉婚櫎缂撳瓨
+                if (loveRoom.DeviceUIFilePathList.Contains(deviceFile) == false)
+                {
+                    return;
+                }
+                loveRoom.DeviceUIFilePathList.Remove(deviceFile);
+                loveRoom.DeviceUIList.RemoveAll((obj) => obj.FileName == deviceFile);
+            }
+        }
+
         #endregion
 
         #region 鈼� 鑾峰彇璁惧_________________________

--
Gitblit v1.8.0