Example #1
0
        private IReadOnlyList <long> GetWorkItemIdsByWiql(IterationTimeFrame iterationTimeFrame)
        {
            var iterationQueryValue = iterationTimeFrame switch
            {
                IterationTimeFrame.Current => "@CurrentIteration",
                IterationTimeFrame.Previous => "@CurrentIteration - 1",
                IterationTimeFrame.Next => "@CurrentIteration + 1",
                _ => "@CurrentIteration"
            };

            var httpResponse = _authorizedHttpClient.PostAsJsonAsync(
                $"https://dev.azure.com/{_azureDevOpsSettings.Organization}/{_azureDevOpsSettings.Project}/{_azureDevOpsSettings.Team}/_apis/wit/wiql?api-version=6.0",
                new
            {
                query =
                    $"Select [System.Id] From WorkItems Where [System.WorkItemType] IN ('Bug','User Story') AND " +
                    $"[State] <> 'Removed' AND [System.IterationPath] = {iterationQueryValue}"
            }).Result;

            var content = httpResponse.Content.ReadAsStringAsync().Result;

            // todo check if the content is null or empty and return appropriate response.
            return(JObject.Parse(content) !.SelectTokens("$.workItems[*].id") !.Select(a => Extensions.Value <long>(a))
                   .ToList());
        }
Example #2
0
        public IReadOnlyList <JObject> GetWorkItems(IterationTimeFrame iteration)
        {
            var workItemIds = GetWorkItemIdsByWiql(iteration);

            return(GetWorkItems(workItemIds));
        }