From 1f65fe366062b3f2cda6b03e1849afce6d2646f8 Mon Sep 17 00:00:00 2001
From: gxc <guoxuecheng@guoxuechengdeMacBook-Pro.local>
Date: 星期四, 17 十月 2019 13:47:37 +0800
Subject: [PATCH] 2019.10.17

---
 ZigbeeApp/Shared/Common/Room.cs |  550 +++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 396 insertions(+), 154 deletions(-)

diff --git a/ZigbeeApp/Shared/Common/Room.cs b/ZigbeeApp/Shared/Common/Room.cs
index f14649b..64e0190 100644
--- a/ZigbeeApp/Shared/Common/Room.cs
+++ b/ZigbeeApp/Shared/Common/Room.cs
@@ -27,20 +27,33 @@
                 return $"Room_{Id}.json";
             }
         }
-
         /// <summary>
         /// 鎴块棿id--浣跨敤guid
         /// Guid.NewGuid().ToString()
         /// </summary>
         public string Id = Guid.NewGuid().ToString();
-
+        /// <summary>
+        /// 妤煎眰Id
+        /// 鏂板鏃朵娇鐢℅uid
+        /// </summary>
+        public string FloorId = string.Empty;
+        /// <summary>
+        /// 妤煎眰鍚嶇О
+        /// </summary>
+        public string FloorName
+        {
+            get
+            {
+               return Config.Instance.Home.GetFloorNameById(FloorId);
+            }
+        }
         /// <summary>
         /// 鎴块棿鍚�
         /// </summary>
         public string Name = string.Empty;
 
         /// <summary>
-        /// 鎴块棿鐨勬椂鍊欒儗鏅浘
+        /// 鎴块棿鑳屾櫙鍥�
         /// </summary>
         public string BackgroundImage = string.Empty;
 
@@ -53,6 +66,15 @@
         /// 妤煎眰--澶囩敤
         /// </summary>
         public Dictionary<string, string> FloorList = new Dictionary<string, string> { };
+
+        /// <summary>
+        /// 娓╁害浼犳劅鍣�(璁惧涓婚敭)
+        /// </summary>
+        public string TemperatrueDevice = string.Empty;
+        /// <summary>
+        /// 婀垮害浼犳劅鍣�(璁惧涓婚敭)
+        /// </summary>
+        public string HumidityDevice = string.Empty;
 
         /// <summary>
         /// 褰撳墠閫夋嫨鐨勬埧闂�
@@ -70,6 +92,11 @@
         public readonly List<string> DeviceUIFilePathList = new List<string>();
 
         /// <summary>
+        /// 鍠滅埍鎴块棿id
+        /// </summary>
+        public const string LoveRoomId= "Favorite";
+
+        /// <summary>
         /// 鏄惁鏄粯璁ゅ枩鐖辨埧闂�
         /// </summary>
         /// <value><c>true</c> if is love; otherwise, <c>false</c>.</value>
@@ -78,7 +105,7 @@
         {
             get
             {
-                return Id == "Favorite";
+                return Id == LoveRoomId;
             }
         }
 
@@ -92,7 +119,7 @@
         /// 鏄惁鍙互鍒锋柊鎴块棿鏁版嵁浜�
         /// 闇�瑕佺瓑鍒濆鍖栨湰鍦拌澶囨暟鎹悗鍦ㄥ彲浠ュ垵濮嬪寲鎴块棿鏁版嵁
         /// </summary>
-        public static bool canInitAllRoom;
+        public static bool CanInitAllRoom;
 
         /// <summary>
         /// 鑾峰彇鍠滅埍鎴块棿鐨勬墍鏈夎澶囪矾寰�
@@ -107,8 +134,7 @@
                 {
                     return new List<string> { };
                 }
-                var loveRoom = Lists[0];
-                return loveRoom.DeviceUIFilePathList;
+                return CurrentRoom.GetLoveRoom().DeviceUIFilePathList;
             }
         }
 
@@ -193,7 +219,7 @@
         /// </summary>
         public static void InitAllRoom()
         {
-            if (canInitAllRoom == false)
+            if (CanInitAllRoom == false)
             {
                 return;
             }
@@ -201,7 +227,7 @@
             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 = "Favorite" };
+                var love = new Room { Name = Language.StringByID(R.MyInternationalizationString.Favorite), BackgroundImage = "Room/r0.png", Id = LoveRoomId };
                 love.Save(true);
                 //娣诲姞鍒癶ouse 鎴块棿璺緞鍒楄〃
                 var currentHome = Config.Instance.Home;
@@ -211,21 +237,12 @@
             foreach (var roomFilePath in Config.Instance.Home.RoomFilePathList)
             {
                 var room = GetRoomByFilePath(roomFilePath);
-                System.Console.WriteLine(roomFilePath);
-                System.Console.WriteLine(room?.FileName);
-                System.Console.WriteLine(room?.Name);
 
                 if (null != room)
                 {
                     if (room.IsSharedRoom)
                     {
-                        var sharedName = $"{room.Name}({Language.StringByID(R.MyInternationalizationString.Shared)})";
-                        if (Lists.Find((obj) => obj.Name == sharedName) == null)
-                        {
-
-                        }
-                        room.Name = $"{room.Name}({Language.StringByID(R.MyInternationalizationString.Shared)})";
-                        room.Save();
+                        room.Name = $"({Language.StringByID(R.MyInternationalizationString.Shared)}){room.Name}";
                     }
                     Lists.Add(room);
                 }
@@ -259,7 +276,7 @@
                 }
             }
             homeTemp.Save(false);
-            canInitAllRoom = true;
+            CanInitAllRoom = true;
             InitAllRoom();
         }
 
@@ -327,6 +344,15 @@
         #endregion
 
         #region 鈼� 鑾峰彇鎴块棿________________________
+
+        /// <summary>
+        /// 鑾峰彇鍠滅埍鎴块棿
+        /// </summary>
+        /// <returns></returns>
+        public  Room GetLoveRoom()
+        {
+            return CurrentRoom.GetRoomById(LoveRoomId);
+        }
 
         /// <summary>
         /// 閫氳繃璺緞鑾峰彇鎴块棿
@@ -427,6 +453,16 @@
         }
 
         /// <summary>
+        /// 鏍规嵁鎴块棿Id锛岃幏鍙栨埧闂村璞�
+        /// </summary>
+        /// <returns>The room by name.</returns>
+        /// <param name="roomId">鎴块棿ID</param>
+        public Room GetRoomById(string roomId)
+        {
+            return Lists.Find((obj) => obj.Id == roomId);
+        }
+
+        /// <summary>
         /// 鏍规嵁鎴块棿鍚嶅瓧锛岃幏鍙栨埧闂村璞�
         /// </summary>
         /// <returns>The room by name.</returns>
@@ -437,59 +473,38 @@
         }
 
         /// <summary>
-        /// 鏍规嵁璁惧鑾峰彇鎴块棿鍚嶅瓧
-        /// </summary>
-        /// <returns>鎴块棿鍚�</returns>
-        /// <param name="device">璁惧瀵硅薄</param>
-        public List<string> GetRoomListNameByDevice(CommonDevice device)
-        {
-            var listName = new List<string>();
-            var listroom = this.GetRoomByDevice(device);
-            foreach (var room in listroom)
-            {
-                listName.Add(room.Name);
-            }
-
-            return listName;
-        }
-
-        /// <summary>
-        /// 鏍规嵁璁惧鑾峰彇鎴块棿鍚嶅瓧(澶氫釜鎴块棿鐨勬椂鍊欙紝鐢ㄢ��,鈥濆垎鍓�)
+        /// 鏍规嵁璁惧鑾峰彇鎴块棿鍚嶅瓧(妤煎眰+鎴块棿鍚�)
         /// </summary>
         /// <returns>鎴块棿鍚�</returns>
         /// <param name="device">璁惧瀵硅薄</param>
         public string GetRoomNameByDevice(CommonDevice device)
         {
-            var listName = this.GetRoomListNameByDevice(device);
-
-            return this.GetRoomName(listName);
-        }
-
-        /// <summary>
-        /// 鑾峰彇澶氫釜鎴块棿鐨勮繛鎺ヨ捣鏉ョ殑鍚嶅瓧
-        /// </summary>
-        /// <param name="listName"></param>
-        /// <returns></returns>
-        public string GetRoomName(List<string> listName)
-        {
-            if (listName.Count == 0)
-            {
-                //鏈垎閰嶅尯鍩�
-                return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
+            var room = this.GetRoomByDevice(device);
+            if (room == null)
+            {
+                //鏈垎閰嶅尯鍩�
+                return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
             }
-            return string.Join(",", listName);
+            if (Config.Instance.Home.FloorDics.ContainsKey(room.FloorId) == true)
+            {
+                //(妤煎眰+鎴块棿鍚�)
+                return Config.Instance.Home.FloorDics[room.FloorId] + " " + room.Name;
+            }
+            return room.Name;
         }
 
         /// <summary>
-        /// 鑾峰彇鎵�鏈夋埧闂寸殑鎵�鏈夎澶�
+        /// 鑾峰彇璁惧鎵�鍦ㄧ殑鎴块棿
         /// </summary>
         /// <returns>The room by device.</returns>
         /// <param name="device">璁惧瀵硅薄</param>
-        public List<Room> GetRoomByDevice(CommonDevice device)
+        public Room GetRoomByDevice(CommonDevice device)
         {
-            var deviceUI = new DeviceUI { };
-            deviceUI.DeviceFileName = device.FilePath;
-            return Lists.FindAll((obj) => obj.DeviceUIFilePathList.Contains(deviceUI.FileName));
+            var deviceUI = new DeviceUI { };
+            deviceUI.DeviceAddr = device.DeviceAddr;
+            deviceUI.DeviceEpoint = device.DeviceEpoint;
+
+            return Lists.Find((obj) => obj.DeviceUIFilePathList.Contains(deviceUI.FileName));
         }
 
         /// <summary>
@@ -527,6 +542,55 @@
             return null;
         }
 
+        /// <summary>
+        /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂�
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public  List<Room> GetRoomsByFloorId(string id)
+        {
+            return Lists.FindAll((obj) => obj.FloorId==id);
+        }
+        /// <summary>
+        /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂村悕绉�
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public  List<string> GetRoomNamesByFloorId(string id)
+        {
+            List<string> names = new List<string> { };
+            foreach(var r in Lists)
+            {
+                if(r.FloorId==id)
+                {
+                    names.Add(r.Name);
+                }
+            }
+            return names;
+        }
+
+        /// <summary>
+        /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂�(鎷兼帴浜嗐�愬父鐢ㄣ�戝湪绗竴浣�)
+        /// </summary>
+        /// <param name="id"></param>
+        /// <returns></returns>
+        public  List<Room> GetRoomsByFloorIdAppendLoveRoom(string id)
+        {
+            var r= Lists.FindAll((obj) => obj.FloorId == id);
+            r.Insert(0, GetLoveRoom());
+            return r;
+        }
+
+        /// <summary>
+        /// 鑾峰彇褰撳墠妤煎眰鐨勬埧闂�(鎷兼帴浜嗐�愬父鐢ㄣ�戝湪绗竴浣�)
+        /// </summary>
+        /// <returns></returns>
+        public  List<Room> GetRoomsByCurrentFloorIdAppendLoveRoom()
+        {
+            var r = Lists.FindAll((obj) => obj.FloorId == Config.Instance.Home.CurrentFloorId);
+            r.Insert(0, GetLoveRoom());
+            return r;
+        }
 
         #endregion
 
@@ -536,52 +600,37 @@
         /// 璁惧鐨勬埧闂村彉鏇�
         /// </summary>
         /// <param name="device">璁惧瀵硅薄</param>
-        /// <param name="listnewName">鏂版埧闂村悕瀛楀垪琛�</param>
-        public void ChangedRoom(CommonDevice device, List<string> listnewName)
+        /// <param name="roomId">鏂版埧闂碔d</param>
+        public void ChangedRoom(CommonDevice device, string roomId)
         {
             //鎴块棿鏄惁淇敼
-            if (this.IsRoomChanged(device, listnewName) == false)
+            if (this.IsRoomChanged(device, roomId) == false)
             {
                 return;
             }
-            var list = new List<string>();
-            list.AddRange(listnewName);
-
-            //浠庡師鏉ョ殑鎴块棿绉婚櫎璁惧,浣嗘槸涓嶅垹闄I鏂囦欢
-            this.DeleteDevice(device, ref list, false);
+            //浠庡師鏉ョ殑鎴块棿绉婚櫎璁惧
+            this.DeleteDevice(device);
 
             //娣诲姞鍒版柊鐨勬埧闂�
-            foreach (string newRoom in list)
-            {
-                var room = this.GetRoomByName(newRoom);
-                if (room != null)
-                {
-                    //涓嶈鐩朥I鏂囦欢
-                    room.AddDevice(device, false);
-                }
+            var room = this.GetRoomById(roomId);
+            if (room != null)
+            {
+                room.AddDevice(device);
             }
-        }
-
+        }
+
         /// <summary>
         /// 鎴块棿鍚嶅瓧鏄惁鏈変慨鏀�
         /// </summary>
         /// <param name="device">璁惧瀵硅薄</param>
-        /// <param name="listnewName">鏂版埧闂村悕瀛楀垪琛�</param>
+        /// <param name="roomId">鏂版埧闂碔d</param>
         /// <returns></returns>
-        public bool IsRoomChanged(CommonDevice device, List<string> listnewName)
+        public bool IsRoomChanged(CommonDevice device, string roomId)
         {
-            var listOld = this.GetRoomListNameByDevice(device);
-            if (listOld.Count != listnewName.Count)
-            {
-                return true;
-            }
-            //涓暟涓�鏍锋椂锛屾瘮杈冨唴瀹�
-            foreach (string newstring in listnewName)
-            {
-                if (listOld.Contains(newstring) == false)
-                {
-                    return true;
-                }
+            var room = this.GetRoomByDevice(device);
+            if (room == null || room.Id != roomId)
+            {
+                return true;
             }
             return false;
         }
@@ -684,8 +733,7 @@
         /// 娣诲姞璁惧
         /// </summary>
         /// <param name="device">瑕佹坊鍔犵殑璁惧瀵硅薄</param>
-        /// <param name="backUpUI">鏄惁瑕佽鐩朥I鏂囦欢</param>
-        public void AddDevice(CommonDevice device, bool backUpUI = true)
+        public void AddDevice(CommonDevice device)
         {
             if (device == null)
             {
@@ -698,19 +746,6 @@
             HdlAutoBackupLogic.AddOrEditorFile(device.FilePath);
 
             DeviceUI deviceUI = Common.LocalDevice.Current.GetDeviceUI(device);
-            deviceUI.DeviceFileName = device.FilePath;
-            if (backUpUI == true)
-            {
-                deviceUI.ReSave();
-            }
-            else
-            {
-                deviceUI.Save();
-            }
-
-            //娣诲姞鑷姩澶囦唤
-            HdlAutoBackupLogic.AddOrEditorFile(deviceUI.FileName);
-
             if (DeviceUIFilePathList.Contains(deviceUI.FileName) == false)
             {
                 DeviceUIFilePathList.Add(deviceUI.FileName);
@@ -726,7 +761,6 @@
         #endregion
 
         #region 鈼� 鍒犻櫎璁惧_________________________
-
         /// <summary>
         /// 鍒犻櫎鍔熻兘-璁惧
         /// </summary>
@@ -747,59 +781,33 @@
         /// 鍒犻櫎璁惧
         /// </summary>
         /// <param name="device">瑕佸垹闄ょ殑璁惧瀵硅薄</param>
-        /// <param name="DeleteUi">鏄惁鍒犻櫎UI鏂囦欢</param>
-        public void DeleteDevice(CommonDevice device, bool DeleteUi = true)
-        {
-            List<string> listNotDelRoom = new List<string>();
-            //鍒犻櫎璁惧
-            this.DeleteDevice(device, ref listNotDelRoom, DeleteUi);
-        }
-
-        /// <summary>
-        /// 鍒犻櫎璁惧(鐗规畩鍑芥暟,鐜伴樁娈垫槸缁欒澶囧彉鏇存埧闂翠娇鐢ㄧ殑)
-        /// </summary>
-        /// <param name="device">瑕佸垹闄ょ殑璁惧瀵硅薄</param>
-        /// <param name="listNotDelRoom">涓嶆墽琛屽垹闄ょ殑鎴块棿,褰撴寚瀹氱殑涓嶈兘鍒犻櫎鐨勬埧闂村瓨鍦ㄦ椂锛屼細浠庤繖涓垪琛ㄤ腑绉婚櫎锛屾渶缁堝彧鍓╀笅鏂扮殑鎴块棿</param>
-        /// <param name="DeleteUi">鏄惁鍒犻櫎UI鏂囦欢</param>
-        public void DeleteDevice(CommonDevice device, ref List<string> listNotDelRoom, bool DeleteUi)
+        public void DeleteDevice(CommonDevice device)
         {
             if (device == null)
             {
                 return;
             }
             DeviceUI deviceUI = new DeviceUI();
-            deviceUI.DeviceFileName = device.FilePath;
+            deviceUI.DeviceAddr = device.DeviceAddr;
+            deviceUI.DeviceEpoint = device.DeviceEpoint;
 
-            //鏍规嵁璁惧锛岃幏鍙栨墍鍦ㄧ殑鎴块棿锛屽洜涓哄畠鍒犵殑涓嶄竴瀹氭槸褰撳墠鎴块棿
-            List<Room> listroom = this.GetRoomByDevice(device);
-
-            //鍒犻櫎UI鏂囦欢
-            if (DeleteUi == true && Global.IsExistsByHomeId(deviceUI.FileName) == true)
-            {
-                Global.DeleteFilebyHomeId(deviceUI.FileName);
-                //鍒犻櫎鑷姩澶囦唤
-                Phone.UserCenter.HdlAutoBackupLogic.DeleteFile(deviceUI.FileName);
-            }
-
-            foreach (Room room in listroom)
-            {
-                if (listNotDelRoom.Contains(room.Name) == true)
-                {
-                    listNotDelRoom.Remove(room.Name);
-                    continue;
-                }
-                //绉婚櫎缂撳瓨
-                if (room.DeviceUIFilePathList.Contains(deviceUI.FileName) == false)
-                {
-                    return;
-                }
-                room.DeviceUIFilePathList.Remove(deviceUI.FileName);
-
-                room.DeviceUIList.RemoveAll((obj) => obj.FileName == deviceUI.FileName);
-                room.Save();
-                //鏇存敼鑷姩澶囦唤
-                Phone.UserCenter.HdlAutoBackupLogic.AddOrEditorFile(room.FileName);
-            }
+            //鏍规嵁璁惧锛岃幏鍙栨墍鍦ㄧ殑鎴块棿
+            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();
+            //鏇存敼鑷姩澶囦唤
+            HdlAutoBackupLogic.AddOrEditorFile(room.FileName);
         }
 
         #endregion
@@ -867,6 +875,78 @@
                 }
             }
         }
+
+        /// <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);
+        }
+
+        /// <summary>
+        /// 鑾峰彇鎴块棿璁惧绫诲瀷
+        /// </summary>
+        /// <param name="room"></param>
+        /// <returns></returns>
+        public static List<DeviceType> GetdeviceTypes(Room room)
+        {
+            List<DeviceType> typeList = new List<DeviceType> { };
+            foreach (var deviceUI in room.DeviceUIList)
+            {
+                if (deviceUI == null || deviceUI.CommonDevice == null)
+                {
+                    continue;
+                }
+                if (!typeList.Contains(deviceUI.CommonDevice.Type))
+                {
+                    typeList.Add(deviceUI.CommonDevice.Type);
+                }
+            }
+            return typeList;
+        }
+
+        /// <summary>
+        /// 鑾峰彇璇ョ被鍨嬬殑璁惧
+        /// </summary>
+        /// <param name="room"></param>
+        /// <param name="deviceType"></param>
+        /// <returns></returns>
+        public static List<DeviceUI> GetDeviceUIs(Room room ,DeviceType deviceType)
+        {
+            List<DeviceUI> typeList = new List<DeviceUI> { };
+            foreach (var deviceUI in room.DeviceUIList)
+            {
+                if (deviceUI == null || deviceUI.CommonDevice == null)
+                {
+                    continue;
+                }
+                if(deviceUI.CommonDevice.Type!=deviceType)
+                {
+                    continue;
+                }
+                if (!typeList.Contains(deviceUI))
+                {
+                    typeList.Add(deviceUI);
+                }
+            }
+            return typeList;
+        }
+
 
         #endregion
 
@@ -977,6 +1057,28 @@
             Save();
         }
 
+        #endregion
+
+        #region 鈼� 璁惧鏄惁鏀惰棌______________________
+
+        /// <summary>
+        /// 鏄惁鏄敹钘忚澶�
+        /// </summary>
+        /// <param name="room"></param>
+        /// <param name="filePath"></param>
+        /// <returns></returns>
+        public bool IsCollectInRoom(Room room,string filePath)
+        {
+            if(room.IsLove)
+            {
+                return true;
+            }
+            if (GetLoveRoom().DeviceUIFilePathList.Find((obj) => obj == filePath) == null)
+            {
+                return false;
+            }
+            return true;
+        }
         #endregion
 
         #region 鈼� 淇敼鍦烘櫙________________________
@@ -1171,6 +1273,142 @@
 
         #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);
+        }
+
+        #endregion
+
         #region 鈼� 鍏嬮殕鎴块棿瀵硅薄_____________________
 
         /// <summary>
@@ -1182,6 +1420,9 @@
             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;
@@ -1190,5 +1431,6 @@
         }
 
         #endregion
+       
     }
 }

--
Gitblit v1.8.0