old mode 100755
new mode 100644
| | |
| | | { |
| | | get |
| | | { |
| | | return Config.Instance.Home.GetFloorNameById(FloorId); |
| | | return Config.Instance.Home.GetFloorNameById(FloorId); |
| | | } |
| | | } |
| | | /// <summary> |
| | |
| | | /// </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> |
| | | /// 喜爱房间id |
| | | /// </summary> |
| | | public const string LoveRoomId= "Favorite"; |
| | | public const string LoveRoomId = "Favorite"; |
| | | |
| | | /// <summary> |
| | | /// 是否是默认喜爱房间 |
| | |
| | | { |
| | | List<DeviceUI> deviceList = new List<DeviceUI>(); |
| | | for (int i = 0; i < Lists.Count; i++) |
| | | {
|
| | | { |
| | | var room = Lists[i]; |
| | | if (room.IsSharedRoom) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | /// <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); |
| | | CanInitAllRoom = true; |
| | | InitAllRoom(); |
| | | } |
| | | |
| | | #endregion |
| | |
| | | //设备(deviceUI) |
| | | beforeRoom.DeviceUIList.Clear(); |
| | | foreach (var deviceFilePath in beforeRoom.DeviceUIFilePathList) |
| | | {
|
| | | { |
| | | beforeRoom.DeviceUIList.Add(Common.LocalDevice.Current.GetDeviceUI(deviceFilePath)); |
| | | } |
| | | //场景(SceneUI) |
| | |
| | | } |
| | | return nowRoom; |
| | | } |
| | | catch(Exception ex) |
| | | catch (Exception ex) |
| | | { |
| | | return null; |
| | | } |
| | |
| | | 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; |
| | | } |
| | |
| | | /// <param name="device">设备对象</param> |
| | | public Room GetRoomByDevice(CommonDevice device) |
| | | { |
| | | var deviceUI = new DeviceUI { };
|
| | | deviceUI.DeviceAddr = device.DeviceAddr;
|
| | | var deviceUI = new DeviceUI { }; |
| | | deviceUI.DeviceAddr = device.DeviceAddr; |
| | | deviceUI.DeviceEpoint = device.DeviceEpoint; |
| | | |
| | | return Lists.Find((obj) => obj.IsLove == false && obj.DeviceUIFilePathList.Contains(deviceUI.FileName)); |
| | |
| | | /// </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); |
| | | } |
| | |
| | | /// </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; |
| | | } |
| | |
| | | /// 获取当前楼层的房间(拼接了【常用】在第一位) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public List<Room> GetRoomsByCurrentFloorIdAppendLoveRoom() |
| | | public List<Room> GetRoomsByCurrentFloorIdAppendLoveRoom() |
| | | { |
| | | var r = Lists.FindAll((obj) => obj.FloorId == Config.Instance.Home.CurrentFloorId); |
| | | r.Insert(0, GetLoveRoom()); |
| | |
| | | |
| | | //添加到新的房间 |
| | | var room = this.GetRoomById(roomId); |
| | | if (room != null)
|
| | | {
|
| | | room.AddDevice(device);
|
| | | if (room != null) |
| | | { |
| | | room.AddDevice(device); |
| | | } |
| | | }
|
| | |
|
| | | } |
| | | |
| | | /// <summary> |
| | | /// 房间名字是否有修改 |
| | | /// </summary> |
| | |
| | | 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; |
| | | } |
| | |
| | | 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); |
| | |
| | | return; |
| | | } |
| | | DeviceUI deviceUI = new DeviceUI(); |
| | | deviceUI.DeviceAddr = device.DeviceAddr;
|
| | | 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; |
| | | } |
| | | //移除缓存 |
| | | 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); |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | if (listDevice.Count == 0) |
| | | { |
| | | return listDevice; |
| | | } |
| | | return Common.LocalDevice.Current.SortDevice(listDevice); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <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) |
| | |
| | | { |
| | | continue; |
| | | } |
| | | if(deviceUI.CommonDevice.Type!=deviceType) |
| | | if (deviceUI.CommonDevice.Type != deviceType) |
| | | { |
| | | continue; |
| | | } |
| | |
| | | return sceneList; |
| | | } |
| | | |
| | | /// <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 |
| | | |
| | | #region ◆ 添加场景_________________________ |
| | |
| | | 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) |
| | | { |
| | |
| | | ScenesId = getSceneIdData.NewScenesId, |
| | | TaskList = common.TaskList, |
| | | DelayTime = common.DelayTime, |
| | | MemberNumber=common.MemberNumber, |
| | | MemberNumber = common.MemberNumber, |
| | | ElseScenesId = common.ElseScenesId |
| | | }; |
| | | //common.ScenesId = getSceneIdData.NewScenesId; |
| | |
| | | Id = getSceneIdData.NewScenesId, |
| | | IconPath = fullPath, |
| | | IconPathType = iconPathType, |
| | | AddSceneMemberDataList= commons |
| | | AddSceneMemberDataList = commons |
| | | }; |
| | | SceneUIList.Add(sceneUI); |
| | | SceneUIFilePathList.Add(sceneUI.FileName); |
| | |
| | | /// <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; |
| | | } |
| | |
| | | TaskList = addCommon.TaskList, |
| | | DelayTime = addCommon.DelayTime, |
| | | ElseScenesId = addCommon.ElseScenesId, |
| | | MemberNumber=addCommon.MemberNumber |
| | | MemberNumber = addCommon.MemberNumber |
| | | }; |
| | | //添加新成员 返回结果 |
| | | var addSceneMemberResponseAllData = await ZigBee.Device.Scene.AddSceneMemberAsync(addSceneMemberData); |
| | |
| | | /// <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; |
| | | } |
| | |
| | | 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); |
| | | } |
| | |
| | | { |
| | | 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);
|
| | | }
|
| | |
|
| | | #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;
|
| | | }
|
| | |
|
| | | |
| | | #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 |
| | | |
| | | } |
| | | } |
| | | } |