From 0d9f64668fd7350d6a21fd157e32009a96d98134 Mon Sep 17 00:00:00 2001 From: 黄学彪 <hxb@hdlchina.com.cn> Date: 星期三, 16 十二月 2020 13:09:08 +0800 Subject: [PATCH] 新云端代码Ver1.2 --- ZigbeeApp/Shared/Phone/Common/Logic/HdlRoomLogic.cs | 354 +++++++++++++++++++++++++++-------------------------------- 1 files changed, 162 insertions(+), 192 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlRoomLogic.cs b/ZigbeeApp/Shared/Phone/Common/Logic/HdlRoomLogic.cs similarity index 85% rename from ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlRoomLogic.cs rename to ZigbeeApp/Shared/Phone/Common/Logic/HdlRoomLogic.cs index b173072..ac738b2 100644 --- a/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlRoomLogic.cs +++ b/ZigbeeApp/Shared/Phone/Common/Logic/HdlRoomLogic.cs @@ -4,7 +4,7 @@ using System.Text; using ZigBee.Device; -namespace Shared.Phone.UserCenter +namespace Shared.Phone { /// <summary> /// 鎴块棿鐨勯�昏緫 @@ -43,10 +43,6 @@ /// 鎵�鏈夌殑鎴块棿淇℃伅 /// </summary> private Dictionary<string, Room> dicRooms = new Dictionary<string, Room>(); - /// <summary> - /// 鐗╃悊璁惧灞炰簬鍝釜鎴块棿鐨勮褰� - /// </summary> - private Dictionary<string, string> dicDeviceRoomId = null; #endregion @@ -67,6 +63,7 @@ this.CheckLoveRoom(); var listFile = HdlFileLogic.Current.GetRootPathListFile(); + var listEsixtMac = new List<string>(); foreach (var fileName in listFile) { if (fileName.StartsWith("Room_") == true) @@ -75,10 +72,18 @@ 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(); //鍒锋柊鎴块棿瑙嗗浘鍒楄〃 @@ -109,7 +114,7 @@ } } //妫�娴嬫ゼ灞傛暟鎹殑鍚堟硶鎬� - if (UserCenterResourse.UserInfo.AuthorityNo == 3) + if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 3) { this.CheckMemberFloorData(listRoomFile); } @@ -204,6 +209,34 @@ 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 鈻� 娣诲姞鎴块棿___________________________ @@ -224,7 +257,7 @@ //鐢熸垚鏂囦欢 room.Save(); //澶囦唤 - HdlAutoBackupLogic.AddOrEditorFile(room.FileName); + HdlBackupLogic.Current.AddOrEditorAutoBackFileStatu(room.FileName); if (refreshRoomView == true) { //鍒锋柊鎴块棿瑙嗗浘鍒楄〃 @@ -269,7 +302,7 @@ { Global.DeleteFilebyHomeId(room.BackgroundImage); //鍒犻櫎澶囦唤 - HdlAutoBackupLogic.DeleteFile(room.BackgroundImage); + HdlBackupLogic.Current.DeleteAutoBackFileStatu(room.BackgroundImage); } } //鎴戠殑鍠滅埍 @@ -296,10 +329,8 @@ //鍒犻櫎鏂囦欢 Global.DeleteFilebyHomeId(roomFilePath); } - HdlAutoBackupLogic.DeleteFile(roomFilePath); + HdlBackupLogic.Current.DeleteAutoBackFileStatu(roomFilePath); - //鏍规嵁鎴块棿ID,绉婚櫎鎸囧畾鐨勭湡瀹炵墿鐞嗚澶囩殑鎵�灞炴埧闂磋褰� - HdlRoomLogic.Current.DeleteRealDeviceByRoomId(roomId); if (refreshLeftView == true) { //鍒锋柊鎴块棿瑙嗗浘鍒楄〃 @@ -415,7 +446,7 @@ /// <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) @@ -549,26 +580,18 @@ /// <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> @@ -578,43 +601,17 @@ /// <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> /// 淇濆瓨鐗╃悊璁惧鎵�灞炴埧闂寸殑璁板綍 @@ -634,42 +631,29 @@ 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杩藉姞:濡傛灉璁板綍鐨勬埧闂碔D鏄笉瀛樺湪鐨勮瘽,鍒欓噸鏂拌鐩� - 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); } } @@ -680,13 +664,13 @@ /// <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> @@ -696,11 +680,19 @@ /// <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> @@ -719,44 +711,22 @@ /// <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 @@ -835,14 +805,14 @@ //璁惧淇℃伅淇濆瓨鍒版湰鍦� 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); @@ -864,7 +834,7 @@ 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) { //淇濆瓨鍒版湰鍦� @@ -892,7 +862,7 @@ return; } //濡傛灉瀹冨彧鏈変竴涓洖璺� - if (deleteReal == true && LocalDevice.Current.GetDevicesCountByMac(device.DeviceAddr) == 1) + if (deleteReal == true && HdlDeviceCommonLogic.Current.GetDevicesCountByMac(device.DeviceAddr) == 1) { //鍒犻櫎鎺夊畠鐨勭湡瀹炵墿鐞嗚澶囩殑鎵�鍦ㄤ綅缃� HdlRoomLogic.Current.DeleteRealDeviceFromRoom(device); @@ -905,11 +875,11 @@ 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); @@ -930,11 +900,11 @@ 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; } @@ -953,7 +923,7 @@ 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) @@ -971,7 +941,7 @@ 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); } } @@ -988,7 +958,7 @@ 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); @@ -1008,7 +978,7 @@ 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); @@ -1045,15 +1015,15 @@ } //鎵�鏈夎澶� - 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); @@ -1091,7 +1061,7 @@ /// <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); @@ -1157,7 +1127,7 @@ { 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) @@ -1211,31 +1181,36 @@ /// <summary> /// 鑾峰彇鎺掑簭鍚庣殑妤煎眰 /// </summary> + /// <param name="i_dicFloor">闇�瑕佹帓搴忕殑妤煎眰闆嗗悎,濡傛灉璁剧疆涓簄ull,鍒欎細杩斿洖褰撳墠浣忓畢鎺掑簭浜嗙殑妤煎眰</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) @@ -1271,7 +1246,7 @@ 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; } @@ -1285,7 +1260,7 @@ /// </summary> public void SetRoomInfoToGateway() { - if (UserCenterResourse.UserInfo.AuthorityNo != 1 && UserCenterResourse.UserInfo.AuthorityNo != 2) + if (HdlUserCenterResourse.ResidenceOption.AuthorityNo != 1 && HdlUserCenterResourse.ResidenceOption.AuthorityNo != 2) { //涓嶆槸涓讳汉鍜岀鐞嗗憳,鍒欎笉澶勭悊 return; @@ -1314,7 +1289,7 @@ } 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); } } @@ -1324,7 +1299,7 @@ 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) @@ -1367,7 +1342,7 @@ 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; @@ -1383,6 +1358,9 @@ HdlThreadLogic.Current.RunThread(async () => { + //鍙戦�丄pp鐨勬埧闂村浠戒俊鎭埌缃戝叧(灏嗘潵鍙兘鏈夌敤) + await this.SetAppRoomInfoBackUpToGateway(); + //鍙戦�佽澶囧尯鍩熶俊鎭� if (strSendDeviceRoomInfo != string.Empty) { @@ -1404,7 +1382,6 @@ { return; } - } //鍒涘缓鏂囦欢瀵硅薄 @@ -1426,13 +1403,44 @@ } /// <summary> + /// 鍙戦�丄pp鐨勬埧闂村浠戒俊鎭埌缃戝叧(灏嗘潵鍙兘鏈夌敤) + /// </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> @@ -1598,44 +1606,6 @@ 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 -- Gitblit v1.8.0