public void GetGroupUsersAction() { _parentModel.IsError = false; AllUserSelected = false; if (IsGroupsFound && _parentModel.SelectedSearchedGroup != null) { DisplayGroupName = "Group :" + _parentModel.SelectedSearchedGroup.Title; _parentModel.IsBusy = true; _parentModel.UserGroupServiceAgent.GetGroupUsers(_parentModel.SelectedSearchedGroup.Id, (users, e) => { _dispatcher.BeginInvoke(new Action(() => { GroupUsers.Clear(); if (users != null && users.Count > 0) { users.ForEach(user => { var u = new User() { Name = user.Title, IsSelected = false, AccountName = user.LoginName, IsEnabled = false }; GroupUsers.Add(u); }); } else { _parentModel.IsError = true; _parentModel.ErrorMessage = Logger.BuildLogMessageForUser(e, "No users assigned for this group!"); } AddUserCommand.IsEnabled = true; RemoveUserCommand.IsEnabled = false; _parentModel.IsBusy = false; })); }); } }
private void SearchUserAction() { if (SearchString.Trim().Length > 0 && SearchString != Constants.FILTER_USERS) { IsError = false; IsBusy = true; UserGroupCommand.IsEnabled = false; UpdateUserGroupsCommand.IsEnabled = false; UserGroupServiceAgent.CheckUserExist(SearchString.Trim(), (verifiedusers,e) => { _dispatcher.BeginInvoke(new Action(() => { SearchedUsers.Clear(); UserGroups.Clear(); if (verifiedusers != null) { var u = new User() { AccountName = verifiedusers.LoginName, Name = verifiedusers.Title, IsEnabled = false, IsSelected = false, }; SearchedUsers.Add(u); IsUsersFound = SearchedUsers.Count > 0 ? true : false; InnerUserGroupsViewModel.IsUsersFound = SearchedUsers.Count > 0 ? true : false; } else { IsError = true; ErrorMessage =Logger.BuildLogMessageForUser(e, "No Users Found!"); } IsBusy = false; })); } ); } }
private void AddUserAction() { _parentModel.IsError = false; AddUserDialog dialog = new AddUserDialog(_parentModel._siteURL, _parentModel._log); dialog.Closed += (s, e) => { AddUserDialog d = (AddUserDialog)s; if ((d.DialogResult.HasValue) && (d.DialogResult.Value)) { _parentModel.IsBusy = true; ClientUtility.PrincipalInfo user = ((AddUserDialogViewModel)d.DataContext).UserFound; User verifyUser = new User() { Name = user.JobTitle, AccountName = user.LoginName, IsEnabled = false, IsSelected = false }; UserComparer comparer = new UserComparer(); if (!GroupUsers.Contains(verifyUser, comparer)) { SCOM.UserCreationInformation addUser = new Microsoft.SharePoint.Client.UserCreationInformation(); addUser.Title = user.JobTitle; addUser.LoginName = user.LoginName; addUser.Email = user.Email; _parentModel.UserGroupServiceAgent.AddUser(_parentModel.SelectedSearchedGroup.Id, addUser, (result, ie) => { _dispatcher.BeginInvoke(new Action(() => { if (result == false) { _parentModel.IsError = true; _parentModel.ErrorMessage = Logger.BuildLogMessageForUser(ie, "Add User Failed!"); _parentModel.IsBusy = false; } else { GroupUsersCommand.Execute(null); } })); }); } else { _parentModel.IsBusy = false; _parentModel.IsError = true; _parentModel.ErrorMessage = "User Already Exist."; } } }; dialog.Show(); }