From c6ff92e84b6cb2815cb98065ecb0ecf95d0689c3 Mon Sep 17 00:00:00 2001 From: WJC <wjc@hdlchina.com.cn> Date: 星期三, 15 一月 2020 09:42:29 +0800 Subject: [PATCH] 2020-01-15-1 --- ZigbeeApp/Shared/Common/Room.cs | 523 +++++++++++++++++++++++++++++---------------------------- 1 files changed, 263 insertions(+), 260 deletions(-) diff --git a/ZigbeeApp/Shared/Common/Room.cs b/ZigbeeApp/Shared/Common/Room.cs index 00f950b..871d687 100644 --- a/ZigbeeApp/Shared/Common/Room.cs +++ b/ZigbeeApp/Shared/Common/Room.cs @@ -44,7 +44,7 @@ { get { - return Config.Instance.Home.GetFloorNameById(FloorId); + return Config.Instance.Home.GetFloorNameById(FloorId); } } /// <summary> @@ -67,12 +67,12 @@ /// </summary> public Dictionary<string, string> FloorList = new Dictionary<string, string> { }; - /// <summary> - /// 娓╁害浼犳劅鍣�(璁惧涓婚敭) + /// <summary> + /// 娓╁害浼犳劅鍣�(璁惧涓婚敭) /// </summary> public string TemperatrueDevice = string.Empty; - /// <summary> - /// 婀垮害浼犳劅鍣�(璁惧涓婚敭) + /// <summary> + /// 婀垮害浼犳劅鍣�(璁惧涓婚敭) /// </summary> public string HumidityDevice = string.Empty; @@ -110,7 +110,7 @@ /// <summary> /// 鍠滅埍鎴块棿id /// </summary> - public const string LoveRoomId = "Favorite"; + public const string LoveRoomId= "Favorite"; /// <summary> /// 鏄惁鏄粯璁ゅ枩鐖辨埧闂� @@ -130,12 +130,6 @@ /// 娉細鍒嗕韩杩囨潵鐨勬埧闂翠笉鑳藉垹闄わ紝涓嶈兘缂栬緫璇ユ埧闂达紝涓嶈兘瀵硅澶囷紙鍔熻兘锛夈�佸満鏅繘琛屽鍒犳敼 /// </summary> public bool IsSharedRoom = false; - - /// <summary> - /// 鏄惁鍙互鍒锋柊鎴块棿鏁版嵁浜� - /// 闇�瑕佺瓑鍒濆鍖栨湰鍦拌澶囨暟鎹悗鍦ㄥ彲浠ュ垵濮嬪寲鎴块棿鏁版嵁 - /// </summary> - public static bool CanInitAllRoom; /// <summary> /// 鑾峰彇鍠滅埍鎴块棿鐨勬墍鏈夎澶囪矾寰� @@ -233,7 +227,7 @@ { List<DeviceUI> deviceList = new List<DeviceUI>(); for (int i = 0; i < Lists.Count; i++) - { + { var room = Lists[i]; if (room.IsSharedRoom) { @@ -282,20 +276,16 @@ /// </summary> public static void InitAllRoom() { - //if (CanInitAllRoom == false) - //{ - // return; - //} Lists.Clear(); if (Config.Instance.Home.RoomFilePathList.Contains("Room_Favorite.json") == false) { //榛樿娣诲姞鍠滅埍鐨勬埧闂�--绂佹淇敼鎴块棿鍚� - var love = new Room { Name = Language.StringByID(R.MyInternationalizationString.Favorite), BackgroundImage = "Room/r0.png", Id = LoveRoomId }; - love.Save(true); + var love = new Room { Name = Language.StringByID(R.MyInternationalizationString.Favorite), BackgroundImage = "RoomIcon/0.JPG", Id = LoveRoomId }; + love.Save(false); //娣诲姞鍒癶ouse 鎴块棿璺緞鍒楄〃 var currentHome = Config.Instance.Home; currentHome.RoomFilePathList.Insert(0, love.FileName); - currentHome.Save(); + currentHome.Save(false); } foreach (var roomFilePath in Config.Instance.Home.RoomFilePathList) { @@ -305,42 +295,43 @@ { if (room.IsSharedRoom) { - room.Name = $"({Language.StringByID(R.MyInternationalizationString.Shared)}){room.Name}"; + room.Name = $"{room.Name}"; } Lists.Add(room); + } } + Config.Instance.Home.InitFloor(); } - /// <summary> - /// 浠庢湰鍦伴噸鏂板姞杞藉叏閮ㄧ殑鎴块棿 + /// <summary> + /// 浠庢湰鍦伴噸鏂板姞杞藉叏閮ㄧ殑鎴块棿 /// </summary> - public static void RefreshAllRoomByLocation() - { - Lists.Clear(); - var homeTemp = Config.Instance.Home; - homeTemp.RoomFilePathList.Clear(); - - var listFile = Global.FileListByHomeId(); - - //鎴戠殑鍠滅埍鐨勬埧闂村繀椤昏鍦ㄧ0浣嶆墠琛� - string fRoom = "Room_Favorite.json"; - if (listFile.Contains(fRoom) == true) - { - listFile.Remove(fRoom); - homeTemp.AddRoomListFilePath(fRoom); - } - - foreach (string fileName in listFile) - { - if (fileName.StartsWith("Room_")) - { - homeTemp.AddRoomListFilePath(fileName); - } - } - homeTemp.Save(false); - CanInitAllRoom = true; - InitAllRoom(); + public static void RefreshAllRoomByLocation() + { + Lists.Clear(); + var homeTemp = Config.Instance.Home; + homeTemp.RoomFilePathList.Clear(); + + var listFile = Global.FileListByHomeId(); + + //鎴戠殑鍠滅埍鐨勬埧闂村繀椤昏鍦ㄧ0浣嶆墠琛� + string fRoom = "Room_Favorite.json"; + if (listFile.Contains(fRoom) == true) + { + listFile.Remove(fRoom); + homeTemp.AddRoomListFilePath(fRoom); + } + + foreach (string fileName in listFile) + { + if (fileName.StartsWith("Room_")) + { + homeTemp.AddRoomListFilePath(fileName); + } + } + homeTemp.Save(false); + InitAllRoom(); } #endregion @@ -445,7 +436,7 @@ //璁惧锛坉eviceUI锛� beforeRoom.DeviceUIList.Clear(); foreach (var deviceFilePath in beforeRoom.DeviceUIFilePathList) - { + { beforeRoom.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(deviceFilePath)); } //鍦烘櫙(SceneUI) @@ -496,7 +487,7 @@ } return nowRoom; } - catch (Exception ex) + catch(Exception ex) { return null; } @@ -534,15 +525,15 @@ public string GetRoomNameByDevice(CommonDevice device) { var room = this.GetRoomByDevice(device); - if (room == null) - { - //鏈垎閰嶅尯鍩� - return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom); + if (room == null) + { + //鏈垎閰嶅尯鍩� + return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom); } - if (Config.Instance.Home.FloorDics.ContainsKey(room.FloorId) == true) - { - //(妤煎眰+鎴块棿鍚�) - return Config.Instance.Home.FloorDics[room.FloorId] + " " + room.Name; + if (Config.Instance.Home.FloorDics.ContainsKey(room.FloorId) == true) + { + //(妤煎眰+鎴块棿鍚�) + return Config.Instance.Home.FloorDics[room.FloorId] + " " + room.Name; } return room.Name; } @@ -582,6 +573,10 @@ { foreach (var r in Lists) { + if (r.IsLove) + { + continue; + } foreach (var scene in r.SceneUIList) { if (scene.Id == sceneId) @@ -598,21 +593,21 @@ /// </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> /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂村悕绉� /// </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); } @@ -625,9 +620,9 @@ /// </summary> /// <param name="id"></param> /// <returns></returns> - public List<Room> GetRoomsByFloorIdAppendLoveRoom(string id) + public List<Room> GetRoomsByFloorIdAppendLoveRoom(string id) { - var r = Lists.FindAll((obj) => obj.FloorId == id); + var r= Lists.FindAll((obj) => obj.FloorId == id); r.Insert(0, GetLoveRoom()); return r; } @@ -636,7 +631,7 @@ /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂�(鎷兼帴浜嗐�愬父鐢ㄣ�戝湪绗竴浣�) /// </summary> /// <returns></returns> - public List<Room> GetRoomsByCurrentFloorIdAppendLoveRoom() + public List<Room> GetRoomsByCurrentFloorIdAppendLoveRoom() { if(Config.Instance.Home.FloorDics.Count==0) { @@ -656,7 +651,8 @@ /// </summary> /// <param name="device">璁惧瀵硅薄</param> /// <param name="roomId">鏂版埧闂碔d</param> - public void ChangedRoom(CommonDevice device, string roomId) + /// <param name="saveRealRoom">鏄惁淇敼鐪熷疄鐗╃悊璁惧鐨勬埧闂�,涓嶅嚭鎰忓,杩欎釜鍊奸粯璁や负true鍗冲彲</param> + public void ChangedRoom(CommonDevice device, string roomId, bool saveRealRoom = true) { //鎴块棿鏄惁淇敼 if (this.IsRoomChanged(device, roomId) == false) @@ -668,12 +664,12 @@ //娣诲姞鍒版柊鐨勬埧闂� var room = this.GetRoomById(roomId); - if (room != null) - { - room.AddDevice(device); + if (room != null) + { + room.AddDevice(device, saveRealRoom); } - } - + } + /// <summary> /// 鎴块棿鍚嶅瓧鏄惁鏈変慨鏀� /// </summary> @@ -683,9 +679,9 @@ public bool IsRoomChanged(CommonDevice device, string roomId) { var room = this.GetRoomByDevice(device); - if (room == null || room.Id != roomId) - { - return true; + if (room == null || room.Id != roomId) + { + return true; } return false; } @@ -742,7 +738,7 @@ try { var newPath = System.IO.Path.Combine(Config.Instance.FullPath, newFile); - var path = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath, oldFile); + var path = System.IO.Path.Combine(Shared.IO.FileUtils.RootPath,oldFile); Global.MoveFileToDirectory(path, newPath); //澶囦唤 Phone.UserCenter.HdlAutoBackupLogic.AddOrEditorFile(oldFile); @@ -759,7 +755,7 @@ #region 鈼� 娣诲姞璁惧________________________ /// <summary> - /// 娣诲姞璁惧 + /// 娣诲姞璁惧(姝ゆ柟娉曠洰鍓嶅彧缁欍�愭垜鐨勫枩鐖便�戜娇鐢�) /// </summary> /// <param name="deviceUIFilePath">Device UIF ile path.</param> public void AddDevice(string deviceUIFilePath) @@ -784,10 +780,11 @@ } /// <summary> - /// 娣诲姞璁惧 + /// 娣诲姞璁惧(姝ゆ柟娉曠洰鍓嶅彧缁橰oom閲岄潰浣跨敤) /// </summary> /// <param name="device">瑕佹坊鍔犵殑璁惧瀵硅薄</param> - public void AddDevice(CommonDevice device) + /// <param name="saveRealRoom">鏄惁淇敼鐪熷疄鐗╃悊璁惧鐨勬埧闂�,涓嶅嚭鎰忓,杩欎釜鍊奸粯璁や负true鍗冲彲</param> + public void AddDevice(CommonDevice device, bool saveRealRoom) { if (device == null) { @@ -795,9 +792,6 @@ } //璁惧淇℃伅淇濆瓨鍒版湰鍦� device.Save(); - - //娣诲姞鑷姩澶囦唤 - HdlAutoBackupLogic.AddOrEditorFile(device.FilePath); var deviceUI = Common.LocalDevice.Current.GetDeviceUI(device); if (DeviceUIFilePathList.Contains(deviceUI.FileName) == false) @@ -809,6 +803,11 @@ //娣诲姞鑷姩澶囦唤 HdlAutoBackupLogic.AddOrEditorFile(FileName); + if (saveRealRoom == true && LocalDevice.Current.GetDevicesCountByMac(device.DeviceAddr) == 1) + { + //濡傛灉鍙湁涓�涓洖璺�,鍒欎慨鏀圭湡瀹炵墿鐞嗚澶囩殑鎴块棿 + LocalDevice.Current.SaveRealDeviceRoomId(new List<CommonDevice>() { device }, this.Id, false); + } } } @@ -874,9 +873,9 @@ return Common.LocalDevice.Current.GetDeviceUI(device); } - /// <summary> - /// 鑾峰彇褰撳墠鎴块棿涓嬬殑鍏ㄩ儴璁惧 - /// </summary> + /// <summary> + /// 鑾峰彇褰撳墠鎴块棿涓嬬殑鍏ㄩ儴璁惧 + /// </summary> /// <returns></returns> public List<CommonDevice> GetRoomListDevice() { @@ -920,7 +919,7 @@ /// <param name="room"></param> /// <param name="deviceType"></param> /// <returns></returns> - public static List<DeviceUI> GetDeviceUIs(Room room, DeviceType deviceType) + public static List<DeviceUI> GetDeviceUIs(Room room ,DeviceType deviceType) { List<DeviceUI> typeList = new List<DeviceUI> { }; foreach (var deviceUI in room.DeviceUIList) @@ -929,7 +928,7 @@ { continue; } - if (deviceUI.CommonDevice.Type != deviceType) + if(deviceUI.CommonDevice.Type!=deviceType) { continue; } @@ -987,14 +986,14 @@ public async System.Threading.Tasks.Task<int> AddScene(string sceneName, string sceneIconPath, List<ZigBee.Device.Scene.AddSceneMemberData> commons, int iconPathType = 0) { var scenes = GetSceneUIsByFloorId(FloorId); - if (scenes != null && scenes.Count > 0) + if(scenes!=null && scenes.Count>0) { if (scenes.Find(s => s.Name == sceneName) != null) { return -1; } } - + var getSceneIdAllData = await ZigBee.Device.Scene.GetSceneNewIdAsync(sceneName); if (getSceneIdAllData == null || getSceneIdAllData.getSceneIdData == null) { @@ -1014,7 +1013,7 @@ ScenesId = getSceneIdData.NewScenesId, TaskList = common.TaskList, DelayTime = common.DelayTime, - MemberNumber = common.MemberNumber, + MemberNumber=common.MemberNumber, ElseScenesId = common.ElseScenesId }; //common.ScenesId = getSceneIdData.NewScenesId; @@ -1046,7 +1045,7 @@ Id = getSceneIdData.NewScenesId, IconPath = fullPath, IconPathType = iconPathType, - AddSceneMemberDataList = commons + AddSceneMemberDataList= commons }; SceneUIList.Add(sceneUI); SceneUIFilePathList.Add(sceneUI.FileName); @@ -1101,9 +1100,9 @@ /// <param name="room"></param> /// <param name="filePath"></param> /// <returns></returns> - public bool IsCollectInRoom(Room room, string filePath) + public bool IsCollectInRoom(Room room,string filePath) { - if (room.IsLove) + if(room.IsLove) { return true; } @@ -1160,7 +1159,7 @@ TaskList = addCommon.TaskList, DelayTime = addCommon.DelayTime, ElseScenesId = addCommon.ElseScenesId, - MemberNumber = addCommon.MemberNumber + MemberNumber=addCommon.MemberNumber }; //娣诲姞鏂版垚鍛� 杩斿洖缁撴灉 var addSceneMemberResponseAllData = await ZigBee.Device.Scene.AddSceneMemberAsync(addSceneMemberData); @@ -1196,7 +1195,7 @@ /// <param name="sceneUI">Scene user interface.</param> public void RemoveScene(SceneUI sceneUI) { - if (Global.IsExistsByHomeId(sceneUI.FileName) == false) + if(Global.IsExistsByHomeId(sceneUI.FileName)==false) { return; } @@ -1205,7 +1204,6 @@ Save(); Global.DeleteFilebyHomeId(sceneUI.FileName); HdlAutoBackupLogic.DeleteFile(sceneUI.FileName); - HdlAutoBackupLogic.AddOrEditorFile(FileName); } #endregion @@ -1221,6 +1219,10 @@ { foreach (var r in Lists) { + if (r.IsLove) + { + continue; + } foreach (var sceneUI in r.SceneUIList) { if (sceneUI.Id == sceneId) @@ -1231,6 +1233,7 @@ } return null; } + /// <summary> /// 鑾峰彇璇ユゼ灞傛墍鏈夊満鏅� /// </summary> @@ -1239,8 +1242,8 @@ public List<SceneUI> GetSameFloorScenes(string floorId) { List<SceneUI> sceneUIs = new List<SceneUI> { }; - var rooms = CurrentRoom.GetRoomsByFloorId(floorId); - foreach (var r in rooms) + var rooms= CurrentRoom.GetRoomsByFloorId(floorId); + foreach(var r in rooms) { sceneUIs.AddRange(r.SceneUIList); } @@ -1318,168 +1321,168 @@ { HdlAutoBackupLogic.AddOrEditorFile(FileName); } - } - + } + #endregion - - #region 鈼� 妤煎眰鍜屾埧闂撮『搴忕浉鍏砡______________ - - /// <summary> - /// 鏍规嵁妤煎眰鐨勪富閿幏鍙栨帓搴忓悗鐨勬埧闂村垪琛� - /// </summary> - /// <param name="i_floorKeys">妤煎眰鐨勪富閿�</param> - /// <param name="getShard">鍒嗕韩鐨勬埧闂存槸鍚︿篃鑾峰彇</param> - /// <returns></returns> - public List<Room> GetFloorSortRoom(string i_floorKeys, bool getShard = true) - { - Dictionary<string, List<string>> dicAllSort = new Dictionary<string, List<string>>(); - //璇诲彇鎴块棿椤哄簭 - string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.RoomSortFile); - var strData = UserCenterLogic.LoadFileContent(fullName); - if (strData != null) - { - dicAllSort = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(strData); - } - - var listRoomSort = new List<string>(); - if (dicAllSort.ContainsKey(i_floorKeys) == true) - { - listRoomSort = dicAllSort[i_floorKeys]; - } - else - { - dicAllSort[i_floorKeys] = listRoomSort; - } - - var dicRoom = new Dictionary<string, Common.Room>(); - foreach (var room in Common.Room.Lists) - { - if (room.FloorId != i_floorKeys || room.IsLove == true) - { - //涓嶆槸鍚屼竴涓ゼ灞� - continue; - } - if (listRoomSort.Contains(room.Id) == false) - { - //鏂版坊鍔犵殑鎴块棿 - listRoomSort.Add(room.Id); - } - if (getShard == false && room.IsSharedRoom == true) - { - //涓嶈鍒嗕韩鐨勬埧闂� - continue; - } - dicRoom[room.Id] = room; - } - - var listSortRoom = new List<Room>(); - for (int i = 0; i < listRoomSort.Count; i++) - { - if (dicRoom.ContainsKey(listRoomSort[i]) == true) - { - listSortRoom.Add(dicRoom[listRoomSort[i]]); - } - } - - //淇濆瓨椤哄簭 - UserCenterLogic.SaveFileContent(fullName, dicAllSort); - return listSortRoom; - } - - /// <summary> - /// 淇濆瓨鎴块棿鐨勯『搴� - /// </summary> - /// <param name="i_floorKeys">妤煎眰涓婚敭</param> - /// <param name="listSort">鎴块棿椤哄簭(鎴块棿鐨勪富閿�)</param> - public void SaveRoomSort(string i_floorKeys, List<string> listSort) - { - Dictionary<string, List<string>> dicAllSort = new Dictionary<string, List<string>>(); - //璇诲彇鎴块棿椤哄簭 - string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.RoomSortFile); - var strData = UserCenterLogic.LoadFileContent(fullName); - if (strData != null) - { - dicAllSort = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(strData); - } - - //淇濆瓨椤哄簭 - dicAllSort[i_floorKeys] = listSort; - UserCenterLogic.SaveFileContent(fullName, dicAllSort); - dicAllSort.Clear(); - } - - /// <summary> - /// 鑾峰彇鎺掑簭鍚庣殑妤煎眰 - /// </summary> - /// <returns></returns> - public Dictionary<string, string> GetFloorSortList() - { - //璇诲彇妤煎眰椤哄簭 - var listFloorSort = new List<string>(); - string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.FloorSortFile); - var strData = UserCenterLogic.LoadFileContent(fullName); - if (strData != null) - { - listFloorSort = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(strData); - } - foreach (string keys in Common.Config.Instance.Home.FloorDics.Keys) - { - if (listFloorSort.Contains(keys) == false) - { - //鏂版坊鍔犵殑妤煎眰 - listFloorSort.Add(keys); - } - } - - var dic = new Dictionary<string, string>(); - for (int i = 0; i < listFloorSort.Count; i++) - { - if (Config.Instance.Home.FloorDics.ContainsKey(listFloorSort[i]) == true) - { - dic[listFloorSort[i]] = Config.Instance.Home.FloorDics[listFloorSort[i]]; - } - } - - //淇濆瓨椤哄簭 - UserCenterLogic.SaveFileContent(fullName, listFloorSort); - return dic; - } - - /// <summary> - /// 淇濆瓨妤煎眰鐨勯『搴� - /// </summary> - /// <param name="listSort">妤煎眰鐨勪富閿�</param> - public void SaveFloorSort(List<string> listSort) - { - string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.FloorSortFile); - //淇濆瓨椤哄簭 - UserCenterLogic.SaveFileContent(fullName, listSort); - } - + + #region 鈼� 妤煎眰鍜屾埧闂撮『搴忕浉鍏砡______________ + + /// <summary> + /// 鏍规嵁妤煎眰鐨勪富閿幏鍙栨帓搴忓悗鐨勬埧闂村垪琛� + /// </summary> + /// <param name="i_floorKeys">妤煎眰鐨勪富閿�</param> + /// <param name="getShard">鍒嗕韩鐨勬埧闂存槸鍚︿篃鑾峰彇</param> + /// <returns></returns> + public List<Room> GetFloorSortRoom(string i_floorKeys, bool getShard = true) + { + Dictionary<string, List<string>> dicAllSort = new Dictionary<string, List<string>>(); + //璇诲彇鎴块棿椤哄簭 + string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.RoomSortFile); + var strData = UserCenterLogic.LoadFileContent(fullName); + if (strData != null) + { + dicAllSort = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(strData); + } + + var listRoomSort = new List<string>(); + if (dicAllSort.ContainsKey(i_floorKeys) == true) + { + listRoomSort = dicAllSort[i_floorKeys]; + } + else + { + dicAllSort[i_floorKeys] = listRoomSort; + } + + var dicRoom = new Dictionary<string, Common.Room>(); + foreach (var room in Common.Room.Lists) + { + if (room.FloorId != i_floorKeys || room.IsLove == true) + { + //涓嶆槸鍚屼竴涓ゼ灞� + continue; + } + if (listRoomSort.Contains(room.Id) == false) + { + //鏂版坊鍔犵殑鎴块棿 + listRoomSort.Add(room.Id); + } + if (getShard == false && room.IsSharedRoom == true) + { + //涓嶈鍒嗕韩鐨勬埧闂� + continue; + } + dicRoom[room.Id] = room; + } + + var listSortRoom = new List<Room>(); + for (int i = 0; i < listRoomSort.Count; i++) + { + if (dicRoom.ContainsKey(listRoomSort[i]) == true) + { + listSortRoom.Add(dicRoom[listRoomSort[i]]); + } + } + + //淇濆瓨椤哄簭 + UserCenterLogic.SaveFileContent(fullName, dicAllSort); + return listSortRoom; + } + + /// <summary> + /// 淇濆瓨鎴块棿鐨勯『搴� + /// </summary> + /// <param name="i_floorKeys">妤煎眰涓婚敭</param> + /// <param name="listSort">鎴块棿椤哄簭(鎴块棿鐨勪富閿�)</param> + public void SaveRoomSort(string i_floorKeys, List<string> listSort) + { + Dictionary<string, List<string>> dicAllSort = new Dictionary<string, List<string>>(); + //璇诲彇鎴块棿椤哄簭 + string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.RoomSortFile); + var strData = UserCenterLogic.LoadFileContent(fullName); + if (strData != null) + { + dicAllSort = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(strData); + } + + //淇濆瓨椤哄簭 + dicAllSort[i_floorKeys] = listSort; + UserCenterLogic.SaveFileContent(fullName, dicAllSort); + dicAllSort.Clear(); + } + + /// <summary> + /// 鑾峰彇鎺掑簭鍚庣殑妤煎眰 + /// </summary> + /// <returns></returns> + public Dictionary<string, string> GetFloorSortList() + { + //璇诲彇妤煎眰椤哄簭 + var listFloorSort = new List<string>(); + string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.FloorSortFile); + var strData = UserCenterLogic.LoadFileContent(fullName); + if (strData != null) + { + listFloorSort = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(strData); + } + foreach (string keys in Common.Config.Instance.Home.FloorDics.Keys) + { + if (listFloorSort.Contains(keys) == false) + { + //鏂版坊鍔犵殑妤煎眰 + listFloorSort.Add(keys); + } + } + + var dic = new Dictionary<string, string>(); + for (int i = 0; i < listFloorSort.Count; i++) + { + if (Config.Instance.Home.FloorDics.ContainsKey(listFloorSort[i]) == true) + { + dic[listFloorSort[i]] = Config.Instance.Home.FloorDics[listFloorSort[i]]; + } + } + + //淇濆瓨椤哄簭 + UserCenterLogic.SaveFileContent(fullName, listFloorSort); + return dic; + } + + /// <summary> + /// 淇濆瓨妤煎眰鐨勯『搴� + /// </summary> + /// <param name="listSort">妤煎眰鐨勪富閿�</param> + public void SaveFloorSort(List<string> listSort) + { + string fullName = UserCenterLogic.CombinePath(DirNameResourse.LocalMemoryDirectory, DirNameResourse.FloorSortFile); + //淇濆瓨椤哄簭 + UserCenterLogic.SaveFileContent(fullName, listSort); + } + + #endregion + + #region 鈼� 鍏嬮殕鎴块棿瀵硅薄_____________________ + + /// <summary> + /// 鍏嬮殕鎴块棿瀵硅薄 + /// </summary> + /// <returns></returns> + public Room CloneRoomClass() + { + var newRoom = new Room(); + //鍏嬮殕灞炴�� + newRoom.Id = this.Id; + newRoom.FloorId = this.FloorId; + newRoom.TemperatrueDevice = this.TemperatrueDevice; + newRoom.HumidityDevice = this.HumidityDevice; + newRoom.Name = this.Name; + newRoom.BackgroundImage = this.BackgroundImage; + newRoom.BackgroundImageType = this.BackgroundImageType; + + return newRoom; + } + #endregion - - #region 鈼� 鍏嬮殕鎴块棿瀵硅薄_____________________ - - /// <summary> - /// 鍏嬮殕鎴块棿瀵硅薄 - /// </summary> - /// <returns></returns> - public Room CloneRoomClass() - { - var newRoom = new Room(); - //鍏嬮殕灞炴�� - newRoom.Id = this.Id; - newRoom.FloorId = this.FloorId; - newRoom.TemperatrueDevice = this.TemperatrueDevice; - newRoom.HumidityDevice = this.HumidityDevice; - newRoom.Name = this.Name; - newRoom.BackgroundImage = this.BackgroundImage; - newRoom.BackgroundImageType = this.BackgroundImageType; - - return newRoom; - } - - #endregion - + } } -- Gitblit v1.8.0