| | |
| | | /// </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>
|
| | |
| | | /// <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));
|
| | |
| | | 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;
|
| | |
| | | row.ButtonClickEvent += (sender, e) =>
|
| | | {
|
| | | var form = new AddNewSharedContentForm();
|
| | | form.AddForm(room, memberShardInfo);
|
| | | form.AddForm(room, this.ChildAccountId);
|
| | | };
|
| | |
|
| | | //选择
|
| | |
| | | /// <param name="room">指定要分享的房间</param>
|
| | | public void DoSharedContentByRoom(List<Common.Room> listRoom)
|
| | | {
|
| | | //获取需要上传的设备(按房间List顺序分组)
|
| | | var dicDevice = new Dictionary<int, List<CommonDevice>>();
|
| | | //获取需要上传的场景,这个东西不要获取它的绑定目标(按房间List顺序分组)
|
| | | 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">获取需要上传的设备(按房间List顺序分组)</param>
|
| | | /// <param name="dicScene">获取需要上传的场景,这个东西不要获取它的绑定目标(按房间List顺序分组)</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++)
|
| | | {
|
| | | //按房间List顺序分组的设备列表
|
| | | var listDevice = new List<CommonDevice>();
|
| | | dicDevice[i] = listDevice;
|
| | | //按房间List顺序分组的场景列表
|
| | | 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
|
| | |
| | | {
|
| | | 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;
|
| | |
| | | }
|
| | | 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
|