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

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

问题描述

我们将TFS中的迭代链接到外部系统,以便通过整个公司跟踪项目。过去,我们使用TFS项目中的IterationPath进行链接,但问题是人们在项目进度时重命名这些IterationPaths,并且链接丢失。经过一些研究,我正在考虑使用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天全站免登陆