From e90209beae6a4e822cecb18e6889f8bda23f630e Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期一, 14 十二月 2020 11:16:06 +0800
Subject: [PATCH] 合并了晾衣架(非新云端)

---
 ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlRoomLogic.cs |  327 ++++++++++++++++++++++++++++++------------------------
 1 files changed, 181 insertions(+), 146 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/Common/Logic/HdlRoomLogic.cs b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlRoomLogic.cs
similarity index 86%
rename from ZigbeeApp/Shared/Phone/Common/Logic/HdlRoomLogic.cs
rename to ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlRoomLogic.cs
index 7373ce4..b173072 100644
--- a/ZigbeeApp/Shared/Phone/Common/Logic/HdlRoomLogic.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/CommonBase/Logic/HdlRoomLogic.cs
@@ -4,7 +4,7 @@
 using System.Text;
 using ZigBee.Device;
 
-namespace Shared.Phone
+namespace Shared.Phone.UserCenter
 {
     /// <summary>
     /// 鎴块棿鐨勯�昏緫
@@ -43,6 +43,10 @@
         /// 鎵�鏈夌殑鎴块棿淇℃伅
         /// </summary>
         private Dictionary<string, Room> dicRooms = new Dictionary<string, Room>();
+        /// <summary>
+        /// 鐗╃悊璁惧灞炰簬鍝釜鎴块棿鐨勮褰�
+        /// </summary>
+        private Dictionary<string, string> dicDeviceRoomId = null;
 
         #endregion
 
@@ -63,7 +67,6 @@
             this.CheckLoveRoom();
 
             var listFile = HdlFileLogic.Current.GetRootPathListFile();
-            var listEsixtMac = new List<string>();
             foreach (var fileName in listFile)
             {
                 if (fileName.StartsWith("Room_") == true)
@@ -72,18 +75,10 @@
                     var room = this.GetRoomByFilePath(fileName);
                     if (room != null)
                     {
-                        this.dicRooms[room.Id] = room;
-                        //鑾峰彇宸茬粡瀛樺湪浜嗙殑Mac
-                        listEsixtMac.AddRange(room.ListDeviceMac);
+                        this.dicRooms[room.Id] = (room);
                     }
                 }
             }
-            //妫�鏌ョ湡瀹炵墿鐞嗚澶囩殑鎵�鍦ㄧ殑鎴块棿鏃跺�欐湁閬楁紡
-            foreach (var room in this.dicRooms.Values)
-            {
-                this.CheckRealDeviceRoom(room, ref listEsixtMac);
-            }
-
             //椤轰究鍒锋柊鍦烘櫙
             HdlSceneLogic.Current.ReFreshByLocal();
             //鍒锋柊鎴块棿瑙嗗浘鍒楄〃
@@ -114,7 +109,7 @@
                 }
             }
             //妫�娴嬫ゼ灞傛暟鎹殑鍚堟硶鎬�
-            if (HdlUserCenterResourse.ResidenceOption.AuthorityNo == 3)
+            if (UserCenterResourse.UserInfo.AuthorityNo == 3)
             {
                 this.CheckMemberFloorData(listRoomFile);
             }
@@ -207,34 +202,6 @@
                 Config.Instance.Home.FloorDics.Remove(deleteId);
             }
             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
@@ -331,6 +298,8 @@
             }
             HdlAutoBackupLogic.DeleteFile(roomFilePath);
 
+            //鏍规嵁鎴块棿ID,绉婚櫎鎸囧畾鐨勭湡瀹炵墿鐞嗚澶囩殑鎵�灞炴埧闂磋褰�
+            HdlRoomLogic.Current.DeleteRealDeviceByRoomId(roomId);
             if (refreshLeftView == true)
             {
                 //鍒锋柊鎴块棿瑙嗗浘鍒楄〃
@@ -446,7 +415,7 @@
         /// <param name="device">璁惧瀵硅薄</param>
         public Room GetRoomByDevice(CommonDevice device)
         {
-            string mainKeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
+            string mainKeys = LocalDevice.Current.GetDeviceMainKeys(device);
             foreach (var room in this.dicRooms.Values)
             {
                 if (room.IsLove == true)
@@ -580,18 +549,26 @@
         /// <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)
         {
-            foreach (var room in this.dicRooms.Values)
+            var localGateway = HdlGatewayLogic.Current.GetLocalGateway(gatewayId);
+            if (localGateway == null)
             {
-                if (room.ListDeviceMac.Contains(gatewayId) == true)
-                {
-                    return room;
-                }
+                return null;
             }
-            return null;
+            return HdlRoomLogic.Current.GetRoomById(localGateway.RoomId);
         }
 
         /// <summary>
@@ -601,17 +578,43 @@
         /// <param name="roomId">鎴块棿ID</param>
         public void ChangedGatewayRoom(string gwId, string roomId)
         {
-            var room = this.GetRoomById(roomId);
-            if (room != null && room.ListDeviceMac.Contains(gwId) == false)
+            var localGateway = HdlGatewayLogic.Current.GetLocalGateway(gwId);
+            if (localGateway != null)
             {
-                room.ListDeviceMac.Add(gwId);
-                room.Save();
+                localGateway.RoomId = roomId;
+                localGateway.ReSave();
+                //娣诲姞澶囦唤
+                HdlAutoBackupLogic.AddOrEditorFile(localGateway.FilePath);
             }
         }
 
         #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>
         /// 淇濆瓨鐗╃悊璁惧鎵�灞炴埧闂寸殑璁板綍
@@ -631,29 +634,42 @@
                 if ((listDevice[0] is OTADevice) == false)
                 {
                     //ota璁惧涓嶉渶瑕佸鐞�
-                    this.ChangedRoom(listDevice[0], roomId, false);
+                    HdlRoomLogic.Current.ChangedRoom(listDevice[0], roomId, false);
                 }
             }
+            bool save = false;
             if (roomId == string.Empty)
             {
-                //鐪熷疄鐗╃悊璁惧鎵�鍦ㄧ殑鎴块棿
-                var realRoom = this.GeteRealDeviceRoom(listDevice[0]);
-                if (realRoom != null && realRoom.ListDeviceMac.Contains(listDevice[0].DeviceAddr) == true)
-                {
-                    //閫夋嫨鐨勬槸鏈垎閰�
-                    realRoom.ListDeviceMac.Remove(listDevice[0].DeviceAddr);
-                    realRoom.Save();
-                }
+                //閫夋嫨鐨勬槸鏈垎閰�
+                this.dicDeviceRoomId.Remove(listDevice[0].DeviceAddr);
+                save = true;
             }
             else
             {
-                //鐪熷疄鐗╃悊璁惧鎵�鍦ㄧ殑鎴块棿
-                var realRoom = this.GetRoomById(roomId);
-                if (realRoom != null && realRoom.ListDeviceMac.Contains(listDevice[0].DeviceAddr) == false)
+                if (this.dicDeviceRoomId.ContainsKey(listDevice[0].DeviceAddr) == false)
                 {
-                    realRoom.ListDeviceMac.Add(listDevice[0].DeviceAddr);
-                    realRoom.Save();
+                    this.dicDeviceRoomId[listDevice[0].DeviceAddr] = roomId;
+                    save = true;
                 }
+                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);
             }
         }
 
@@ -664,13 +680,13 @@
         /// <returns></returns>
         public string GeteRealDeviceRoomName(CommonDevice device)
         {
-            var room = this.GeteRealDeviceRoom(device);
-            if (room == null)
+            if (this.dicDeviceRoomId.ContainsKey(device.DeviceAddr) == false)
             {
                 //鏈垎閰嶅尯鍩�
                 return Language.StringByID(R.MyInternationalizationString.uDeviceNotAssignedRoom);
             }
-            return this.GetRoomName(room);
+            var room = HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
+            return HdlRoomLogic.Current.GetRoomName(room);
         }
 
         /// <summary>
@@ -680,19 +696,11 @@
         /// <returns></returns>
         public Room GeteRealDeviceRoom(CommonDevice device)
         {
-            foreach (var room in this.dicRooms.Values)
+            if (this.dicDeviceRoomId.ContainsKey(device.DeviceAddr) == false)
             {
-                if (room.IsLove == true)
-                {
-                    //鍠滅埍鎴块棿涓嶅鐞�
-                    continue;
-                }
-                if (room.ListDeviceMac.Contains(device.DeviceAddr) == true)
-                {
-                    return room;
-                }
+                return null;
             }
-            return null;
+            return HdlRoomLogic.Current.GetRoomById(this.dicDeviceRoomId[device.DeviceAddr]);
         }
 
         /// <summary>
@@ -711,22 +719,44 @@
         /// <param name="listMac">璁惧Mac鍦板潃</param>
         public void DeleteRealDeviceFromRoom(List<string> listMac)
         {
-            foreach (var room in this.dicRooms.Values)
+            bool save = false;
+            foreach (var deviceMacAddr in listMac)
             {
-                bool save = false;
-                foreach (var strMac in listMac)
+                if (this.dicDeviceRoomId.ContainsKey(deviceMacAddr) == true)
                 {
-                    if (room.ListDeviceMac.Contains(strMac) == true)
-                    {
-                        room.ListDeviceMac.Remove(strMac);
-                        save = true;
-                    }
-                }
-                if (save == true)
-                {
-                    room.Save();
+                    this.dicDeviceRoomId.Remove(deviceMacAddr);
+                    save = true;
                 }
             }
+            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
@@ -805,14 +835,14 @@
             //璁惧淇℃伅淇濆瓨鍒版湰鍦�
             device.Save();
 
-            string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
+            string mainkeys = LocalDevice.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 && HdlDeviceCommonLogic.Current.GetDevicesCountByMac(device.DeviceAddr) == 1)
+                if (i_room.IsLove == false && saveRealRoom == true && LocalDevice.Current.GetDevicesCountByMac(device.DeviceAddr) == 1)
                 {
                     //濡傛灉鍙湁涓�涓洖璺�,鍒欎慨鏀圭湡瀹炵墿鐞嗚澶囩殑鎴块棿
                     this.SaveRealDeviceRoomId(new List<CommonDevice>() { device }, i_room.Id, false);
@@ -834,7 +864,7 @@
             var loveRoom = this.GetLoveRoom();
             if (loveRoom != null)
             {
-                string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
+                string mainkeys = LocalDevice.Current.GetDeviceMainKeys(device);
                 if (loveRoom.ListDevice.Contains(mainkeys) == false)
                 {
                     //淇濆瓨鍒版湰鍦�
@@ -862,7 +892,7 @@
                 return;
             }
             //濡傛灉瀹冨彧鏈変竴涓洖璺�
-            if (deleteReal == true && HdlDeviceCommonLogic.Current.GetDevicesCountByMac(device.DeviceAddr) == 1)
+            if (deleteReal == true && LocalDevice.Current.GetDevicesCountByMac(device.DeviceAddr) == 1)
             {
                 //鍒犻櫎鎺夊畠鐨勭湡瀹炵墿鐞嗚澶囩殑鎵�鍦ㄤ綅缃�
                 HdlRoomLogic.Current.DeleteRealDeviceFromRoom(device);
@@ -875,7 +905,7 @@
                 return;
             }
             //绉婚櫎缂撳瓨
-            string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
+            string mainkeys = LocalDevice.Current.GetDeviceMainKeys(device);
             room.ListDevice.Remove(mainkeys);
             room.Save();
             //鏇存敼鑷姩澶囦唤
@@ -900,7 +930,7 @@
             if (loveRoom != null)
             {
                 //绉婚櫎缂撳瓨
-                string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
+                string mainkeys = LocalDevice.Current.GetDeviceMainKeys(device);
                 loveRoom.ListDevice.Remove(mainkeys);
                 loveRoom.Save();
                 //鏇存敼鑷姩澶囦唤
@@ -923,7 +953,7 @@
             var dicSort = new Dictionary<string, List<int>>();
             foreach (var mainKeys in i_room.ListDevice)
             {
-                var device = HdlDeviceCommonLogic.Current.GetDevice(mainKeys);
+                var device = LocalDevice.Current.GetDevice(mainKeys);
                 if (device != null)
                 {
                     if (dicSort.ContainsKey(device.DeviceAddr) == false)
@@ -941,7 +971,7 @@
                 listEpont.Sort();
                 for (int i = 0; i < listEpont.Count; i++)
                 {
-                    var device = HdlDeviceCommonLogic.Current.GetDevice(strMac, listEpont[i]);
+                    var device = LocalDevice.Current.GetDevice(strMac, listEpont[i]);
                     listDevice.Add(device);
                 }
             }
@@ -958,7 +988,7 @@
             var typeList = new List<DeviceType>();
             foreach (var mainKeys in i_room.ListDevice)
             {
-                var device = HdlDeviceCommonLogic.Current.GetDevice(mainKeys);
+                var device = LocalDevice.Current.GetDevice(mainKeys);
                 if (device != null)
                 {
                     typeList.Add(device.Type);
@@ -978,7 +1008,7 @@
             List<CommonDevice> typeList = new List<CommonDevice>();
             foreach (var mainKeys in room.ListDevice)
             {
-                var device = HdlDeviceCommonLogic.Current.GetDevice(mainKeys);
+                var device = LocalDevice.Current.GetDevice(mainKeys);
                 if (device != null && device.Type == deviceType)
                 {
                     typeList.Add(device);
@@ -1015,15 +1045,15 @@
             }
 
             //鎵�鏈夎澶�
-            var commonDeviceList = HdlDeviceCommonLogic.Current.listAllDevice;
+            var commonDeviceList = LocalDevice.Current.listAllDevice;
             foreach (var device in commonDeviceList)
             {
                 //鍒ゆ柇璇ヨ澶囪兘鍚︽樉绀哄湪涓婚〉
-                if (HdlDeviceCommonLogic.Current.CanShowInHomeHomeMainPage(device) == false)
+                if (LocalDevice.Current.CanShowInHomeHomeMainPage(device) == false)
                 {
                     continue;
                 }
-                string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
+                string mainkeys = LocalDevice.Current.GetDeviceMainKeys(device);
                 if (listEsxit.Contains(mainkeys) == false)
                 {
                     listDevice.Add(device);
@@ -1061,7 +1091,7 @@
         /// <returns></returns>
         public bool IsCollectInRoom(CommonDevice device)
         {
-            string mainkeys = HdlDeviceCommonLogic.Current.GetDeviceMainKeys(device);
+            string mainkeys = LocalDevice.Current.GetDeviceMainKeys(device);
             //鍠滅埍鎴块棿
             var room = this.GetLoveRoom();
             return room.ListDevice.Contains(mainkeys);
@@ -1127,7 +1157,7 @@
             {
                 listName.Add(room.Name);
             }
-            int numberLength = HdlCommonLogic.Current.GetNumberMaxLength(listName);
+            int numberLength = this.GetNumberMaxLength(listName);
 
             var listSort = new List<string[]>();
             foreach (var room in listRoom)
@@ -1195,7 +1225,7 @@
             {
                 listName.Add(floorName);
             }
-            int numberLength = HdlCommonLogic.Current.GetNumberMaxLength(listName);
+            int numberLength = this.GetNumberMaxLength(listName);
 
             var listSort = new List<string[]>();
             foreach (var floorId in Config.Instance.Home.FloorDics.Keys)
@@ -1255,7 +1285,7 @@
         /// </summary>
         public void SetRoomInfoToGateway()
         {
-            if (HdlUserCenterResourse.ResidenceOption.AuthorityNo != 1 && HdlUserCenterResourse.ResidenceOption.AuthorityNo != 2)
+            if (UserCenterResourse.UserInfo.AuthorityNo != 1 && UserCenterResourse.UserInfo.AuthorityNo != 2)
             {
                 //涓嶆槸涓讳汉鍜岀鐞嗗憳,鍒欎笉澶勭悊
                 return;
@@ -1284,7 +1314,7 @@
                     }
                     strSendDeviceRoomInfo += " " + this.SetDoublMark(device.DeviceAddr) + " ";
                     strSendDeviceRoomInfo += this.SetDoublMark("0x" + Convert.ToString(device.DeviceEpoint, 16).PadLeft(2, '0')) + " ";
-                    strSendDeviceRoomInfo += this.SetDoublMark(HdlDeviceCommonLogic.Current.GetDeviceEpointName(device).Replace(HdlUserCenterResourse.douMarks, string.Empty)) + " ";
+                    strSendDeviceRoomInfo += this.SetDoublMark(LocalDevice.Current.GetDeviceEpointName(device).Replace(UserCenterResourse.douMarks, string.Empty)) + " ";
                     strSendDeviceRoomInfo += this.SetDoublMark(room.Id);
                 }
             }
@@ -1294,7 +1324,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)
@@ -1337,7 +1367,7 @@
             gatewayInfo.uid = "000101" + gwMac.Substring(2) + "07";
             gatewayInfo.name = HdlGatewayLogic.Current.GetGatewayName(loaclGateway);
 
-            var roomGateway = this.GetRoomByGateway(loaclGateway.GwId);
+            var roomGateway = HdlRoomLogic.Current.GetRoomByGateway(loaclGateway);
             if (roomGateway != null)
             {
                 gatewayInfo.parentId = roomGateway.Id;
@@ -1353,9 +1383,6 @@
 
             HdlThreadLogic.Current.RunThread(async () =>
             {
-                //鍙戦�丄pp鐨勬埧闂村浠戒俊鎭埌缃戝叧(灏嗘潵鍙兘鏈夌敤)
-                await this.SetAppRoomInfoBackUpToGateway();
-
                 //鍙戦�佽澶囧尯鍩熶俊鎭�
                 if (strSendDeviceRoomInfo != string.Empty)
                 {
@@ -1377,6 +1404,7 @@
                     {
                         return;
                     }
+
                 }
 
                 //鍒涘缓鏂囦欢瀵硅薄
@@ -1398,44 +1426,13 @@
         }
 
         /// <summary>
-        /// 鍙戦�丄pp鐨勬埧闂村浠戒俊鎭埌缃戝叧(灏嗘潵鍙兘鏈夌敤)
-        /// </summary>
-        /// <returns></returns>
-        private async System.Threading.Tasks.Task SetAppRoomInfoBackUpToGateway()
-        {
-            //鐢熸垚鎴块棿鍜屾ゼ灞傜殑json
-            var roomInfo = string.Empty;
-            TemplateData.TemplateCommonLogic.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 HdlUserCenterResourse.douMarks + i_text + HdlUserCenterResourse.douMarks;
+            return UserCenterResourse.douMarks + i_text + UserCenterResourse.douMarks;
         }
 
         /// <summary>
@@ -1603,6 +1600,44 @@
             }
         }
 
+        /// <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