在 TFS 中查找 IterationID [英] Finding IterationID in TFS

查看:21
本文介绍了在 TFS 中查找 IterationID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在将 TFS 内的迭代链接到外部系统,以便在整个公司范围内跟踪项目.过去,我们在 TFS 项目中使用 IterationPath 进行链接,但问题是人们随着项目的进展重命名这些 IterationPath,并且链接丢失.因此,经过一些研究,我正在考虑使用 IterationID 进行链接.TFSWarehouse 中的 IterationID 与 WorkItemTracking 表中的 IterationID 不一样,我似乎找不到一种简单的方法来查找 IterationPath 的 IterationID?有人知道我们如何才能实现这一目标吗?

we are linking Iterations within TFS to an external system for tracking projects through the entire company. In the past, we were linking using the IterationPath in a TFS Project, but the problem is that people rename these IterationPaths as the projects progress, and the link is lost. So after some research, I'm thinking of doing the linking by using the IterationID. The IterationID in the TFSWarehouse is NOT the same as the IterationID in the WorkItemTracking table, and I can't seem to find an easy way to find the IterationID of an IterationPath? Anyone got any idea how we may be able to achieve this?

推荐答案

好的 - 经过一些进一步的挖掘,发现下面的代码遍历所有迭代,所以使用它的一个子集,我会得到我需要的 :)

OK - after some further digging, found the code below that iterates thru all the iterations, so using a subset of this, I will get what I needed :)

using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;

namespace TFSIterationList
{
    class Program
    {
        static void Main(string[] args)
        {
            string tfsServer = "tfs";
            string tfsProject = "Project Name";
            TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(tfsServer);
            WorkItemStore store = new WorkItemStore(tfsServer);
            PrintTreeNodeCount(store, tfsProject);
        }


        private static void PrintTreeNodeCount(WorkItemStore store, string tfsProject)
        {
            int iterationNodeCount = 0;
            NodeCollection rootNodeCollection = store.Projects[tfsProject].IterationRootNodes;
            GetChildNodeCount(rootNodeCollection, ref iterationNodeCount);
            Console.WriteLine(tfsProject + " Iteration nodes : " + iterationNodeCount);
         }

        private static void GetChildNodeCount(NodeCollection nodeCollection, ref int nodeCount)
        {
            nodeCount += nodeCollection.Count;
            for (int i = 0; i < nodeCollection.Count; i++)
            {

                Console.WriteLine(nodeCollection[i].Id + " : " + nodeCollection[i].Path);
                // Console.WriteLine(nodeCollection[i].Name);

                if (nodeCollection[i].ChildNodes.Count > 0)
                {  
                // Recursively walk through the child nodes
                    GetChildNodeCount(nodeCollection[i].ChildNodes, ref nodeCount);
                }
            }
        }

    }
}

这篇关于在 TFS 中查找 IterationID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆