コード例 #1
0
        internal PagedGraphGroups GetAllGroups()
        {
            GraphHttpClient  graphClient = connection.GetClient <GraphHttpClient>();
            PagedGraphGroups groups      = graphClient.ListGroupsAsync().Result;

            return(groups);
        }
コード例 #2
0
        public void ConnectionIsCreated()
        {
            string        PAT           = Environment.GetEnvironmentVariable("ADOConnection_PAT");
            string        collectionUrl = Environment.GetEnvironmentVariable("ADOConnection_URL");
            ADOConnection aDOConnection = new ADOConnection(collectionUrl, PAT);

            using (GraphHttpClient graphClient = aDOConnection.Connection.GetClient <GraphHttpClient>())
            {
                PagedGraphGroups groups = graphClient.ListGroupsAsync().Result;
                Assert.IsNotNull(groups.GraphGroups);
            }
        }
コード例 #3
0
ファイル: ProcessAdoServices.cs プロジェクト: suposk/CSRO
        public async Task <List <string> > GetUsers(string organization)
        {
            VssConnection connection = null;

            try
            {
                string url = $"https://dev.azure.com/{organization}";
                if (_adoConfig.UsePta)
                {
                    connection = new VssConnection(new Uri(url), new VssBasicCredential(string.Empty, _adoConfig.AdoPersonalAccessToken));
                }
                //connection = new VssConnection()
                else
                {
                    connection = new VssConnection(new Uri(url), new VssClientCredentials(true));
                }

                GraphHttpClient  graphClient = connection.GetClient <GraphHttpClient>();
                PagedGraphGroups groups      = await graphClient.ListGroupsAsync();

                var users = await graphClient.ListUsersAsync();

                return(users?.GraphUsers.Where(a => a.Origin.Contains("ad", StringComparison.OrdinalIgnoreCase))?.Select(a => a.DisplayName)?.ToList());


                //UserHttpClient userHttpClient = connection.GetClient<UserHttpClient>();

                //TeamHttpClient teamHttpClient = connection.GetClient<TeamHttpClient>();

                //AccountHttpClient accountHttpClient = connection.GetClient<AccountHttpClient>();
                //var res = await accountHttpClient.GetAccountsAsync();
                //return res.Select(a => a.AccountName).ToList();

                //ProfileHttpClient profileHttpClient = connection.GetClient<ProfileHttpClient>();

                //OrganizationHttpClient organizatioClient = connection.GetClient<OrganizationHttpClient>();

                //var res = profileHttpClient.ge
                //var res = await teamHttpClient.GetTeamMembers()

                return(null);
            }
            catch (Exception ex)
            {
                //throw;
            }
            finally
            {
                connection?.Dispose();
            }
            return(null);
        }
コード例 #4
0
        public PagedGraphGroups GetAllGroups()
        {
            VssConnection    connection  = Context.Connection;
            GraphHttpClient  graphClient = connection.GetClient <GraphHttpClient>();
            PagedGraphGroups groups      = graphClient.ListGroupsAsync().Result;

            foreach (var group in groups.GraphGroups)
            {
                LogGroup(group);
            }

            return(groups);
        }
コード例 #5
0
    internal static async IAsyncEnumerable <GraphGroup> ListAllGroupsAsync(this GraphHttpClient client, string scopeDescriptor = null)
    {
        if (client is null)
        {
            throw new ArgumentNullException(nameof(client));
        }

        var graphGroupsPage = await client
                              .ListGroupsAsync(scopeDescriptor)
                              .ConfigureAwait(false);

        await foreach (var graphGroup in graphGroupsPage.AsContinuousCollectionAsync((continuationToken) => client.ListGroupsAsync(scopeDescriptor, continuationToken: continuationToken)))
        {
            yield return(graphGroup);
        }
    }