/// <summary> /// 创建新讨论组时调用 /// </summary> /// <param name="group"></param> /// <returns></returns> public GroupInfoViewModel AddGroup(AntSdkCreateGroupOutput group) { //不为空||去除重复的 if (group == null) { return(null); } else if (GroupIds.Contains(group.groupId)) { return(GroupInfoList.FirstOrDefault(c => c.GroupInfo.groupId == group.groupId)); } var newGroup = new AntSdkGroupInfo { groupId = @group.groupId, groupName = @group.groupName, groupPicture = @group.groupPicture, state = (int)GlobalVariable.MsgRemind.Remind, groupOwnerId = group.groupOwnerId, memberCount = group.memberCount }; return(AddGroupInfoModel(newGroup)); }
public void AddGroupAndClick(AntSdkCreateGroupOutput group) { GroupInfoViewModel vm = AddGroup(group); vm?.OnMouseDoubleClickEvent(); }
private void CreateGroup() { // 讨论组名不能为空 //if (string.IsNullOrWhiteSpace(GroupName)) //{ // GroupNameBorderBrush = new SolidColorBrush(Colors.Red); // //GroupNameBorderThickness = new Thickness(1, 1, 1, 1); // return; //} //else //{ // GroupNameBorderBrush = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString("#e0e0e0")); // //GroupNameBorderThickness = new Thickness(0); //} // 讨论组成员不能少于3 if (GroupMemberList == null || GroupMemberList.Count < 3) { MessageBoxWindow.Show("讨论组至少需要包括三个成员", GlobalVariable.WarnOrSuccess.Warn); return; } if (string.IsNullOrWhiteSpace(GroupName.Trim(' ')))//自定义群名为空 取默认值 { GroupName = GetNewGroupName(); } GroupName = GroupName.TrimStart(' '); #region 旧代码 CreateGroupInput input = new CreateGroupInput(); input.token = AntSdkService.AntSdkLoginOutput.token; input.version = GlobalVariable.Version; input.userId = AntSdkService.AntSdkLoginOutput.userId; input.groupName = GroupName; //获取讨论组成员头像 //List<string> picList = new List<string>(); //foreach (ContactInfoViewModel m in GroupMemberList) //{ // picList.Add(m.Photo); //} //input.groupPicture = ImageHandle.GetGroupPicture(picList); //input.groupPicture =; input.userIds = string.Join(",", GroupMemberList.Select(c => c.User.userId).ToArray()); //CreateGroupOutput output = new CreateGroupOutput(); var errCode = 0; var errMsg = string.Empty; //if (!(new HttpService()).CreateGroup(input, ref output, ref errMsg)) //{ // if (output.errorCode != "1004") // { // MessageBoxWindow.Show(errMsg,GlobalVariable.WarnOrSuccess.Warn); // } // return; //} //output.group.groupPicture = ImageHandle.GetGroupPicture(GroupMemberList.Select(c => c.Photo).ToList()); //ThreadPool.QueueUserWorkItem(m => //{ //}); #endregion AntSdkCreateGroupInput newGroupInput = new AntSdkCreateGroupInput(); newGroupInput.userId = AntSdkService.AntSdkLoginOutput.userId; newGroupInput.groupName = GroupName; newGroupInput.userIds = GroupMemberList.Select(c => c.User.userId).ToArray(); //newGroupInput.groupPicture = ImageHandle.GetGroupPicture(GroupMemberList.Select(c => c.Photo).ToList()); //TODO:AntSdk_Modify //DONE:AntSdk_Modify AntSdkCreateGroupOutput createGroupOutput = AntSdkService.CreateGroup(newGroupInput, ref errCode, ref errMsg); if (createGroupOutput == null) { if (!AntSdkService.AntSdkIsConnected) { errMsg = "网络已断开,请检查网络"; } if (!string.IsNullOrEmpty(errMsg)) { MessageBoxWindow.Show(errMsg, GlobalVariable.WarnOrSuccess.Warn); } return; } createGroupOutput.groupPicture = ImageHandle.GetGroupPicture(GroupMemberList.Select(c => c.Photo).ToList()); //异步更新讨论组头像,这里需要用前台线程,因此不能用线程池 string[] ThreadParams = new string[3]; ThreadParams[0] = createGroupOutput.groupId; ThreadParams[1] = createGroupOutput.groupPicture; ThreadParams[2] = string.IsNullOrEmpty(createGroupOutput.groupName) ? "" : createGroupOutput.groupName; Thread UpdateGroupPictureThread = new Thread(GroupPublicFunction.UpdateGroupPicture); UpdateGroupPictureThread.Start(ThreadParams); this.CreateGroupOutput = createGroupOutput; App.Current.Dispatcher.BeginInvoke((Action)(() => { this.close.Invoke(); })); }