gxc
2020-01-02 34e965100d635346e2d4cd6e6013bdaed66b3004
ZigbeeApp/Shared/Common/Room.cs
old mode 100755 new mode 100644
@@ -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 @@
                    //设备(deviceUI)
                    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 ◆ 获取设备_________________________