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/AddNewSharedListRoomForm.cs | 179 +++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 153 insertions(+), 26 deletions(-) diff --git a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedListRoomForm.cs b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedListRoomForm.cs index 98b9962..6f0377a 100755 --- a/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedListRoomForm.cs +++ b/ZigbeeApp/Shared/Phone/UserCenter/SharedContent/AddNewSharedListRoomForm.cs @@ -22,9 +22,13 @@ /// </summary> private BottomClickButton btnShard = null; /// <summary> - /// 鎴愬憳ID + /// 鎴愬憳淇℃伅 /// </summary> - private string ChildAccountId = string.Empty; + private MemberInfoRes memberResult = null; + /// <summary> + /// 鎴愬憳鐨勫垎浜暟鎹� + /// </summary> + private MemberShardInfoData memberShardInfo = null; /// <summary> /// 閫夋嫨鐨勬埧闂� /// </summary> @@ -41,10 +45,12 @@ /// <summary> /// 鐢婚潰鏄剧ず(搴曞眰浼氬浐瀹氳皟鐢ㄦ鏂规硶锛屽�熶互瀹屾垚鐢婚潰鍒涘缓) /// </summary> - /// <param name="i_ChildAccountId">鎴愬憳ID</param> - public void ShowForm(string i_ChildAccountId) + /// <param name="i_memberResult">鎴愬憳淇℃伅</param> + /// <param name="i_memberShardInfo">鎴愬憳鐨勫叡浜俊鎭�</param> + public void ShowForm(MemberInfoRes i_memberResult, MemberShardInfoData i_memberShardInfo) { - this.ChildAccountId = i_ChildAccountId; + this.memberResult = i_memberResult; + this.memberShardInfo = i_memberShardInfo; //璁剧疆澶撮儴淇℃伅 base.SetTitleText(Language.StringByID(R.MyInternationalizationString.uAddShared)); @@ -70,7 +76,7 @@ bodyFrameLayout.AddChidren(frameBack); //鎴块棿鍒楄〃 var btnTitle = new NormalViewControl(800, 60, true); - btnTitle.X = HdlControlResourse.XXLeft; + btnTitle.X = ControlCommonResourse.XXLeft; btnTitle.Y = Application.GetRealHeight(52); btnTitle.TextID = R.MyInternationalizationString.RoomList; btnTitle.TextColor = UserCenterColor.Current.TextColor2; @@ -227,7 +233,7 @@ row.ButtonClickEvent += (sender, e) => { var form = new AddNewSharedContentForm(); - form.AddForm(room, this.ChildAccountId); + form.AddForm(room, memberShardInfo); }; //閫夋嫨 @@ -268,28 +274,130 @@ /// <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(); - //涓婁紶鍒嗕韩 - var result = HdlShardLogic.Current.UploadSharedRoom(this.ChildAccountId, listRoom); + + 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; + } + } //鍏抽棴杩涘害鏉� this.CloseProgressBar(); - if (result == true) + //涓嶇鎴愬姛杩樻槸澶辫触,閮藉埛鏂扮晫闈� + HdlThreadLogic.Current.RunMain(() => { - //涓嶅埛鏂扮晫闈� - HdlThreadLogic.Current.RunMain(() => + if (this.Parent != null) { - if (this.Parent != null) - { - //閲嶆柊鍒锋柊鐣岄潰 - this.InitMiddleFrame(); - } - }); - } + //閲嶆柊鍒锋柊鐣岄潰 + 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) + { + listAllFile.Add(deviceFile); + } + } + } + + //鑾峰彇鍦烘櫙閲岄潰宓屽鐨勫瓙璁惧鍜屽瓙鍦烘櫙(璁$畻鎬绘暟鐢�) + 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 @@ -325,19 +433,19 @@ { return false; } - if (HdlShardLogic.Current.GetShardRoomFromMemory(room.Id) == null) + if (memberShardInfo.dicShardRoom.ContainsKey(room.FileName) == false) { //娌℃湁杩欎釜鎴块棿 return true; } foreach (var deviceKeys in room.ListDevice) { - if (HdlDeviceCommonLogic.Current.GetDevice(deviceKeys) == null) + var device = Common.LocalDevice.Current.GetDevice(deviceKeys); + if (device == null) { - //鏈湴娌℃湁杩欎釜璁惧 continue; } - if (HdlShardLogic.Current.GetShardDeviceFromMemory(deviceKeys) == null) + if (memberShardInfo.dicAllShardKeys.ContainsKey(device.FilePath) == false) { //瀛樺湪鏈垎浜殑璁惧鐨勮瘽锛屾鎴块棿鍙互鏄剧ず return true; @@ -345,12 +453,12 @@ } foreach (var sceneId in room.ListSceneId) { - if (HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId) == null) + var sceneUi = HdlSceneLogic.Current.GetSceneUIBySceneId(sceneId); + if (sceneUi == null) { - //鏈湴娌℃湁杩欎釜鍦烘櫙 continue; } - if (HdlShardLogic.Current.GetShardSceneFromMemory(sceneId) == null) + if (memberShardInfo.dicAllShardKeys.ContainsKey(sceneUi.FileName) == false) { //瀛樺湪鏈垎浜殑鍦烘櫙鐨勮瘽锛屾鎴块棿鍙互鏄剧ず return true; @@ -360,5 +468,24 @@ } #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