File was renamed from ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlRoomLogic.cs |
| | |
| | | using System.Text; |
| | | using ZigBee.Device; |
| | | |
| | | namespace Shared.Phone.UserCenter |
| | | namespace Shared.Phone |
| | | { |
| | | /// <summary> |
| | | /// 房间的逻辑 |
| | |
| | | /// 所有的房间信息 |
| | | /// </summary> |
| | | private Dictionary<string, Room> dicRooms = new Dictionary<string, Room>(); |
| | | /// <summary> |
| | | /// 物理设备属于哪个房间的记录 |
| | | /// </summary> |
| | | private Dictionary<string, string> dicDeviceRoomId = null; |
| | | |
| | | #endregion |
| | | |
| | |
| | | this.CheckLoveRoom(); |
| | | |
| | | var listFile = HdlFileLogic.Current.GetRootPathListFile(); |
| | | var listEsixtMac = new List<string>(); |
| | | foreach (var fileName in listFile) |
| | | { |
| | | if (fileName.StartsWith("Room_") == true) |
| | |
| | | var room = this.GetRoomByFilePath(fileName); |
| | | if (room != null) |
| | | { |
| | | this.dicRooms[room.Id] = (room); |
| | | this.dicRooms[room.Id] = room; |
| | | //获取已经存在了的Mac |
| | | listEsixtMac.AddRange(room.ListDeviceMac); |
| | | } |
| | | } |
| | | } |
| | | //检查真实物理设备的所在的房间时候有遗漏 |
| | | foreach (var room in this.dicRooms.Values) |
| | | { |
| | | this.CheckRealDeviceRoom(room, ref listEsixtMac); |
| | | } |
| | | |
| | | //顺便刷新场景 |
| | | HdlSceneLogic.Current.ReFreshByLocal(); |
| | | //刷新房间视图列表 |
| | |
| | | } |
| | | } |
| | | //检测楼层数据的合法性 |
| | | if (UserCenterResourse.UserInfo.AuthorityNo == 3) |
| | | if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 3) |
| | | { |
| | | this.CheckMemberFloorData(listRoomFile); |
| | | } |
| | |
| | | Config.Instance.Home.Save(false); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 检查真实物理设备的所在的房间时候有遗漏 |
| | | /// </summary> |
| | | /// <param name="i_room">房间对象</param> |
| | | /// <param name="listEsixtMac">已经存在了的Mac</param> |
| | | private void CheckRealDeviceRoom(Room i_room, ref List<string> listEsixtMac) |
| | | { |
| | | //不考虑收藏 |
| | | if (i_room.IsLove == true) { return; } |
| | | |
| | | bool save = false; |
| | | foreach (var deviceKey in i_room.ListDevice) |
| | | { |
| | | string deviceMac = deviceKey.Split(new string[] { "_" }, StringSplitOptions.RemoveEmptyEntries)[0].Trim(); |
| | | //如果这个Mac并没有加到它自己这个房间,或者其他房间,则添加进去 |
| | | if (i_room.ListDeviceMac.Contains(deviceMac) == false && listEsixtMac.Contains(deviceMac) == false) |
| | | { |
| | | listEsixtMac.Add(deviceMac); |
| | | i_room.ListDeviceMac.Add(deviceMac); |
| | | save = true; |
| | | } |
| | | } |
| | | if (save == true) |
| | | { |
| | | i_room.Save(); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ■ 添加房间___________________________ |
| | |
| | | //生成文件 |
| | | room.Save(); |
| | | //备份 |
| | | HdlAutoBackupLogic.AddOrEditorFile(room.FileName); |
| | | HdlBackupLogic.Current.AddOrEditorAutoBackFileStatu(room.FileName); |
| | | if (refreshRoomView == true) |
| | | { |
| | | //刷新房间视图列表 |
| | |
| | | { |
| | | Global.DeleteFilebyHomeId(room.BackgroundImage); |
| | | //删除备份 |
| | | HdlAutoBackupLogic.DeleteFile(room.BackgroundImage); |
| | | HdlBackupLogic.Current.DeleteAutoBackFileStatu(room.BackgroundImage); |
| | | } |
| | | } |
| | | //我的喜爱 |
| | |
| | | //删除文件 |
| | | Global.DeleteFilebyHomeId(roomFilePath); |
| | | } |
| | | HdlAutoBackupLogic.DeleteFile(roomFilePath); |
| | | HdlBackupLogic.Current.DeleteAutoBackFileStatu(roomFilePath); |
| | | |
| | | //根据房间ID,移除指定的真实物理设备的所属房间记录 |
| | | HdlRoomLogic.Current.DeleteRealDeviceByRoomId(roomId); |
| | | if (refreshLeftView == true) |
| | | { |
| | | //刷新房间视图列表 |
| | |
| | | /// <param name="device">设备对象</param> |
| | | public Room GetRoomByDevice(CommonDevice device) |
| | | { |
| | | string mainKeys = LocalDevice.Current.GetDeviceMainKeys(device); |
| | | string mainKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device); |
| | | foreach (var room in this.dicRooms.Values) |
| | | { |
| | | if (room.IsLove == true) |
| | |
| | | /// <summary> |
| | | /// 获取网关所在的房间 |
| | | /// </summary> |
| | | /// <param name="zbGateway">网关对象</param> |
| | | /// <returns></returns> |
| | | public Room GetRoomByGateway(ZbGateway zbGateway) |
| | | { |
| | | return this.GetRoomByGateway(zbGateway.GwId); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取网关所在的房间 |
| | | /// </summary> |
| | | /// <param name="gatewayId">网关ID</param> |
| | | /// <returns></returns> |
| | | public Room GetRoomByGateway(string gatewayId) |
| | | { |
| | | var localGateway = HdlGatewayLogic.Current.GetLocalGateway(gatewayId); |
| | | if (localGateway == null) |
| | | foreach (var room in this.dicRooms.Values) |
| | | { |
| | | return null; |
| | | if (room.ListDeviceMac.Contains(gatewayId) == true) |
| | | { |
| | | return room; |
| | | } |
| | | } |
| | | return HdlRoomLogic.Current.GetRoomById(localGateway.RoomId); |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="roomId">房间ID</param> |
| | | public void ChangedGatewayRoom(string gwId, string roomId) |
| | | { |
| | | var localGateway = HdlGatewayLogic.Current.GetLocalGateway(gwId); |
| | | if (localGateway != null) |
| | | var room = this.GetRoomById(roomId); |
| | | if (room != null && room.ListDeviceMac.Contains(gwId) == false) |
| | | { |
| | | localGateway.RoomId = roomId; |
| | | localGateway.ReSave(); |
| | | //添加备份 |
| | | HdlAutoBackupLogic.AddOrEditorFile(localGateway.FilePath); |
| | | room.ListDeviceMac.Add(gwId); |
| | | room.Save(); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |
| | | #region ■ 物理设备所属房间___________________ |
| | | |
| | | /// <summary> |
| | | /// 初始化物理设备所属房间的记录 |
| | | /// </summary> |
| | | public void InitRealDeviceRoomId() |
| | | { |
| | | this.dicDeviceRoomId = new Dictionary<string, string>(); |
| | | string fullName = DirNameResourse.DeviceRoomIdFile; |
| | | var strData = HdlFileLogic.Current.ReadFileTextContent(fullName); |
| | | if (strData != null) |
| | | { |
| | | this.dicDeviceRoomId = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(strData); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取全部物理设备所属房间的记录 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | public Dictionary<string, string> GetAllRealDeviceRoomData() |
| | | { |
| | | return this.dicDeviceRoomId; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 保存物理设备所属房间的记录 |
| | |
| | | if ((listDevice[0] is OTADevice) == false) |
| | | { |
| | | //ota设备不需要处理 |
| | | HdlRoomLogic.Current.ChangedRoom(listDevice[0], roomId, false); |
| | | this.ChangedRoom(listDevice[0], roomId, false); |
| | | } |
| | | } |
| | | bool save = false; |
| | | if (roomId == string.Empty) |
| | | { |
| | | //选择的是未分配 |
| | | this.dicDeviceRoomId.Remove(listDevice[0].DeviceAddr); |
| | | save = true; |
| | | //真实物理设备所在的房间 |
| | | var realRoom = this.GeteRealDeviceRoom(listDevice[0]); |
| | | if (realRoom != null && realRoom.ListDeviceMac.Contains(listDevice[0].DeviceAddr) == true) |
| | | { |
| | | //选择的是未分配 |
| | | realRoom.ListDeviceMac.Remove(listDevice[0].DeviceAddr); |
| | | realRoom.Save(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (this.dicDeviceRoomId.ContainsKey(listDevice[0].DeviceAddr) == false) |
| | | //真实物理设备所在的房间 |
| | | var realRoom = this.GetRoomById(roomId); |
| | | if (realRoom != null && realRoom.ListDeviceMac.Contains(listDevice[0].DeviceAddr) == false) |
| | | { |
| | | this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId; |
| | | save = true; |
| | | realRoom.ListDeviceMac.Add(listDevice[0].DeviceAddr); |
| | | realRoom.Save(); |
| | | } |
| | | else |
| | | { |
| | | //2020.05.18追加:如果记录的房间ID是不存在的话,则重新覆盖 |
| | | var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[listDevice[0].DeviceAddr]); |
| | | if (room == null || this.dicDeviceRoomId[listDevice[0].DeviceAddr] != roomId) |
| | | { |
| | | this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId; |
| | | save = true; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (save == true) |
| | | { |
| | | //保存记录 |
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId); |
| | | |
| | | //添加自动备份 |
| | | HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile); |
| | | } |
| | | } |
| | | |
| | |
| | | /// <returns></returns> |
| | | public string GeteRealDeviceRoomName(CommonDevice device) |
| | | { |
| | | if (this.dicDeviceRoomId.ContainsKey(device.DeviceAddr) == false) |
| | | var room = this.GeteRealDeviceRoom(device); |
| | | if (room == null) |
| | | { |
| | | //未分配区域 |
| | | return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom); |
| | | } |
| | | var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]); |
| | | return HdlRoomLogic.Current.GetRoomName(room); |
| | | return this.GetRoomName(room); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns></returns> |
| | | public Room GeteRealDeviceRoom(CommonDevice device) |
| | | { |
| | | if (this.dicDeviceRoomId.ContainsKey(device.DeviceAddr) == false) |
| | | foreach (var room in this.dicRooms.Values) |
| | | { |
| | | return null; |
| | | if (room.IsLove == true) |
| | | { |
| | | //喜爱房间不处理 |
| | | continue; |
| | | } |
| | | if (room.ListDeviceMac.Contains(device.DeviceAddr) == true) |
| | | { |
| | | return room; |
| | | } |
| | | } |
| | | return HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]); |
| | | return null; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="listMac">设备Mac地址</param> |
| | | public void DeleteRealDeviceFromRoom(List<string> listMac) |
| | | { |
| | | bool save = false; |
| | | foreach (var deviceMacAddr in listMac) |
| | | foreach (var room in this.dicRooms.Values) |
| | | { |
| | | if (this.dicDeviceRoomId.ContainsKey(deviceMacAddr) == true) |
| | | bool save = false; |
| | | foreach (var strMac in listMac) |
| | | { |
| | | this.dicDeviceRoomId.Remove(deviceMacAddr); |
| | | save = true; |
| | | if (room.ListDeviceMac.Contains(strMac) == true) |
| | | { |
| | | room.ListDeviceMac.Remove(strMac); |
| | | save = true; |
| | | } |
| | | } |
| | | if (save == true) |
| | | { |
| | | room.Save(); |
| | | } |
| | | } |
| | | if (save == false) |
| | | { |
| | | //没有改变,不需要保存 |
| | | return; |
| | | } |
| | | //保存记录 |
| | | HdlFileLogic.Current.SaveFileContent(DirNameResourse.DeviceRoomIdFile, this.dicDeviceRoomId); |
| | | |
| | | //添加自动备份 |
| | | HdlAutoBackupLogic.AddOrEditorFile(DirNameResourse.DeviceRoomIdFile); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 根据房间ID,移除指定的真实物理设备的所属房间记录 |
| | | /// </summary> |
| | | /// <param name="i_RoomId"></param> |
| | | public void DeleteRealDeviceByRoomId(string i_RoomId) |
| | | { |
| | | var listDeleteKey = new List<string>(); |
| | | foreach (var deviceAddr in this.dicDeviceRoomId.Keys) |
| | | { |
| | | if (this.dicDeviceRoomId[deviceAddr] == i_RoomId |
| | | && listDeleteKey.Contains(deviceAddr) == false) |
| | | { |
| | | listDeleteKey.Add(deviceAddr); |
| | | } |
| | | } |
| | | //将真实物理设备从房间中移除 |
| | | this.DeleteRealDeviceFromRoom(listDeleteKey); |
| | | } |
| | | |
| | | #endregion |
| | |
| | | //设备信息保存到本地 |
| | | device.Save(); |
| | | |
| | | string mainkeys = LocalDevice.Current.GetDeviceMainKeys(device); |
| | | string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device); |
| | | if (i_room.ListDevice.Contains(mainkeys) == false) |
| | | { |
| | | //保存到本地 |
| | | i_room.ListDevice.Add(mainkeys); |
| | | i_room.Save(); |
| | | |
| | | if (i_room.IsLove == false && saveRealRoom == true && LocalDevice.Current.GetDevicesCountByMac(device.DeviceAddr) == 1) |
| | | if (i_room.IsLove == false && saveRealRoom == true && HdlDeviceCommonLogic.Current.GetDevicesCountByMac(device.DeviceAddr) == 1) |
| | | { |
| | | //如果只有一个回路,则修改真实物理设备的房间 |
| | | this.SaveRealDeviceRoomId(new List<CommonDevice>() { device }, i_room.Id, false); |
| | |
| | | var loveRoom = this.GetLoveRoom(); |
| | | if (loveRoom != null) |
| | | { |
| | | string mainkeys = LocalDevice.Current.GetDeviceMainKeys(device); |
| | | string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device); |
| | | if (loveRoom.ListDevice.Contains(mainkeys) == false) |
| | | { |
| | | //保存到本地 |
| | |
| | | return; |
| | | } |
| | | //如果它只有一个回路 |
| | | if (deleteReal == true && LocalDevice.Current.GetDevicesCountByMac(device.DeviceAddr) == 1) |
| | | if (deleteReal == true && HdlDeviceCommonLogic.Current.GetDevicesCountByMac(device.DeviceAddr) == 1) |
| | | { |
| | | //删除掉它的真实物理设备的所在位置 |
| | | HdlRoomLogic.Current.DeleteRealDeviceFromRoom(device); |
| | |
| | | return; |
| | | } |
| | | //移除缓存 |
| | | string mainkeys = LocalDevice.Current.GetDeviceMainKeys(device); |
| | | string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device); |
| | | room.ListDevice.Remove(mainkeys); |
| | | room.Save(); |
| | | //更改自动备份 |
| | | HdlAutoBackupLogic.AddOrEditorFile(room.FileName); |
| | | HdlBackupLogic.Current.AddOrEditorAutoBackFileStatu(room.FileName); |
| | | |
| | | //递归:删除掉以前的旧数据导致的多个房间的问题 |
| | | this.DeleteDevice(device, deleteReal); |
| | |
| | | if (loveRoom != null) |
| | | { |
| | | //移除缓存 |
| | | string mainkeys = LocalDevice.Current.GetDeviceMainKeys(device); |
| | | string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device); |
| | | loveRoom.ListDevice.Remove(mainkeys); |
| | | loveRoom.Save(); |
| | | //更改自动备份 |
| | | HdlAutoBackupLogic.AddOrEditorFile(loveRoom.FileName); |
| | | HdlBackupLogic.Current.AddOrEditorAutoBackFileStatu(loveRoom.FileName); |
| | | //添加收藏设备时,需要刷新主页 |
| | | UserView.UserPage.Instance.RefreshAllForm = true; |
| | | } |
| | |
| | | var dicSort = new Dictionary<string, List<int>>(); |
| | | foreach (var mainKeys in i_room.ListDevice) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(mainKeys); |
| | | var device = HdlDeviceCommonLogic.Current.GetDevice(mainKeys); |
| | | if (device != null) |
| | | { |
| | | if (dicSort.ContainsKey(device.DeviceAddr) == false) |
| | |
| | | listEpont.Sort(); |
| | | for (int i = 0; i < listEpont.Count; i++) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(strMac, listEpont[i]); |
| | | var device = HdlDeviceCommonLogic.Current.GetDevice(strMac, listEpont[i]); |
| | | listDevice.Add(device); |
| | | } |
| | | } |
| | |
| | | var typeList = new List<DeviceType>(); |
| | | foreach (var mainKeys in i_room.ListDevice) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(mainKeys); |
| | | var device = HdlDeviceCommonLogic.Current.GetDevice(mainKeys); |
| | | if (device != null) |
| | | { |
| | | typeList.Add(device.Type); |
| | |
| | | List<CommonDevice> typeList = new List<CommonDevice>(); |
| | | foreach (var mainKeys in room.ListDevice) |
| | | { |
| | | var device = LocalDevice.Current.GetDevice(mainKeys); |
| | | var device = HdlDeviceCommonLogic.Current.GetDevice(mainKeys); |
| | | if (device != null && device.Type == deviceType) |
| | | { |
| | | typeList.Add(device); |
| | |
| | | } |
| | | |
| | | //所有设备 |
| | | var commonDeviceList = LocalDevice.Current.listAllDevice; |
| | | var commonDeviceList = HdlDeviceCommonLogic.Current.listAllDevice; |
| | | foreach (var device in commonDeviceList) |
| | | { |
| | | //判断该设备能否显示在主页 |
| | | if (LocalDevice.Current.CanShowInHomeHomeMainPage(device) == false) |
| | | if (HdlDeviceCommonLogic.Current.CanShowInHomeHomeMainPage(device) == false) |
| | | { |
| | | continue; |
| | | } |
| | | string mainkeys = LocalDevice.Current.GetDeviceMainKeys(device); |
| | | string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device); |
| | | if (listEsxit.Contains(mainkeys) == false) |
| | | { |
| | | listDevice.Add(device); |
| | |
| | | /// <returns></returns> |
| | | public bool IsCollectInRoom(CommonDevice device) |
| | | { |
| | | string mainkeys = LocalDevice.Current.GetDeviceMainKeys(device); |
| | | string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device); |
| | | //喜爱房间 |
| | | var room = this.GetLoveRoom(); |
| | | return room.ListDevice.Contains(mainkeys); |
| | |
| | | { |
| | | listName.Add(room.Name); |
| | | } |
| | | int numberLength = this.GetNumberMaxLength(listName); |
| | | int numberLength = HdlCommonLogic.Current.GetNumberMaxLength(listName); |
| | | |
| | | var listSort = new List<string[]>(); |
| | | foreach (var room in listRoom) |
| | |
| | | /// <summary> |
| | | /// 获取排序后的楼层 |
| | | /// </summary> |
| | | /// <param name="i_dicFloor">需要排序的楼层集合,如果设置为null,则会返回当前住宅排序了的楼层</param> |
| | | /// <returns></returns> |
| | | public Dictionary<string, string> GetFloorSortList() |
| | | public Dictionary<string, string> GetFloorSortList(Dictionary<string, string> i_dicFloor = null) |
| | | { |
| | | if (i_dicFloor == null) |
| | | { |
| | | i_dicFloor = Config.Instance.Home.FloorDics; |
| | | } |
| | | //没有楼层 |
| | | if (Config.Instance.Home.FloorDics.Count == 0) |
| | | if (i_dicFloor.Count == 0) |
| | | { |
| | | return new Dictionary<string, string>(); |
| | | } |
| | | //从一堆文字中,获取这一堆文字里面数字字符串的最长长度 |
| | | var listName = new List<string>(); |
| | | foreach (var floorName in Config.Instance.Home.FloorDics.Values) |
| | | foreach (var floorName in i_dicFloor.Values) |
| | | { |
| | | listName.Add(floorName); |
| | | } |
| | | int numberLength = this.GetNumberMaxLength(listName); |
| | | int numberLength = HdlCommonLogic.Current.GetNumberMaxLength(listName); |
| | | |
| | | var listSort = new List<string[]>(); |
| | | foreach (var floorId in Config.Instance.Home.FloorDics.Keys) |
| | | foreach (var floorId in i_dicFloor.Keys) |
| | | { |
| | | var strArry = new string[2]; |
| | | strArry[0] = floorId; |
| | | strArry[1] = string.Empty; |
| | | |
| | | string value = string.Empty; |
| | | string floorName = Config.Instance.Home.FloorDics[floorId]; |
| | | string floorName = i_dicFloor[floorId]; |
| | | foreach (var c in floorName) |
| | | { |
| | | if (char.IsNumber(c) == true) |
| | |
| | | var dic = new Dictionary<string, string>(); |
| | | foreach (var strArry in listSort) |
| | | { |
| | | dic[strArry[0]] = Config.Instance.Home.FloorDics[strArry[0]]; |
| | | dic[strArry[0]] = i_dicFloor[strArry[0]]; |
| | | } |
| | | return dic; |
| | | } |
| | |
| | | /// </summary> |
| | | public void SetRoomInfoToGateway() |
| | | { |
| | | if (UserCenterResourse.UserInfo.AuthorityNo != 1 && UserCenterResourse.UserInfo.AuthorityNo != 2) |
| | | if (HdlUserCenterResourse.ResidenceOption.AuthorityNo != 1 && HdlUserCenterResourse.ResidenceOption.AuthorityNo != 2) |
| | | { |
| | | //不是主人和管理员,则不处理 |
| | | return; |
| | |
| | | } |
| | | strSendDeviceRoomInfo += " " + this.SetDoublMark(device.DeviceAddr) + " "; |
| | | strSendDeviceRoomInfo += this.SetDoublMark("0x" + Convert.ToString(device.DeviceEpoint, 16).PadLeft(2, '0')) + " "; |
| | | strSendDeviceRoomInfo += this.SetDoublMark(LocalDevice.Current.GetDeviceEpointName(device).Replace(UserCenterResourse.douMarks, string.Empty)) + " "; |
| | | strSendDeviceRoomInfo += this.SetDoublMark(HdlDeviceCommonLogic.Current.GetDeviceEpointName(device).Replace(HdlUserCenterResourse.douMarks, string.Empty)) + " "; |
| | | strSendDeviceRoomInfo += this.SetDoublMark(room.Id); |
| | | } |
| | | } |
| | |
| | | var houseInfo = new AreaSpaceInfo(); |
| | | houseInfo.name = Common.Config.Instance.Home.Name; |
| | | houseInfo.uid = Common.Config.Instance.Home.Id; |
| | | houseInfo.parentId = null; |
| | | houseInfo.parentId = "null"; |
| | | listAreaSpaceInfo.Add(houseInfo); |
| | | //然后添加楼层 |
| | | foreach (var floorId in Common.Config.Instance.Home.FloorDics.Keys) |
| | |
| | | gatewayInfo.uid = "000101" + gwMac.Substring(2) + "07"; |
| | | gatewayInfo.name = HdlGatewayLogic.Current.GetGatewayName(loaclGateway); |
| | | |
| | | var roomGateway = HdlRoomLogic.Current.GetRoomByGateway(loaclGateway); |
| | | var roomGateway = this.GetRoomByGateway(loaclGateway.GwId); |
| | | if (roomGateway != null) |
| | | { |
| | | gatewayInfo.parentId = roomGateway.Id; |
| | |
| | | |
| | | HdlThreadLogic.Current.RunThread(async () => |
| | | { |
| | | //发送App的房间备份信息到网关(将来可能有用) |
| | | await this.SetAppRoomInfoBackUpToGateway(); |
| | | |
| | | //发送设备区域信息 |
| | | if (strSendDeviceRoomInfo != string.Empty) |
| | | { |
| | |
| | | { |
| | | return; |
| | | } |
| | | |
| | | } |
| | | |
| | | //创建文件对象 |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 发送App的房间备份信息到网关(将来可能有用) |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private async System.Threading.Tasks.Task SetAppRoomInfoBackUpToGateway() |
| | | { |
| | | //生成房间和楼层的json |
| | | var roomInfo = string.Empty; |
| | | HdlTemplateCommonLogic.Current.CrearWriteRoomTemplateData(ref roomInfo); |
| | | |
| | | var realMain = ZbGateway.MainGateWay; |
| | | //创建文件对象 |
| | | var result0 = await realMain.CreateFileAsync("AppFloorRoomInfo.json"); |
| | | if (result0 == null) |
| | | { |
| | | return; |
| | | } |
| | | if (result0.Result != 0 && result0.Result != 2) |
| | | { |
| | | //如果是2,允许上传 |
| | | return; |
| | | } |
| | | //发送数据流 |
| | | var byteData = ASCIIEncoding.UTF8.GetBytes(roomInfo); |
| | | var result1 = await realMain.SendFileAsync(byteData); |
| | | if (result1 == null || result1.Result != 0) |
| | | { |
| | | return; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 设置双引号 |
| | | /// </summary> |
| | | /// <param name="i_text"></param> |
| | | /// <returns></returns> |
| | | private string SetDoublMark(string i_text) |
| | | { |
| | | return UserCenterResourse.douMarks + i_text + UserCenterResourse.douMarks; |
| | | return HdlUserCenterResourse.douMarks + i_text + HdlUserCenterResourse.douMarks; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | love.Save(false); |
| | | this.dicRooms["Favorite"] = love; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 从一堆文字中,获取这一堆文字里面数字字符串的最长长度 |
| | | /// </summary> |
| | | /// <param name="listText"></param> |
| | | /// <returns></returns> |
| | | private int GetNumberMaxLength(List<string> listText) |
| | | { |
| | | int maxLength = 0; |
| | | foreach (var text in listText) |
| | | { |
| | | string value = string.Empty; |
| | | foreach (var c in text) |
| | | { |
| | | if (char.IsNumber(c) == true) |
| | | { |
| | | //数字 |
| | | value += c.ToString(); |
| | | continue; |
| | | } |
| | | else if (value != string.Empty) |
| | | { |
| | | //判断数字长度 |
| | | if (maxLength <= value.Length) |
| | | { |
| | | maxLength = value.Length; |
| | | } |
| | | value = string.Empty; |
| | | } |
| | | } |
| | | //判断数字长度 |
| | | if (maxLength <= value.Length) |
| | | { |
| | | maxLength = value.Length; |
| | | } |
| | | } |
| | | return maxLength; |
| | | } |
| | | |
| | | #endregion |