From 9c6bd67d66859e48f0e794cd2746aef9310ce71d Mon Sep 17 00:00:00 2001
From: WJC <wjc@hdlchina.com.cn>
Date: 星期五, 13 十二月 2019 18:01:37 +0800
Subject: [PATCH] 2019-12-13-2

---
 ZigbeeApp/Shared/Common/Room.cs |  620 ++++++++++++++++++++++++++++---------------------------
 1 files changed, 313 insertions(+), 307 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/Room.cs b/ZigbeeApp/Shared/Common/Room.cs
old mode 100644
new mode 100755
index b15f457..495100a
--- 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,19 +67,35 @@
         /// </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;
 
+        /// <summary>
+        /// 褰撳墠閫夋嫨鐨勬埧闂�
+        /// </summary>
+        private static Room m_CurrentRoom = null;
         /// <summary>
         /// 褰撳墠閫夋嫨鐨勬埧闂�
         /// </summary>
-        public static Room CurrentRoom;
+        [Newtonsoft.Json.JsonIgnore]
+        public static Room CurrentRoom
+        {
+            get
+            {
+                if (m_CurrentRoom == null && Lists.Count > 0)
+                {
+                    return Lists[0];
+                }
+                return m_CurrentRoom;
+            }
+            set { m_CurrentRoom = value; }
+        }
 
         /// <summary>
         /// 鎴块棿閲屾墍鏈夌殑璁惧鍒楄〃
@@ -94,7 +110,7 @@
         /// <summary>
         /// 鍠滅埍鎴块棿id
         /// </summary>
-        public const string LoveRoomId = "Favorite";
+        public const string LoveRoomId= "Favorite";
 
         /// <summary>
         /// 鏄惁鏄粯璁ゅ枩鐖辨埧闂�
@@ -114,12 +130,6 @@
         /// 娉細鍒嗕韩杩囨潵鐨勬埧闂翠笉鑳藉垹闄わ紝涓嶈兘缂栬緫璇ユ埧闂达紝涓嶈兘瀵硅澶囷紙鍔熻兘锛夈�佸満鏅繘琛屽鍒犳敼
         /// </summary>
         public bool IsSharedRoom = false;
-
-        /// <summary>
-        /// 鏄惁鍙互鍒锋柊鎴块棿鏁版嵁浜�
-        /// 闇�瑕佺瓑鍒濆鍖栨湰鍦拌澶囨暟鎹悗鍦ㄥ彲浠ュ垵濮嬪寲鎴块棿鏁版嵁
-        /// </summary>
-        public static bool CanInitAllRoom;
 
         /// <summary>
         /// 鑾峰彇鍠滅埍鎴块棿鐨勬墍鏈夎澶囪矾寰�
@@ -217,7 +227,7 @@
             {
                 List<DeviceUI> deviceList = new List<DeviceUI>();
                 for (int i = 0; i < Lists.Count; i++)
-                {
+                {
                     var room = Lists[i];
                     if (room.IsSharedRoom)
                     {
@@ -266,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)
             {
@@ -289,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
@@ -429,7 +436,7 @@
                     //璁惧锛坉eviceUI锛�
                     beforeRoom.DeviceUIList.Clear();
                     foreach (var deviceFilePath in beforeRoom.DeviceUIFilePathList)
-                    {
+                    {
                         beforeRoom.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(deviceFilePath));
                     }
                     //鍦烘櫙(SceneUI)
@@ -480,7 +487,7 @@
                 }
                 return nowRoom;
             }
-            catch (Exception ex)
+            catch(Exception ex)
             {
                 return null;
             }
@@ -493,6 +500,10 @@
         /// <param name="roomId">鎴块棿ID</param>
         public Room GetRoomById(string roomId)
         {
+            if (string.IsNullOrEmpty(roomId))
+            {
+                return null;
+            }
             return Lists.Find((obj) => obj.Id == roomId);
         }
 
@@ -514,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;
         }
@@ -534,11 +545,8 @@
         /// <param name="device">璁惧瀵硅薄</param>
         public Room GetRoomByDevice(CommonDevice device)
         {
-            var deviceUI = new DeviceUI { };
-            deviceUI.DeviceAddr = device.DeviceAddr;
-            deviceUI.DeviceEpoint = device.DeviceEpoint;
-
-            return Lists.Find((obj) => obj.IsLove == false && obj.DeviceUIFilePathList.Contains(deviceUI.FileName));
+            string deviceFile = device.FilePath;
+            return Lists.Find((obj) => obj.IsLove == false && obj.DeviceUIFilePathList.Contains(deviceFile));
         }
 
         /// <summary>
@@ -581,21 +589,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);
                 }
@@ -608,9 +616,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;
         }
@@ -619,8 +627,12 @@
         /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂�(鎷兼帴浜嗐�愬父鐢ㄣ�戝湪绗竴浣�)
         /// </summary>
         /// <returns></returns>
-        public List<Room> GetRoomsByCurrentFloorIdAppendLoveRoom()
+        public  List<Room> GetRoomsByCurrentFloorIdAppendLoveRoom()
         {
+            if(Config.Instance.Home.FloorDics.Count==0)
+            {
+                return Lists;
+            }
             var r = Lists.FindAll((obj) => obj.FloorId == Config.Instance.Home.CurrentFloorId);
             r.Insert(0, GetLoveRoom());
             return r;
@@ -635,7 +647,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)
@@ -647,12 +660,12 @@
 
             //娣诲姞鍒版柊鐨勬埧闂�
             var room = this.GetRoomById(roomId);
-            if (room != null)
-            {
-                room.AddDevice(device);
+            if (room != null)
+            {
+                room.AddDevice(device, saveRealRoom);
             }
-        }
-
+        }
+
         /// <summary>
         /// 鎴块棿鍚嶅瓧鏄惁鏈変慨鏀�
         /// </summary>
@@ -662,9 +675,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;
         }
@@ -721,7 +734,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);
@@ -738,7 +751,7 @@
         #region 鈼� 娣诲姞璁惧________________________
 
         /// <summary>
-        /// 娣诲姞璁惧
+        /// 娣诲姞璁惧(姝ゆ柟娉曠洰鍓嶅彧缁欍�愭垜鐨勫枩鐖便�戜娇鐢�)
         /// </summary>
         /// <param name="deviceUIFilePath">Device UIF ile path.</param>
         public void AddDevice(string deviceUIFilePath)
@@ -747,9 +760,8 @@
             {
                 return;
             }
-            var jsonInfo = Encoding.UTF8.GetString(Global.ReadFileByHomeId(deviceUIFilePath));
-            var deviceUI = Newtonsoft.Json.JsonConvert.DeserializeObject<DeviceUI>(jsonInfo);
-            if (null == deviceUI || null == deviceUI.CommonDevice)
+            var deviceUI = Common.LocalDevice.Current.GetDeviceUI(deviceUIFilePath);
+            if (null == deviceUI.CommonDevice)
             {
                 //褰撳墠瀵硅薄鏁版嵁鏃犳晥
                 return;
@@ -764,10 +776,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)
             {
@@ -776,10 +789,7 @@
             //璁惧淇℃伅淇濆瓨鍒版湰鍦�
             device.Save();
 
-            //娣诲姞鑷姩澶囦唤
-            HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
-
-            DeviceUI deviceUI = Common.LocalDevice.Current.GetDeviceUI(device);
+            var deviceUI = Common.LocalDevice.Current.GetDeviceUI(device);
             if (DeviceUIFilePathList.Contains(deviceUI.FileName) == false)
             {
                 DeviceUIFilePathList.Add(deviceUI.FileName);
@@ -789,6 +799,11 @@
 
                 //娣诲姞鑷姩澶囦唤
                 HdlAutoBackupLogic.AddOrEditorFile(FileName);
+                if (saveRealRoom == true && LocalDevice.Current.GetDevicesCountByMac(device.DeviceAddr) == 1)
+                {
+                    //濡傛灉鍙湁涓�涓洖璺�,鍒欎慨鏀圭湡瀹炵墿鐞嗚澶囩殑鎴块棿
+                    LocalDevice.Current.SaveRealDeviceRoomId(new List<CommonDevice>() { device }, this.Id, false);
+                }
             }
         }
 
@@ -802,11 +817,10 @@
         public void DeleteDevice(string deviceUIFilePath)
         {
             if (deviceUIFilePath == null) return;
-            if (DeviceUIFilePathList.Contains(deviceUIFilePath) && Global.IsExistsByHomeId(deviceUIFilePath))
+            if (DeviceUIFilePathList.Contains(deviceUIFilePath))
             {
                 DeviceUIFilePathList.Remove(deviceUIFilePath);
                 DeviceUIList.RemoveAll((obj) => obj.FileName == deviceUIFilePath);
-                HdlAutoBackupLogic.DeleteFile(deviceUIFilePath);
                 Save();
             }
         }
@@ -821,26 +835,23 @@
             {
                 return;
             }
-            DeviceUI deviceUI = new DeviceUI();
-            deviceUI.DeviceAddr = device.DeviceAddr;
-            deviceUI.DeviceEpoint = device.DeviceEpoint;
-
             //鏍规嵁璁惧锛岃幏鍙栨墍鍦ㄧ殑鎴块棿
             var room = this.GetRoomByDevice(device);
-            if (room == null)
-            {
-                return;
-            }
-            //绉婚櫎缂撳瓨
-            if (room.DeviceUIFilePathList.Contains(deviceUI.FileName) == false)
-            {
-                return;
-            }
-            room.DeviceUIFilePathList.Remove(deviceUI.FileName);
-
-            room.DeviceUIList.RemoveAll((obj) => obj.FileName == deviceUI.FileName);
-            room.Save();
-            //鏇存敼鑷姩澶囦唤
+            if (room == null)
+            {
+                return;
+            }
+            string deviceFile = device.FilePath;
+            //绉婚櫎缂撳瓨
+            if (room.DeviceUIFilePathList.Contains(deviceFile) == false)
+            {
+                return;
+            }
+            room.DeviceUIFilePathList.Remove(deviceFile);
+
+            room.DeviceUIList.RemoveAll((obj) => obj.FileName == deviceFile);
+            room.Save();
+            //鏇存敼鑷姩澶囦唤
             HdlAutoBackupLogic.AddOrEditorFile(room.FileName);
         }
 
@@ -858,26 +869,22 @@
             return Common.LocalDevice.Current.GetDeviceUI(device);
         }
 
-        /// <summary>
-        /// 鑾峰彇褰撳墠鎴块棿涓嬬殑鍏ㄩ儴璁惧
-        /// </summary>
+        /// <summary>
+        /// 鑾峰彇褰撳墠鎴块棿涓嬬殑鍏ㄩ儴璁惧
+        /// </summary>
         /// <returns></returns>
-        public List<CommonDevice> GetRoomListDevice()
-        {
-            var listDevice = new List<CommonDevice>();
-            foreach (var device in this.DeviceUIList)
-            {
-                if (device == null || device.CommonDevice == null)
-                {
-                    continue;
-                }
-                listDevice.Add(device.CommonDevice);
-            }
-            if (listDevice.Count == 0)
-            {
-                return listDevice;
-            }
-            return Common.LocalDevice.Current.SortDevice(listDevice);
+        public List<CommonDevice> GetRoomListDevice()
+        {
+            var listDevice = new List<CommonDevice>();
+            foreach (var device in this.DeviceUIList)
+            {
+                if (device == null || device.CommonDevice == null)
+                {
+                    continue;
+                }
+                listDevice.Add(device.CommonDevice);
+            }
+            return listDevice;
         }
 
         /// <summary>
@@ -908,7 +915,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)
@@ -917,7 +924,7 @@
                 {
                     continue;
                 }
-                if (deviceUI.CommonDevice.Type != deviceType)
+                if(deviceUI.CommonDevice.Type!=deviceType)
                 {
                     continue;
                 }
@@ -975,14 +982,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)
             {
@@ -1002,7 +1009,7 @@
                     ScenesId = getSceneIdData.NewScenesId,
                     TaskList = common.TaskList,
                     DelayTime = common.DelayTime,
-                    MemberNumber = common.MemberNumber,
+                    MemberNumber=common.MemberNumber,
                     ElseScenesId = common.ElseScenesId
                 };
                 //common.ScenesId = getSceneIdData.NewScenesId;
@@ -1034,7 +1041,7 @@
                     Id = getSceneIdData.NewScenesId,
                     IconPath = fullPath,
                     IconPathType = iconPathType,
-                    AddSceneMemberDataList = commons
+                    AddSceneMemberDataList= commons
                 };
                 SceneUIList.Add(sceneUI);
                 SceneUIFilePathList.Add(sceneUI.FileName);
@@ -1089,9 +1096,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;
             }
@@ -1148,7 +1155,7 @@
                     TaskList = addCommon.TaskList,
                     DelayTime = addCommon.DelayTime,
                     ElseScenesId = addCommon.ElseScenesId,
-                    MemberNumber = addCommon.MemberNumber
+                    MemberNumber=addCommon.MemberNumber
                 };
                 //娣诲姞鏂版垚鍛� 杩斿洖缁撴灉
                 var addSceneMemberResponseAllData = await ZigBee.Device.Scene.AddSceneMemberAsync(addSceneMemberData);
@@ -1184,7 +1191,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;
             }
@@ -1193,7 +1200,6 @@
             Save();
             Global.DeleteFilebyHomeId(sceneUI.FileName);
             HdlAutoBackupLogic.DeleteFile(sceneUI.FileName);
-            HdlAutoBackupLogic.AddOrEditorFile(FileName);
         }
 
         #endregion
@@ -1227,8 +1233,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);
             }
@@ -1306,168 +1312,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
-
+       
     }
-}
\ No newline at end of file
+}

--
Gitblit v1.8.0