public bool AddMembers(GroupMembershipDto members) { if (members == null) { return(false); } var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(_server, _tenantName); ActionHelper.Execute(delegate() { var users = members.Users.Where(x => x.State == State.ForAdd).ToList(); if (users.Count > 0) { _service.Group.AddUsers(_server, _tenantName, _groupDto, users, auth.Token); } var solnUsers = members.SolutionUsers.Where(x => x.State == State.ForAdd).ToList(); if (solnUsers.Count > 0) { _service.Group.AddSolutionUsers(_server, _tenantName, _groupDto, solnUsers, auth.Token); } var groups = members.Groups.Where(x => x.State == State.ForAdd).ToList(); if (groups.Count > 0) { _service.Group.AddGroups(_server, _tenantName, _groupDto, groups, auth.Token); } }, auth); return(true); }
void SetGroupDataSource(GroupMembershipDto members) { foreach (NSTableColumn column in GroupMembersTableView.TableColumns()) { GroupMembersTableView.RemoveColumn(column); } var listView = new GroupMembershipDataSource { Groups = members.Groups, Users = members.Users, SolutionUsers = members.SolutionUsers }; var columnNames = new List <ColumnOptions> { new ColumnOptions { Id = "Name", DisplayName = "Member", DisplayOrder = 1, Width = 180 } }; var columns = ListViewHelper.ToNSTableColumns(columnNames); foreach (var column in columns) { GroupMembersTableView.AddColumn(column); } GroupMembersTableView.DataSource = listView; GroupMembersTableView.ReloadData(); }
public override void AwakeFromNib() { base.AwakeFromNib(); GroupDto = new GroupDto { GroupName = GroupDtoOriginal.GroupName, GroupDomain = GroupDtoOriginal.GroupDomain, GroupDetails = new GroupDetailsDto { Description = GroupDtoOriginal.GroupDetails.Description } }; TxtGroupName.StringValue = GroupDto.GroupName == null ? string.Empty : GroupDto.GroupName; TxtGroupDescription.StringValue = GroupDto.GroupDetails.Description == null ? string.Empty : GroupDto.GroupDetails.Description; GroupMembersTableView.Delegate = new TableDelegate(); GroupMembershipDto = new GroupMembershipDto { Users = (GroupsMembershipDtoOriginal.Users == null ? new List <UserDto> () : new List <UserDto> (GroupsMembershipDtoOriginal.Users)), SolutionUsers = (GroupsMembershipDtoOriginal.SolutionUsers == null ? new List <SolutionUserDto> () : new List <SolutionUserDto> (GroupsMembershipDtoOriginal.SolutionUsers)), Groups = (GroupsMembershipDtoOriginal.Groups == null ? new List <GroupDto> () : new List <GroupDto> (GroupsMembershipDtoOriginal.Groups)) }; SetGroupDataSource(GroupMembershipDto); BtnSave.Hidden = !IsSystemDomain; this.BtnSave.Activated += OnClickSaveButton; this.BtnAddMember.Activated += OnClickAddMember; this.BtnRemoveMember.Activated += OnClickRemoveMember; BtnAddMember.Enabled = IsSystemDomain; BtnRemoveMember.Enabled = IsSystemDomain; }
private void GetSelectedMembers() { _groupMembershipDto = new GroupMembershipDto(); foreach (ListViewItem item in lstGroupMembers.SelectedItems) { if (item.Tag.GetType() == typeof(UserDto)) { var user = ((UserDto)item.Tag); _groupMembershipDto.Users.Add(user); } if (item.Tag.GetType() == typeof(SolutionUserDto)) { var user = ((SolutionUserDto)item.Tag); _groupMembershipDto.SolutionUsers.Add(user); } if (item.Tag.GetType() == typeof(GroupDto)) { var group = ((GroupDto)item.Tag); _groupMembershipDto.Groups.Add(group); } } }
public void OnClickAddGroupButton(object sender, EventArgs e) { if (GroupsTableView.SelectedRows.Count > 0) { SelectedMembers = new GroupMembershipDto() { Groups = new List <GroupDto> (), Users = new List <UserDto> () }; var dataSource = (GroupMembershipDataSource)GroupsTableView.DataSource; foreach (var groupId in GroupsTableView.SelectedRows) { var gid = (int)groupId; if (gid < dataSource.Groups.Count) { SelectedMembers.Groups.Add(dataSource.Groups [gid]); } else { SelectedMembers.Users.Add(dataSource.Users [gid - dataSource.Groups.Count]); } } this.Close(); NSApplication.SharedApplication.StopModalWithCode(1); } }
public bool UpdateMembers(GroupMembershipDto members) { if (members == null) { return(false); } return(RemoveMembers(members) && AddMembers(members)); }
void _parent_Apply(object sender, CancelEventArgs e) { _groupDto.GroupDetails.Description = txtDescription.Text; var success = _presenter.UpdateMembers(_groupMembershipDto); _groupDto = _presenter.Update(_groupDto); e.Cancel = !success; _groupMembershipDto = _presenter.GetMembershipInfo(); RefreshMembers(); }
public GroupGeneralProperty(GroupPropertyDataManager presenter, GroupDto groupDto, bool systemDomain) { _presenter = presenter; _groupMembershipDto = _presenter.GetMembershipInfo(); _groupDto = groupDto; _isSystemDomain = systemDomain; InitializeComponent(); PropertyPageInit(); SetVisibility(systemDomain); }
public GroupMembershipDto GetAllMembers() { var membershipDto = new GroupMembershipDto(); var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(_server, _tenantName); ActionHelper.Execute(delegate() { // all Users membershipDto = SnapInContext.Instance.ServiceGateway.Tenant.Search(_server, _tenantName, _domainName, MemberType.ALL, SearchType.NAME, auth.Token); }, auth); return(membershipDto); }
private void btnAdd_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; var count = lstGroupMembers.Items; GroupMembershipDto groupMembershipDto = null; if (_presenter != null) { ActionHelper.Execute(delegate { var frm = new SelectGroupMembers(_presenter); var dataContext = SnapInContext.Instance.NavigationController.NavigateToView(Page.ParentSheet, frm); groupMembershipDto = (GroupMembershipDto)dataContext; }, null); if (groupMembershipDto != null) { foreach (var member in groupMembershipDto.Groups) { var principalName = member.GroupName + "@" + member.GroupDomain; if (!_groupMembershipDto.Groups.Exists(y => y.GroupName + "@" + y.GroupDomain == principalName)) { member.State = State.ForAdd; _groupMembershipDto.Groups.Add(member); } } foreach (var member in groupMembershipDto.Users) { var principalName = member.Name + "@" + member.Domain; if (!_groupMembershipDto.Users.Exists(y => y.Name + "@" + y.Domain == principalName)) { member.State = State.ForAdd; _groupMembershipDto.Users.Add(member); } } foreach (var member in groupMembershipDto.SolutionUsers) { var principalName = member.Name + "@" + member.Domain; if (!_groupMembershipDto.SolutionUsers.Exists(y => y.Name + "@" + y.Domain == principalName)) { member.State = State.ForAdd; _groupMembershipDto.SolutionUsers.Add(member); } } } } Page.Dirty = true; RefreshMembers(); Cursor.Current = Cursors.Default; }
public GroupMembershipDto GetMembershipInfo() { GroupMembershipDto memberInfo = new GroupMembershipDto(); var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(_server, _tenantName); ActionHelper.Execute(delegate() { var userInfo = _service.Group.GetMembers(_server, _tenantName, _groupDto, GroupMemberType.USER, auth.Token); memberInfo.Users = userInfo.Users == null ? new List <UserDto>() : new List <UserDto>(userInfo.Users); userInfo = _service.Group.GetMembers(_server, _tenantName, _groupDto, GroupMemberType.GROUP, auth.Token); memberInfo.Groups = userInfo.Groups == null ? new List <GroupDto>() : new List <GroupDto>(userInfo.Groups); }, auth); if (memberInfo == null) { memberInfo = new GroupMembershipDto(); } return(memberInfo); }
private void Search(string name, string domain, MemberTypeFilter filter) { var groupInfo = new GroupMembershipDto() { Groups = new List <GroupDto> (), Users = new List <UserDto>() }; if (filter != MemberTypeFilter.Users) { ActionHelper.Execute(delegate() { var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(ServerDto.ServerName); var groupInfo1 = SnapInContext.Instance.ServiceGateway.Tenant.Search(ServerDto, TenantName, domain, MemberType.GROUP, SearchType.NAME, auth.Token, name); groupInfo.Groups = groupInfo1.Groups; }); } if (filter != MemberTypeFilter.Groups) { ActionHelper.Execute(delegate() { var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(ServerDto.ServerName); var groupInfo2 = SnapInContext.Instance.ServiceGateway.Tenant.Search(ServerDto, TenantName, domain, MemberType.USER, SearchType.NAME, auth.Token, name); groupInfo.Users = groupInfo2.Users; }); } var listView = new GroupMembershipDataSource { Groups = groupInfo.Groups, Users = groupInfo.Users }; if (listView.Groups == null) { listView.Groups = new List <GroupDto> (); } if (listView.Users == null) { listView.Users = new List <UserDto> (); } GroupsTableView.DataSource = listView; GroupsTableView.ReloadData(); WarningLabel.Hidden = (listView.Groups.Count + listView.Users.Count) < 100; }
public override void AwakeFromNib() { base.AwakeFromNib(); this.BtnClose.Activated += (object sender, EventArgs e) => { this.Close(); NSApplication.SharedApplication.StopModalWithCode(0); }; this.BtnAdd.Activated += OnClickAddGroupButton; foreach (NSTableColumn column in GroupsTableView.TableColumns()) { GroupsTableView.RemoveColumn(column); } GroupsTableView.Delegate = new TableDelegate(); var groupInfo = new GroupMembershipDto() { Groups = new List <GroupDto> () }; ActionHelper.Execute(delegate() { var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(ServerDto.ServerName); groupInfo = SnapInContext.Instance.ServiceGateway.Tenant.Search(ServerDto, TenantName, DomainName, MemberType.GROUP, SearchType.NAME, auth.Token); }); var listView = new GroupsDataSource { Entries = groupInfo.Groups }; var columnNames = new List <ColumnOptions> { new ColumnOptions { Id = "Name", DisplayName = "Group Name", DisplayOrder = 1, Width = 500 }, }; var columns = ListViewHelper.ToNSTableColumns(columnNames); foreach (var column in columns) { GroupsTableView.AddColumn(column); } GroupsTableView.DataSource = listView; GroupsTableView.ReloadData(); }
public async Task <ActionResult <GroupMembership> > GetGroupMembership(GroupMembershipDto groupMembershipDto) { return(await _groupService.GetGroupMembershipAsync(groupMembershipDto.EmployeeId, groupMembershipDto.GroupId)); }
private void UpdateGroupMembership(GroupMembershipDto left, GroupMembershipDto right) { if (left.Groups == null && right.Groups != null) { var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(ServerDto.ServerName); SnapInContext.Instance.ServiceGateway.Group.AddGroups(ServerDto, TenantName, GroupDto, right.Groups, auth.Token); } else if (left.Groups != null && right.Groups != null) { var groups = new List <GroupDto> (); foreach (var group in left.Groups) { var fullName = group.GroupName + "@" + group.GroupDomain; if (right.Groups.FirstOrDefault(x => (x.GroupName + "@" + x.GroupDomain) == fullName) == null) { groups.Add(group); } if (groups.Count() > 0) { // remove var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(ServerDto.ServerName); SnapInContext.Instance.ServiceGateway.Group.RemoveGroups(ServerDto, TenantName, GroupDto, groups, auth.Token); } } groups = new List <GroupDto> (); foreach (var group in right.Groups) { var fullName = group.GroupName + "@" + group.GroupDomain; if (left.Groups.FirstOrDefault(x => (x.GroupName + "@" + x.GroupDomain) == fullName) == null) { groups.Add(group); } if (groups.Count() > 0) { // remove var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(ServerDto.ServerName); SnapInContext.Instance.ServiceGateway.Group.AddGroups(ServerDto, TenantName, GroupDto, groups, auth.Token); } } } if (left.Users == null && right.Users != null) { var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(ServerDto.ServerName); SnapInContext.Instance.ServiceGateway.Group.AddUsers(ServerDto, TenantName, GroupDto, right.Users, auth.Token); } else if (left.Users != null && right.Users != null) { var users = new List <UserDto> (); foreach (var user in left.Users) { var fullName = user.Name + "@" + user.Domain; if (right.Users.FirstOrDefault(x => (x.Name + "@" + x.Domain) == fullName) == null) { users.Add(user); } if (users.Count() > 0) { // remove var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(ServerDto.ServerName); SnapInContext.Instance.ServiceGateway.Group.RemoveUsers(ServerDto, TenantName, GroupDto, users, auth.Token); } } users = new List <UserDto> (); foreach (var user in right.Users) { var fullName = user.Name + "@" + user.Domain; if (left.Users.FirstOrDefault(x => (x.Name + "@" + x.Domain) == fullName) == null) { users.Add(user); } if (users.Count() > 0) { // remove var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(ServerDto.ServerName); SnapInContext.Instance.ServiceGateway.Group.AddUsers(ServerDto, TenantName, GroupDto, users, auth.Token); } } } if (left.SolutionUsers == null && right.SolutionUsers != null) { var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(ServerDto.ServerName); SnapInContext.Instance.ServiceGateway.Group.AddSolutionUsers(ServerDto, TenantName, GroupDto, right.SolutionUsers, auth.Token); } else if (left.SolutionUsers != null && right.SolutionUsers != null) { var users = new List <SolutionUserDto> (); foreach (var user in left.SolutionUsers) { var fullName = user.Name + "@" + user.Domain; if (right.SolutionUsers.FirstOrDefault(x => (x.Name + "@" + x.Domain) == fullName) == null) { users.Add(user); } if (users.Count() > 0) { // remove var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(ServerDto.ServerName); SnapInContext.Instance.ServiceGateway.Group.RemoveSolutionUsers(ServerDto, TenantName, GroupDto, users, auth.Token); } } users = new List <SolutionUserDto> (); foreach (var user in right.SolutionUsers) { var fullName = user.Name + "@" + user.Domain; if (left.SolutionUsers.FirstOrDefault(x => (x.Name + "@" + x.Domain) == fullName) == null) { users.Add(user); } if (users.Count() > 0) { // remove var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken(ServerDto.ServerName); SnapInContext.Instance.ServiceGateway.Group.AddSolutionUsers(ServerDto, TenantName, GroupDto, users, auth.Token); } } } }