0

我想找到查询来找到bugs,Task,Feature,Stories 我团队的所有冲刺。
我的项目名称中有 2 个团队“ MRI_Scrum_GIt ”,其中包含 2 个团队Phoneix 和 SS,这 2 个团队包含受尊重的冲刺(正在进行或完成)
以及如何让所有团队参与我的项目(查询)案例 SS 和 MRI_Scrum 的 phoniex

在此处输入图像描述

4

1 回答 1

2

我使用组操作而不是操作“In”创建了查询:

在此处输入图像描述

对于我在保存查询中的项目 wiql 是:

从 WorkItemLinks WHERE ([Source].[System.TeamProject] = 'VSTSScrum' AND ([Source].[System.WorkItemType] = 'Bug' OR [Source].[System.WorkItemType] = 'Product Backlog Item' OR [Source].[System.WorkItemType] = 'Feature') AND ([Source].[System.IterationPath] UNDER 'VSTSScrum\SS' OR [Source].[System.IterationPath] UNDER 'VSTSScrum\Phoneix'))和([System.Links.LinkType] = 'System.LinkTypes.Hierarchy -Forward') And ([Target].[System.WorkItemType] = 'Task' OR [Target].[System.WorkItemType] = 'Product Backlog Item') ORDER BY [System.Id] 模式(递归)

您的请求的源代码:

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 ....
            }
        }
    }
}
于 2018-02-22T09:57:50.153 回答