C# 如何通过WIQL C代码在TFS中查找Sprint的所有bug、特性和任务工作?

C# 如何通过WIQL C代码在TFS中查找Sprint的所有bug、特性和任务工作?,c#,tfs,azure-devops,wiql,C#,Tfs,Azure Devops,Wiql,我想通过查询找到所有的bug、任务、特性和故事 在我们两个团队的所有冲刺中。 我的项目名为MRI_Scrum_GIt,有两个团队,包含两个Phoneix和SS团队,这两个团队包含正在进行或完成的受人尊敬的Sprint 在我的例子中,如何让所有的团队参与到项目查询中 我已在中使用组操作而不是操作创建了查询: 对于我的项目,保存的查询中的wiql为: 从[Source].[System.TeamProject]='VSTSScrum'和[Source].[System.WorkItemType]='

我想通过查询找到所有的bug、任务、特性和故事 在我们两个团队的所有冲刺中。 我的项目名为MRI_Scrum_GIt,有两个团队,包含两个Phoneix和SS团队,这两个团队包含正在进行或完成的受人尊敬的Sprint
在我的例子中,如何让所有的团队参与到项目查询中


我已在中使用组操作而不是操作创建了查询:

对于我的项目,保存的查询中的wiql为:

从[Source].[System.TeamProject]='VSTSScrum'和[Source].[System.WorkItemType]='Bug'或[Source].[System.WorkItemType]='Product Backlog Item'或[Source].[System.WorkItemType]='Feature'和[Source]的工作项链接中选择[System.Id]、[System.WorkItemType]、[System.AssignedTo]、[System.State]、[System.Tags]“VSTSScrum\SS”下的[System.IterationPath]或[Source],“VSTSScrum\Phoneix”下的[System.Links.LinkType]=“System.LinkTypes.Hierarchy Forward”和[Target]。[System.WorkItemType]=“Task”或[Target]。[System.WorkItemType]=“Product Backlog Item”按[System.Id]modeRecursive排序

您的请求的源代码:

using Microsoft.TeamFoundation.WorkItemTracking.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QueryLinkedWIQL
{
    class Program
    {
        static void Main(string[] args)
        {
            WorkItemStore _wistore = new WorkItemStore("http://server/collection");

            string _teamProject = "VSTSScrum";
            string _teamPhoneixRootIteration = "VSTSScrum\\Phoneix";
            string _teamSSRootIteration = "VSTSScrum\\SS";

                string _wiql = string.Format("SELECT [System.Id] FROM WorkItemLinks WHERE ([Source].[System.TeamProject] = '{0}'"+ 
                "AND ( [Source].[System.WorkItemType] = 'Bug'  OR  [Source].[System.WorkItemType] = 'Product Backlog Item'  OR  [Source].[System.WorkItemType] = 'Feature' ) " + 
                "AND ( [Source].[System.IterationPath] UNDER '{1}'  OR  [Source].[System.IterationPath] UNDER '{2}' )) " + 
                "And ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward') And " + 
                "([Target].[System.WorkItemType] = 'Task'  OR  [Target].[System.WorkItemType] = 'Product Backlog Item') ORDER BY [System.Id] mode(Recursive)",
                _teamProject, _teamPhoneixRootIteration, _teamSSRootIteration);

            Query _query = new Query(_wistore, _wiql);

            WorkItemLinkInfo[] _links = _query.RunLinkQuery();

            foreach(WorkItemLinkInfo _link in _links)
            {
                //process link info item ....
            }
        }
    }
}
==============================

如果您不了解您的所有团队。你可以在这里找到它们:

在这种情况下,您的所有团队都必须具有默认的迭代ProjectName\IterationName

using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QueryLinkedWIQL
{
    class Program
    {
        static List<string> ListTeams(TfsTeamProjectCollection pTpc, Project pProject)
        {
            TfsTeamService _teamService = pTpc.GetService<TfsTeamService>();
            var _teams = _teamService.QueryTeams(pProject.Uri.ToString());
            return (from t in _teams select t.Name).ToList();
        }

        static string ConstructTeamsString(string pProjectName, List<string> pTeamNames)
        {
            string _val = "";

            for(int  i = 0; i< pTeamNames.Count; i++)
                if (pTeamNames[i] == "SS" || pTeamNames[i] == "Phoneix") // I have many teams without iteration root name. So I use this if to remove unneeded teams. You can remove this line
                    _val += ((_val != "") ? " OR " : "") + string.Format("[Source].[System.IterationPath] UNDER '{0}\\{1}'", pProjectName, pTeamNames[i]);

            return _val;
        }

        static void Main(string[] args)
        {
            string _teamProject = "VSTSScrum";

            TfsTeamProjectCollection _tpc = new TfsTeamProjectCollection(new Uri("http://server/collection"));

            WorkItemStore _wistore = _tpc.GetService<WorkItemStore>();

            string _teamsStr = ConstructTeamsString(_teamProject, ListTeams(_tpc, _wistore.Projects[_teamProject]));

            string _wiql = string.Format("SELECT [System.Id] FROM WorkItemLinks WHERE ([Source].[System.TeamProject] = '{0}'"+ 
                "AND ( [Source].[System.WorkItemType] = 'Bug'  OR  [Source].[System.WorkItemType] = 'Product Backlog Item'  OR  [Source].[System.WorkItemType] = 'Feature' ) " + 
                "AND ( {1} )) " + 
                "And ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward') And " + 
                "([Target].[System.WorkItemType] = 'Task'  OR  [Target].[System.WorkItemType] = 'Product Backlog Item') ORDER BY [System.Id] mode(Recursive)",
                _teamProject, _teamsStr);

            Query _query = new Query(_wistore, _wiql);

            WorkItemLinkInfo[] _links = _query.RunLinkQuery();

            foreach(WorkItemLinkInfo _link in _links)
            {
                //process link info item ....
            }
        }
    }
}

你想得到简单的工作项列表还是工作项树?tree@shamrayaleksander以及如何让项目中的所有团队投入到我的案例中查询MRI_Scrumone的SS和phoniex最后一个问题我想要2017年12月1日至2018年2月29日期间的所有迭代功能任务、bug和故事。谎言是什么?它们是在2017年12月1日至2018年2月29日(第一季度)之间创建的。如果我只知道项目名称并希望找到所有的团队名称,该怎么办?q2.如果我知道团队名称和项目名称,我希望所有的迭代