Example #1
0
        public async Task <IList <string> > GetWorkItems(string assignedTo, string account, string project, OAuthToken token)
        {
            account.ThrowIfNullOrWhiteSpace(nameof(account));
            token.ThrowIfNull(nameof(token));

            using (var client = await this.ConnectAsync <WorkItemTrackingHttpClient>(token, account))
            {
                var query = string.Format(" SELECT [System.Id], [System.WorkItemType], [System.Title]" +
                                          " FROM WorkItems" +
                                          " WHERE [System.TeamProject] = '{0}' AND [System.WorkItemType] IN ('Bug','Task') AND [System.State] = 'Active' AND [System.AssignedTo] CONTAINS '{1}'", project, assignedTo);

                var wiqlQuery = new Wiql()
                {
                    Query = query
                };
                var results = await client.QueryByWiqlAsync(wiqlQuery);

                var ids = results.WorkItems.Select(workItemReference => workItemReference.Id);

                if (!ids.Any())
                {
                    return(Enumerable.Empty <string>().ToList());
                }

                var workItemsForQueryResult = client
                                              .GetWorkItemsAsync(
                    ids,
                    expand: WorkItemExpand.All).Result;

                return(workItemsForQueryResult.Select(a => a.Fields["System.Title"].ToString()).ToList());
            }
        }
Example #2
0
        public async Task <Profile> GetProfile(OAuthToken token)
        {
            token.ThrowIfNull(nameof(token));

            using (var client = await this.ConnectAsync <ProfileHttpClient>(token))
            {
                return(await client.GetProfileAsync(new ProfileQueryContext(AttributesScope.Core)));
            }
        }
Example #3
0
        public async Task <IList <Account> > GetAccounts(OAuthToken token, Guid memberId)
        {
            token.ThrowIfNull(nameof(token));

            using (var client = await this.ConnectAsync <AccountHttpClient>(token))
            {
                return(await client.GetAccountsByMemberAsync(memberId));
            }
        }
Example #4
0
        public async Task <IList <IdentityRef> > GetTeamMembers(string account, string projectId, string teamId, OAuthToken token)
        {
            token.ThrowIfNull(nameof(token));

            using (var client = await this.ConnectAsync <TeamHttpClient>(token, account))
            {
                return(await client.GetTeamMembersAsync(projectId, teamId));
            }
        }
Example #5
0
        public async Task <IList <TeamProjectReference> > GetProjects(string account, OAuthToken token)
        {
            account.ThrowIfNullOrWhiteSpace(nameof(account));
            token.ThrowIfNull(nameof(token));

            using (var client = await this.ConnectAsync <ProjectHttpClient>(token, account))
            {
                var results = await client.GetProjects();

                return(results.ToList());
            }
        }