コード例 #1
0
 public GroupMemberListViewModel(List <AntSdkGroupMember> GroupMembers, AntSdkGroupInfo groupInfo)
 {
     this.GroupInfo = groupInfo;
     _groupMembers  = GroupMembers;
     AsyncHandler.AsyncCall(System.Windows.Application.Current.Dispatcher, () =>
     {
         AntSdkGroupMember groupOwner =
             GroupMembers.FirstOrDefault(c => c.roleLevel == (int)GlobalVariable.GroupRoleLevel.GroupOwner);
         GroupOwnerId = groupOwner == null ? "" : groupOwner.userId;
         LogHelper.WriteFatal(groupInfo.groupId + "-------" + groupInfo.groupName + "群组的群主: " +
                              groupOwner?.userNum + groupOwner?.userName);
         groupAdminUser = GroupMembers.FirstOrDefault(c =>
                                                      c.roleLevel == (int)GlobalVariable.GroupRoleLevel.Admin &&
                                                      c.userId == AntSdkService.AntSdkLoginOutput.userId);
         adminCount = GroupMembers.Count(m => m.roleLevel == (int)GlobalVariable.GroupRoleLevel.Admin);
         var orderByDesGroupMembers = GroupMembers.OrderByDescending(m => m.roleLevel).ToList();
         foreach (AntSdkGroupMember user in orderByDesGroupMembers)
         {
             GroupMemberViewModel groupMemberViewModel = new GroupMemberViewModel(user, GroupOwnerId,
                                                                                  GroupInfo.groupId, this, SearchGroupName, adminCount);
             if (user.roleLevel == (int)GlobalVariable.GroupRoleLevel.GroupOwner)
             {
                 GroupMemberControlList.Insert(0, groupMemberViewModel);
             }
             else if (user.roleLevel == (int)GlobalVariable.GroupRoleLevel.Admin)
             {
                 GroupMemberControlList.Insert(GroupMemberControlList.Count > 0 ? 1 : 0, groupMemberViewModel);
             }
             else
             {
                 var userinfo =
                     AntSdkService.AntSdkListContactsEntity.users.FirstOrDefault(c => c.userId == user.userId);
                 groupMemberViewModel.KickoutGroupVisibility = groupAdminUser != null ||
                                                               GroupOwnerId ==
                                                               AntSdkService.AntSdkLoginOutput.userId
                     ? Visibility.Visible
                     : Visibility.Collapsed;
                 if (userinfo != null && userinfo.state != (int)GlobalVariable.OnLineStatus.OffLine)
                 {
                     var index =
                         GroupMemberControlList.Count(
                             m =>
                             !m.IsGroupAdminImage && !m.IsOfflineState &&
                             m.AdminImageVisibility != Visibility.Visible);
                     GroupMemberControlList.Insert(index + adminCount + 1, groupMemberViewModel);
                 }
                 else
                 {
                     GroupMemberControlList.Add(groupMemberViewModel);
                 }
             }
         }
     });
     SearchGroupNameCommand = new DelegateCommand(GroupNameSearch);
     GoMemberSessionCommand = new DelegateCommand(goMemberSession);
     GroupMemberViewModel.KickoutGroupEvent           += KickOutGroup;
     GroupMemberViewModel.ChangeManagerCompletedEvent += GroupMemberViewModel_ChangeManagerCompletedEvent;
     MemberCountPrompt = string.Format("群成员({0}人)", GroupMembers.Count);
 }
コード例 #2
0
 public void UpdateGroupMembers(List <AntSdkGroupMember> GroupMembers)
 {
     AsyncHandler.AsyncCall(System.Windows.Application.Current.Dispatcher, () =>
     {
         GroupMemberControlList.Clear();
         AntSdkGroupMember admin =
             GroupMembers.FirstOrDefault(c => c.roleLevel == (int)GlobalVariable.GroupRoleLevel.GroupOwner);
         _groupMembers  = GroupMembers;
         groupAdminUser =
             GroupMembers.FirstOrDefault(
                 c =>
                 c.roleLevel == (int)GlobalVariable.GroupRoleLevel.Admin &&
                 c.userId == AntSdkService.AntSdkLoginOutput.userId);
         GroupOwnerId = (admin == null ? "" : admin.userId);
         LogHelper.WriteFatal(this.GroupInfo.groupId + "-------" + this.GroupInfo.groupName + "群组的群主: " +
                              admin?.userNum + admin?.userName);
         adminCount = GroupMembers.Count(m => m.roleLevel == (int)GlobalVariable.GroupRoleLevel.Admin);
         var orderByDesGroupMembers = GroupMembers.OrderByDescending(m => m.roleLevel).ToList();
         foreach (AntSdkGroupMember user in orderByDesGroupMembers)
         {
             GroupMemberViewModel groupMemberViewModel = new GroupMemberViewModel(user, GroupOwnerId,
                                                                                  GroupInfo.groupId, this, SearchGroupName, adminCount);
             //groupMemberViewModel.AdminCount = adminCount;
             if (user.userId == GroupOwnerId)
             {
                 GroupMemberControlList.Insert(0, groupMemberViewModel);
             }
             else if (user.roleLevel == (int)GlobalVariable.GroupRoleLevel.Admin)
             {
                 GroupMemberControlList.Insert(GroupMemberControlList.Count > 0 ? 1 : 0, groupMemberViewModel);
             }
             else
             {
                 var userinfo =
                     AntSdkService.AntSdkListContactsEntity.users.FirstOrDefault(c => c.userId == user.userId);
                 groupMemberViewModel.KickoutGroupVisibility = groupAdminUser != null ||
                                                               GroupOwnerId ==
                                                               AntSdkService.AntSdkLoginOutput.userId
                     ? Visibility.Visible
                     : Visibility.Collapsed;
                 if (userinfo != null && userinfo.state != (int)GlobalVariable.OnLineStatus.OffLine)
                 {
                     var index =
                         GroupMemberControlList.Count(
                             m =>
                             !m.IsGroupAdminImage && !m.IsOfflineState &&
                             m.AdminImageVisibility != Visibility.Visible);
                     GroupMemberControlList.Insert(index + adminCount + 1, groupMemberViewModel);
                 }
                 else
                 {
                     GroupMemberControlList.Add(groupMemberViewModel);
                 }
             }
         }
         MemberCountPrompt = string.Format("群成员({0}人)", GroupMembers.Count);
     });
 }
コード例 #3
0
 /// <summary>
 /// 搜索群组成员
 /// </summary>
 public void GroupNameSearch()
 {
     AsyncHandler.AsyncCall(System.Windows.Application.Current.Dispatcher, () =>
     {
         if (string.IsNullOrWhiteSpace(SearchGroupName))
         {
             IsShowSearchList = false;
             SearchGroupMemberControlList.Clear();
             return;
         }
         if (SearchGroupMemberControlList == null)
         {
             SearchGroupMemberControlList = new ObservableCollection <GroupMemberViewModel>();
         }
         SearchGroupMemberControlList.Clear();
         if (_groupMembers != null && _groupMembers.Any())
         {
             //var groupMemberList = _groupMembers.Where(m => IsconditionsSatisfy(m.userName, m.userNum));
             //if (groupMemberList != null && groupMemberList.Any())
             //{
             //    var groupMemberOrderByList = groupMemberList.OrderBy(m => m.userName);
             //    foreach (var user in groupMemberOrderByList)
             //    {
             //        GroupMemberViewModel groupMemberViewModel = new GroupMemberViewModel(user, GroupAdminId, GroupInfo.groupId, this, SearchGroupName);
             //        groupMemberViewModel.AdminImageVisibility = Visibility.Collapsed;
             //        SearchGroupMemberControlList.Add(groupMemberViewModel);
             //    }
             //}
             foreach (var member in _groupMembers)
             {
                 string pinYin   = string.Empty;
                 var contactUser = AntSdkService.AntSdkListContactsEntity.users.FirstOrDefault(m => m.userId == member.userId);
                 if (contactUser != null && contactUser.status == 0)
                 {
                     continue;
                 }
                 if (IsconditionsSatisfy(member.userName, member.userNum, ref pinYin))
                 {
                     GroupMemberViewModel groupMemberViewModel = new GroupMemberViewModel(member, GroupOwnerId,
                                                                                          GroupInfo.groupId, this, SearchGroupName, pinYin);
                     groupMemberViewModel.AdminImageVisibility = Visibility.Collapsed;
                     SearchGroupMemberControlList.Add(groupMemberViewModel);
                 }
             }
         }
         if (!SearchGroupMemberControlList.Any())
         {
             IsExistData = false;
         }
         else
         {
             GroupMeberSelected = SearchGroupMemberControlList[0];
             IsExistData        = true;
         }
         IsShowSearchList = true;
     });
 }
コード例 #4
0
        private void KickOutGroup(string groupId, string userID, string picture)
        {
            if (GroupInfo.groupId != groupId)
            {
                return;
            }
            GroupMemberViewModel vm = GroupMemberControlList.FirstOrDefault(c => c.Member.userId == userID);

            GroupMemberControlList.Remove(vm);
            MemberCountPrompt = string.Format("群成员({0}人)", GroupMemberControlList.Count);
        }
コード例 #5
0
 public void AddNewMember(List <AntSdkContact_User> newGroupMemberList)
 {
     AsyncHandler.AsyncCall(System.Windows.Application.Current.Dispatcher, () =>
     {
         foreach (AntSdkContact_User user in newGroupMemberList)
         {
             AntSdkGroupMember member = new AntSdkGroupMember();
             member.picture           = user.picture;
             member.position          = user.position;
             member.roleLevel         = (int)GlobalVariable.GroupRoleLevel.Ordinary;
             member.userId            = user.userId;
             member.userName          = user.userName;
             GroupMemberViewModel groupMemberViewModel = new GroupMemberViewModel(member, GroupOwnerId,
                                                                                  GroupInfo.groupId, this, SearchGroupName, adminCount);
             //groupMemberViewModel.AdminCount = adminCount;
             var userinfo =
                 AntSdkService.AntSdkListContactsEntity.users.FirstOrDefault(c => c.userId == user.userId);
             groupMemberViewModel.KickoutGroupVisibility = groupAdminUser != null ||
                                                           GroupOwnerId == AntSdkService.AntSdkLoginOutput.userId
                 ? Visibility.Visible
                 : Visibility.Collapsed;
             if (userinfo != null && userinfo.state != (int)GlobalVariable.OnLineStatus.OffLine)
             {
                 var index =
                     GroupMemberControlList.Count(
                         m =>
                         !m.IsGroupAdminImage && !m.IsOfflineState &&
                         m.AdminImageVisibility != Visibility.Visible);
                 GroupMemberControlList.Insert(index + adminCount + 1, groupMemberViewModel);
             }
             else
             {
                 GroupMemberControlList.Add(groupMemberViewModel);
             }
             //groupMemberViewModel.KickoutGroupVisibility = groupAdminUser != null ? Visibility.Visible : Visibility.Collapsed;
             //GroupMemberControlList.Add(groupMemberViewModel);
         }
         MemberCountPrompt = string.Format("群成员({0}人)", GroupMemberControlList.Count);
     });
 }