From fe3b2466c68b5db70d38e78039703add3b8b1dfe Mon Sep 17 00:00:00 2001
From: 黄学彪 <hxb@hdlchina.com.cn>
Date: 星期四, 31 十二月 2020 19:29:43 +0800
Subject: [PATCH] 合并了代码

---
 ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedListRoomForm.cs |  111 ++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 85 insertions(+), 26 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedListRoomForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedListRoomForm.cs
index 6eae1ad..7feed80 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedListRoomForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/LookSharedListRoomForm.cs
@@ -18,9 +18,13 @@
         /// </summary>
         private VerticalFrameControl listView = null;
         /// <summary>
-        /// 鎴愬憳ID
+        /// 鎴愬憳淇℃伅
         /// </summary>
-        private string ChildAccountId = string.Empty;
+        private MemberInfoRes memberResult = null;
+        /// <summary>
+        /// 鎴愬憳鐨勫垎浜暟鎹�
+        /// </summary>
+        private MemberShardInfoData memberShardInfo = null;
 
         #endregion
 
@@ -31,9 +35,11 @@
         /// </summary>
         /// <param name="i_memberResult">鎴愬憳淇℃伅</param>
         /// <param name="i_memberShardInfo">鎴愬憳鐨勫叡浜俊鎭�</param>
-        public void ShowForm(string i_ChildAccountId)
+        public void ShowForm(MemberInfoRes i_memberResult, MemberShardInfoData i_memberShardInfo)
         {
-            this.ChildAccountId = i_ChildAccountId;
+            this.memberResult = i_memberResult;
+            this.memberShardInfo = i_memberShardInfo;
+            this.memberShardInfo.SubAccountDistributedMark = this.memberResult.SubAccountDistributedMark;
 
             //璁剧疆澶撮儴淇℃伅
             base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uShared2));
@@ -44,7 +50,7 @@
             btnAdd.ButtonClickEvent += (sender, e) =>
             {
                 var form = new AddNewSharedListRoomForm();
-                form.AddForm(this.ChildAccountId);
+                form.AddForm(this.memberResult, this.memberShardInfo);
             };
             topFrameLayout.AddChidren(btnAdd);
             btnAdd.InitControl();
@@ -63,8 +69,8 @@
 
             HdlThreadLogic.Current.RunThread(() =>
             {
-                //鍒濆鍖栨垚鍛樼殑鍏变韩鍒楄〃
-                var result = HdlShardLogic.Current.InitMemberShardContentListAndSetToLocation(this.ChildAccountId);
+                //鑾峰彇鎴愬憳鐨勫叡浜垪琛�
+                var result = HdlShardLogic.Current.GetMemberShardContentListAndSetToLocation(memberShardInfo);
                 if (result == false)
                 {
                     //鏄剧ず閲嶆柊鍔犺浇鐨勭晫闈�
@@ -85,8 +91,7 @@
         /// </summary>
         private void InitAreaListRow()
         {
-            var dicShardRoom = HdlShardLogic.Current.GetShardRoomFromMemory();
-            if (dicShardRoom.Count == 0)
+            if (memberShardInfo.dicShardRoom.Count == 0)
             {
                 HdlThreadLogic.Current.RunMain(() =>
                 {
@@ -101,7 +106,7 @@
             {
                 //鍚堝苟鍚屼竴妤煎眰鐨勬埧闂�
                 var dicGroup = new Dictionary<string, List<Common.Room>>();
-                foreach (var room in dicShardRoom.Values)
+                foreach (var room in memberShardInfo.dicShardRoom.Values)
                 {
                     if (dicGroup.ContainsKey(room.FloorId) == false)
                     {
@@ -109,9 +114,6 @@
                     }
                     dicGroup[room.FloorId].Add(room);
                 }
-                //鑾峰彇鍒嗕韩鐨勬ゼ灞�(鎺掑簭)
-                var dicSortFloor = HdlShardLogic.Current.GetShardFloorFormMemory();
-                dicSortFloor = HdlRoomLogic.Current.GetFloorSortList(dicSortFloor);
 
                 HdlThreadLogic.Current.RunMain(() =>
                 {
@@ -121,19 +123,21 @@
                     listView.Height = bodyFrameLayout.Height;
                     bodyFrameLayout.AddChidren(listView);
 
-                    foreach (var floorId in dicSortFloor.Keys)
+                    //鎺掑簭妤煎眰
+                    var dicSort = HdlRoomLogic.Current.GetFloorSortList();
+                    foreach (var floorId in dicSort.Keys)
                     {
                         if (dicGroup.ContainsKey(floorId) == true)
                         {
                             //娣诲姞鍚勮嚜妤煎眰鐨勬埧闂村垪琛�
-                            this.AddRoomListRow(floorId, dicSortFloor[floorId], dicGroup[floorId]);
+                            this.AddRoomListRow(floorId, dicGroup[floorId]);
                             dicGroup.Remove(floorId);
                         }
                     }
                     //娣诲姞鍚勮嚜妤煎眰鐨勬埧闂村垪琛�(杩欓噷鏄寚瀹氭ゼ灞傚苟涓嶅湪鎺掑簭璁板綍閲岄潰鐨�)
                     foreach (var floorId in dicGroup.Keys)
                     {
-                        this.AddRoomListRow(floorId, string.Empty, dicGroup[floorId]);
+                        this.AddRoomListRow(floorId, dicGroup[floorId]);
                     }
                     //璋冩暣妗屽竷楂樺害
                     listView.AdjustTableHeight();
@@ -145,7 +149,7 @@
         /// 娣诲姞鎴块棿鍒楄〃琛�
         /// </summary>
         /// <param name="listRoom"></param>
-        private void AddRoomListRow(string floorId, string floorName, List<Common.Room> listRoom)
+        private void AddRoomListRow(string floorId, List<Common.Room> listRoom)
         {
             var frameBack = new FrameListControl(29);
             frameBack.BackgroundColor = UserCenterColor.Current.White;
@@ -156,14 +160,14 @@
             if (string.IsNullOrEmpty(floorId) == false)
             {
                 var btnFloor = new NormalViewControl(800, 60, true);
-                btnFloor.X = HdlControlResourse.XXLeft;
+                btnFloor.X = ControlCommonResourse.XXLeft;
                 btnFloor.Y = Application.GetRealHeight(52);
                 btnFloor.TextColor = UserCenterColor.Current.TextColor2;
                 btnFloor.TextSize = 15;
                 frameBack.AddChidren(btnFloor);
-                if (floorName != string.Empty)
+                if (memberShardInfo.dicShardFloor.ContainsKey(floorId) == true)
                 {
-                    btnFloor.Text = floorName;
+                    btnFloor.Text = memberShardInfo.dicShardFloor[floorId];
                 }
                 else if (floorId == "Other")
                 {
@@ -176,10 +180,34 @@
                 }
             }
             //鎴块棿鎺掑簭
-            var listSortRoom = HdlRoomLogic.Current.SortRoom(listRoom);
-            for (int i = 0; i < listSortRoom.Count; i++)
+            var listSortRoom = HdlRoomLogic.Current.GetFloorSortRoom(floorId, false);
+            var listSort = new HashSet<string>();
+            foreach (var room in listSortRoom)
             {
-                var room = listSortRoom[i];
+                //鏀堕泦鐜版湁鐨勬帓搴廔D
+                listSort.Add(room.Id);
+            }
+            var dicRoom = new Dictionary<string, Common.Room>();
+            foreach (var room in listRoom)
+            {
+                //淇濆瓨闇�瑕佹樉绀哄嚭鏉ョ殑鎴块棿
+                dicRoom[room.Id] = room;
+                if (listSort.Contains(room.Id) == false)
+                {
+                    //涓嶅啀鎺掑簭璁板綍鍐�,鍒欏湪灏鹃儴杩藉姞
+                    listSort.Add(room.Id);
+                }
+            }
+
+            foreach(var roomId in listSort)
+            {
+                if (dicRoom.ContainsKey(roomId) == false)
+                {
+                    continue;
+                }
+                var room = dicRoom[roomId];
+                dicRoom.Remove(roomId);
+
                 var frameRow = new RowLayoutControl(frameBack.rowSpace / 2);
                 frameBack.AddChidren(frameRow);
                 //鍥炬爣
@@ -190,7 +218,7 @@
                 btnName.TextSize = 15;
                 //鍙崇澶�
                 frameRow.frameTable.AddRightArrow();
-                if (i != listSortRoom.Count - 1)
+                if (dicRoom.Count != 0)
                 {
                     //搴曠嚎
                     frameRow.frameTable.AddBottomLine();
@@ -198,7 +226,7 @@
                 frameRow.frameTable.ButtonClickEvent += (sender, e) =>
                 {
                     var form = new LookSharedContentForm();
-                    form.AddForm(room, this.ChildAccountId);
+                    form.AddForm(room, memberShardInfo);
                 };
 
                 //鍒犻櫎
@@ -233,10 +261,41 @@
         /// <param name="room">鎸囧畾瑕佸垹闄ょ殑鍏变韩鍖哄煙</param>
         public void DoDeleteShardContentByRoom(Common.Room room)
         {
+            //鑾峰彇鍏ㄩ儴璁惧
+            var listDevice = new List<CommonDevice>();
+            foreach (var deviceKeys in room.ListDevice)
+            {
+                string deviceFile = HdlShardLogic.Current.GetShardDeviceFileName(deviceKeys);
+                if (deviceFile == string.Empty)
+                {
+                    continue;
+                }
+                var byteData = HdlShardLogic.Current.GetShardFileContent(deviceFile);
+                if (byteData == null)
+                {
+                    continue;
+                }
+                var device = Newtonsoft.Json.JsonConvert.DeserializeObject<CommonDevice>(System.Text.Encoding.UTF8.GetString(byteData));
+                device.Type = (DeviceType)device.DeviceID;
+                listDevice.Add(device);
+            }
+            //鑾峰彇鍏ㄩ儴鍦烘櫙
+            var listScene = new List<Common.SceneUI>();
+            foreach (var sceneId in room.ListSceneId)
+            {
+                var byteData = HdlShardLogic.Current.GetShardFileContent($"Scene_{sceneId}.json");
+                if (byteData == null)
+                {
+                    continue;
+                }
+                var sceneUi = Newtonsoft.Json.JsonConvert.DeserializeObject<Common.SceneUI>(System.Text.Encoding.UTF8.GetString(byteData));
+                listScene.Add(sceneUi);
+            }
+
             HdlThreadLogic.Current.RunThread(() =>
             {
                 //鎵ц鍒犻櫎
-                var result = HdlShardLogic.Current.DeleteSharedRoom(this.ChildAccountId, new List<Common.Room> { room });
+                var result = HdlShardLogic.Current.DoDeleteSharedContent(memberShardInfo, room, listDevice, listScene);
                 if (result == true)
                 {
                     HdlThreadLogic.Current.RunMain(() =>

--
Gitblit v1.8.0