Exemple #1
0
        public static async Task <QueryHierarchyItem> AddQueryAsync(this WorkItemTrackingHttpClient source, TeamProject project, QueryHierarchyItem query, CancellationToken cancellationToken)
        {
            //Have to build up the path to the query
            var queryPath = new QueryPath(query.Path);

            if (queryPath.Parent != null && !queryPath.Parent.IsRoot)
            {
                await source.AddFolderAsync(project, queryPath.Parent, cancellationToken : cancellationToken).ConfigureAwait(false);
            }

            //Clone the query
            var newQuery = new QueryHierarchyItem()
            {
                Clauses       = query.Clauses,
                Columns       = query.Columns,
                FilterOptions = query.FilterOptions,
                IsPublic      = query.IsPublic,
                LinkClauses   = query.LinkClauses,
                Name          = query.Name,
                QueryType     = query.QueryType,
                SortColumns   = query.SortColumns,
                SourceClauses = query.SourceClauses,
                TargetClauses = query.TargetClauses,
                Wiql          = query.Wiql
            };

            return(await source.CreateQueryAsync(newQuery, project.Id, queryPath.Parent?.FullPath, cancellationToken : cancellationToken).ConfigureAwait(false));
        }
        private (string Name, QueryPath Parent) NormalizePath()
        {
            var       name   = "";
            QueryPath parent = null;

            //Format is: [{parent}]/{Name}
            var index = FullPath.LastIndexOfAny(s_nodePathDelimiters);

            if (index > 0)
            {
                name   = FullPath.Substring(index + 1);
                parent = new QueryPath(FullPath.Left(index));
            }
            else
            {
                name = FullPath;
            };

            return(name, parent);
        }
Exemple #3
0
        public static async Task <QueryHierarchyItem> AddFolderAsync(this WorkItemTrackingHttpClient source, TeamProject project, QueryPath folderPath, CancellationToken cancellationToken)
        {
            var folder = await source.GetFolderAsync(project, folderPath.FullPath, cancellationToken).ConfigureAwait(false);

            if (folder != null)
            {
                return(folder);
            }

            //Ensure the parent folder exists, unless it is a root path
            cancellationToken.ThrowIfCancellationRequested();
            if (folderPath.Parent != null && !folderPath.Parent.IsRoot)
            {
                await source.AddFolderAsync(project, folderPath.Parent, cancellationToken).ConfigureAwait(false);
            }

            var query = new QueryHierarchyItem()
            {
                Name = folderPath.Name, IsFolder = true
            };

            cancellationToken.ThrowIfCancellationRequested();
            return(await source.CreateQueryAsync(query, project.Id, folderPath.Parent?.FullPath, cancellationToken : cancellationToken).ConfigureAwait(false));
        }