Ejemplo n.º 1
0
        public static async Task <IEnumerable <QueryHierarchyItem> > GetFolderContentsAsync(this WorkItemTrackingHttpClient source, TeamProject project, string folderPath, CancellationToken cancellationToken)
        {
            var query = await source.TryCatchAsync(c => c.GetQueryAsync(project.Id, folderPath, QueryExpand.All,
                                                                        depth: 1, includeDeleted: false, cancellationToken: cancellationToken),
                                                   new[] { "TF401243" }).ConfigureAwait(false);

            if (query == null || query.Id == Guid.Empty || !query.HasChildren.GetValueOrDefault())
            {
                return(Enumerable.Empty <QueryHierarchyItem>());
            }

            //Enumerate the children
            var items = new List <QueryHierarchyItem>();

            foreach (var child in query.Children)
            {
                if (child.IsFolder.GetValueOrDefault())
                {
                    items.AddRange(await source.GetFolderContentsAsync(project, child.Path, cancellationToken).ConfigureAwait(false));
                }
                else
                {
                    items.Add(child);
                }

                cancellationToken.ThrowIfCancellationRequested();
            }
            ;

            return(items);
        }
Ejemplo n.º 2
0
        public static async Task <List <QueryHierarchyItem> > GetSharedQueriesAsync(this WorkItemTrackingHttpClient source, TeamProject project, CancellationToken cancellationToken)
        {
            //We are limited to 2 levels so we have to query for each level one by one
            var queries = new List <QueryHierarchyItem>();

            queries.AddRange(await source.GetFolderContentsAsync(project, QueryExtensions.SharedQueriesPath, cancellationToken: cancellationToken).ConfigureAwait(false));

            return(queries);
        }