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/UserCenter/SharedContent/AddNewSharedListRoomForm.cs |  175 ++++++++--------------------------------------------------
 1 files changed, 24 insertions(+), 151 deletions(-)

diff --git a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedListRoomForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedListRoomForm.cs
index 6f0377a..98b9962 100755
--- a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedListRoomForm.cs
+++ b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedListRoomForm.cs
@@ -22,13 +22,9 @@
         /// </summary>
         private BottomClickButton btnShard = null;
         /// <summary>
-        /// 鎴愬憳淇℃伅
+        /// 鎴愬憳ID
         /// </summary>
-        private MemberInfoRes memberResult = null;
-        /// <summary>
-        /// 鎴愬憳鐨勫垎浜暟鎹�
-        /// </summary>
-        private MemberShardInfoData memberShardInfo = null;
+        private string ChildAccountId = string.Empty;
         /// <summary>
         /// 閫夋嫨鐨勬埧闂�
         /// </summary>
@@ -45,12 +41,10 @@
         /// <summary>
         /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓)
         /// </summary>
-        /// <param name="i_memberResult">鎴愬憳淇℃伅</param>
-        /// <param name="i_memberShardInfo">鎴愬憳鐨勫叡浜俊鎭�</param>
-        public void ShowForm(MemberInfoRes i_memberResult, MemberShardInfoData i_memberShardInfo)
+        /// <param name="i_ChildAccountId">鎴愬憳ID</param>
+        public void ShowForm(string i_ChildAccountId)
         {
-            this.memberResult = i_memberResult;
-            this.memberShardInfo = i_memberShardInfo;
+            this.ChildAccountId = i_ChildAccountId;
 
             //璁剧疆澶撮儴淇℃伅
             base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddShared));
@@ -76,7 +70,7 @@
             bodyFrameLayout.AddChidren(frameBack);
             //鎴块棿鍒楄〃
             var btnTitle = new NormalViewControl(800, 60, true);
-            btnTitle.X = ControlCommonResourse.XXLeft;
+            btnTitle.X = HdlControlResourse.XXLeft;
             btnTitle.Y = Application.GetRealHeight(52);
             btnTitle.TextID = R.MyInternationalizationString.RoomList;
             btnTitle.TextColor = UserCenterColor.Current.TextColor2;
@@ -233,7 +227,7 @@
             row.ButtonClickEvent += (sender, e) =>
             {
                 var form = new AddNewSharedContentForm();
-                form.AddForm(room, memberShardInfo);
+                form.AddForm(room, this.ChildAccountId);
             };
 
             //閫夋嫨
@@ -274,130 +268,28 @@
         /// <param name="room">鎸囧畾瑕佸垎浜殑鎴块棿</param>
         public void DoSharedContentByRoom(List<Common.Room> listRoom)
         {
-            //鑾峰彇闇�瑕佷笂浼犵殑璁惧(鎸夋埧闂碙ist椤哄簭鍒嗙粍)
-            var dicDevice = new Dictionary<int, List<CommonDevice>>();
-            //鑾峰彇闇�瑕佷笂浼犵殑鍦烘櫙,杩欎釜涓滆タ涓嶈鑾峰彇瀹冪殑缁戝畾鐩爣(鎸夋埧闂碙ist椤哄簭鍒嗙粍)
-            var dicScene = new Dictionary<int, List<Common.SceneUI>>();
-            //鑾峰彇闇�瑕佷笂浼犵殑鎴块棿鏁版嵁
-            int fileCount = this.GetUpLoadRoomData(listRoom, dicDevice, dicScene);
-
-            var listCheckFile = new HashSet<string>();
             HdlThreadLogic.Current.RunThread(() =>
             {
                 //鎵撳紑杩涘害鏉�
                 this.ShowProgressBar();
-
-                for (int index = 0; index < listRoom.Count; index++)
-                {
-                    //鎵ц涓婁紶
-                    var result = HdlShardLogic.Current.DoUploadSharedContent(memberShardInfo, listRoom[index], dicDevice[index], dicScene[index], fileCount, listCheckFile);
-                    if (result == false)
-                    {
-                        break;
-                    }
-                }
+                //涓婁紶鍒嗕韩
+                var result = HdlShardLogic.Current.UploadSharedRoom(this.ChildAccountId, listRoom);
                 //鍏抽棴杩涘害鏉�
                 this.CloseProgressBar();
 
-                //涓嶇鎴愬姛杩樻槸澶辫触,閮藉埛鏂扮晫闈�
-                HdlThreadLogic.Current.RunMain(() =>
+                if (result == true)
                 {
-                    if (this.Parent != null)
+                    //涓嶅埛鏂扮晫闈�
+                    HdlThreadLogic.Current.RunMain(() =>
                     {
-                        //閲嶆柊鍒锋柊鐣岄潰
-                        this.InitMiddleFrame();
-                    }
-                });
-            });
-        }
-
-        /// <summary>
-        /// 鑾峰彇闇�瑕佷笂浼犵殑鎴块棿鏁版嵁
-        /// </summary>
-        /// <param name="listRoom">闇�瑕佷笂浼犵殑鎴块棿鍒楄〃</param>
-        /// <param name="dicDevice">鑾峰彇闇�瑕佷笂浼犵殑璁惧(鎸夋埧闂碙ist椤哄簭鍒嗙粍)</param>
-        /// <param name="dicScene">鑾峰彇闇�瑕佷笂浼犵殑鍦烘櫙,杩欎釜涓滆タ涓嶈鑾峰彇瀹冪殑缁戝畾鐩爣(鎸夋埧闂碙ist椤哄簭鍒嗙粍)</param>
-        /// <returns></returns>
-        private int GetUpLoadRoomData(List<Common.Room> listRoom, Dictionary<int, List<CommonDevice>> dicDevice, Dictionary<int, List<Common.SceneUI>> dicScene)
-        {
-            var listAllFile = new HashSet<string>();
-            for (int i = 0; i < listRoom.Count; i++)
-            {
-                //鎸夋埧闂碙ist椤哄簭鍒嗙粍鐨勮澶囧垪琛�
-                var listDevice = new List<CommonDevice>();
-                dicDevice[i] = listDevice;
-                //鎸夋埧闂碙ist椤哄簭鍒嗙粍鐨勫満鏅垪琛�
-                var listScene = new List<Common.SceneUI>();
-                dicScene[i] = listScene;
-
-                //鑾峰彇鎴块棿鍏ㄩ儴璁惧
-                foreach (var deviceKeys in listRoom[i].ListDevice)
-                {
-                    var device = Common.LocalDevice.Current.GetDevice(deviceKeys);
-                    if (device == null || memberShardInfo.dicAllShardKeys.ContainsKey(device.FilePath) == true)
-                    {
-                        //寮傚父
-                        continue;
-                    }
-                    string deviceFile = device.FilePath;
-                    if (memberShardInfo.dicAllShardKeys.ContainsKey(deviceFile) == false)
-                    {
-                        //鎴栬�呭凡缁忓垎浜簡鐨勶紝涓嶅啀鏄剧ず
-                        listDevice.Add(device);
-                        if (listAllFile.Contains(deviceFile) == false)
+                        if (this.Parent != null)
                         {
-                            listAllFile.Add(deviceFile);
+                            //閲嶆柊鍒锋柊鐣岄潰
+                            this.InitMiddleFrame();
                         }
-                    }
+                    });
                 }
-
-                //鑾峰彇鍦烘櫙閲岄潰宓屽鐨勫瓙璁惧鍜屽瓙鍦烘櫙(璁$畻鎬绘暟鐢�)
-                var listCheck = new HashSet<string>();
-                var listChirdDevice = new List<CommonDevice>();
-                var listChirdScene = new List<Common.SceneUI>();
-                //鑾峰彇鎴块棿鍏ㄩ儴鍦烘櫙
-                foreach (var sceneId in listRoom[i].ListSceneId)
-                {
-                    var sceneUi = HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId);
-                    if (sceneUi == null || memberShardInfo.dicAllShardKeys.ContainsKey(sceneUi.FileName) == true)
-                    {
-                        //寮傚父锛屾垨鑰呭凡缁忓垎浜簡鐨勶紝涓嶅啀鏄剧ず
-                        continue;
-                    }
-                    listScene.Add(sceneUi);
-                    //浠庣紦瀛樿幏鍙栧満鏅殑鎵ц鐩爣(杩欎釜鍑芥暟鏄绠楁�绘暟鐢�)
-                    HdlShardLogic.Current.GetSceneDeviceList(sceneUi, listCheck, listChirdScene, listChirdDevice);
-                    if (listAllFile.Contains(sceneUi.FileName) == false)
-                    {
-                        listAllFile.Add(sceneUi.FileName);
-                    }
-                }
-                foreach (var device in listChirdDevice)
-                {
-                    //宓屽瀛愯澶囩殑鏂囦欢鍚嶅瓧(璁$畻鎬绘暟鐢�)
-                    string deviceFile = device.FilePath;
-                    if (listAllFile.Contains(deviceFile) == false)
-                    {
-                        listAllFile.Add(deviceFile);
-                    }
-                }
-                foreach (var secene in listChirdScene)
-                {
-                    //宓屽瀛愬満鏅殑鏂囦欢鍚嶅瓧(璁$畻鎬绘暟鐢�)
-                    if (listAllFile.Contains(secene.FileName) == false)
-                    {
-                        listAllFile.Add(secene.FileName);
-                    }
-                }
-                //鎴块棿鏂囦欢
-                listAllFile.Add(listRoom[i].FileName);
-            }
-            //濡傛灉鏈夋ゼ灞傜殑璇�
-            if (Common.Config.Instance.Home.FloorDics.Count > 0)
-            {
-                return listAllFile.Count + 1;
-            }
-            return listAllFile.Count;
+            });
         }
 
         #endregion
@@ -433,19 +325,19 @@
             {
                 return false;
             }
-            if (memberShardInfo.dicShardRoom.ContainsKey(room.FileName) == false)
+            if (HdlShardLogic.Current.GetShardRoomFromMemory(room.Id) == null)
             {
                 //娌℃湁杩欎釜鎴块棿
                 return true;
             }
             foreach (var deviceKeys in room.ListDevice)
             {
-                var device = Common.LocalDevice.Current.GetDevice(deviceKeys);
-                if (device == null)
+                if (HdlDeviceCommonLogic.Current.GetDevice(deviceKeys) == null)
                 {
+                    //鏈湴娌℃湁杩欎釜璁惧
                     continue;
                 }
-                if (memberShardInfo.dicAllShardKeys.ContainsKey(device.FilePath) == false)
+                if (HdlShardLogic.Current.GetShardDeviceFromMemory(deviceKeys) == null)
                 {
                     //瀛樺湪鏈垎浜殑璁惧鐨勮瘽锛屾鎴块棿鍙互鏄剧ず
                     return true;
@@ -453,37 +345,18 @@
             }
             foreach (var sceneId in room.ListSceneId)
             {
-                var sceneUi = HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId);
-                if (sceneUi == null)
+                if (HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId) == null)
                 {
+                    //鏈湴娌℃湁杩欎釜鍦烘櫙
                     continue;
                 }
-                if (memberShardInfo.dicAllShardKeys.ContainsKey(sceneUi.FileName) == false)
+                if (HdlShardLogic.Current.GetShardSceneFromMemory(sceneId) == null)
                 {
                     //瀛樺湪鏈垎浜殑鍦烘櫙鐨勮瘽锛屾鎴块棿鍙互鏄剧ず
                     return true;
                 }
             }
             return false;
-        }
-
-        #endregion
-
-        #region 鈻� 缁撴瀯浣揰____________________________
-
-        /// <summary>
-        /// 鎺ユ敹鍒嗕韩鏁版嵁
-        /// </summary>
-        private class MemberShardInfoResult
-        {
-            /// <summary>
-            /// 鏂囦欢鍚嶅瓧
-            /// </summary>
-            public string ShareName = string.Empty;
-            /// <summary>
-            /// 涓婚敭
-            /// </summary>
-            public string DistributedMark = string.Empty;
         }
 
         #endregion

--
Gitblit v1.8.0