From 427d1c7ecd04b03419eae157e32fe3367d8dffea Mon Sep 17 00:00:00 2001 From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local> Date: 星期四, 28 十一月 2019 09:53:25 +0800 Subject: [PATCH] 2019.11.28 --- ZigbeeApp/Shared/Common/Room.cs | 45 +++++++++++++++++++++++++-------------------- 1 files changed, 25 insertions(+), 20 deletions(-) diff --git a/ZigbeeApp/Shared/Common/Room.cs b/ZigbeeApp/Shared/Common/Room.cs old mode 100755 new mode 100644 index 8279080..c344624 --- a/ZigbeeApp/Shared/Common/Room.cs +++ b/ZigbeeApp/Shared/Common/Room.cs @@ -132,12 +132,6 @@ public bool IsSharedRoom = false; /// <summary> - /// 鏄惁鍙互鍒锋柊鎴块棿鏁版嵁浜� - /// 闇�瑕佺瓑鍒濆鍖栨湰鍦拌澶囨暟鎹悗鍦ㄥ彲浠ュ垵濮嬪寲鎴块棿鏁版嵁 - /// </summary> - public static bool CanInitAllRoom; - - /// <summary> /// 鑾峰彇鍠滅埍鎴块棿鐨勬墍鏈夎澶囪矾寰� /// </summary> /// <value>The love room device list.</value> @@ -282,10 +276,6 @@ /// </summary> public static void InitAllRoom() { - //if (CanInitAllRoom == false) - //{ - // return; - //} Lists.Clear(); if (Config.Instance.Home.RoomFilePathList.Contains("Room_Favorite.json") == false) { @@ -305,11 +295,13 @@ { if (room.IsSharedRoom) { - room.Name = $"({Language.StringByID(R.MyInternationalizationString.Shared)}){room.Name}"; + room.Name = $"{room.Name}"; } Lists.Add(room); + } } + Config.Instance.Home.InitFloor(); } /// <summary> @@ -339,7 +331,6 @@ } } homeTemp.Save(false); - CanInitAllRoom = true; InitAllRoom(); } @@ -445,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(); @@ -598,9 +602,9 @@ /// </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); + return Lists.FindAll((obj) => obj.FloorId == id); } /// <summary> /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂村悕绉� @@ -765,8 +769,9 @@ public void AddDevice(string deviceUIFilePath) { if (string.IsNullOrEmpty(deviceUIFilePath)) - { - return; + + { + return; } var deviceUI = Common.LocalDevice.Current.GetDeviceUI(deviceUIFilePath); if (null == deviceUI.CommonDevice) @@ -994,7 +999,7 @@ return -1; } } - + var getSceneIdAllData = await ZigBee.Device.Scene.GetSceneNewIdAsync(sceneName); if (getSceneIdAllData == null || getSceneIdAllData.getSceneIdData == null) { @@ -1480,6 +1485,6 @@ } #endregion - + } } -- Gitblit v1.8.0