Пример #1
0
        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();
        }