如何从TFS所有集合 [英] How to get all collections from TFS

查看:283
本文介绍了如何从TFS所有集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用TFS API



请参阅的这里了解更多详情。这是TFS的东西最好的资源之一。


解决方案

 私人TfsConfigurationServer configurationServer; 
configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(URI);



公众的IList< KeyValuePair<的Guid,字符串>> GetCollections()
{
//ApplicationLogger.Log(\"Entered到GetCollections());
变种collectionList =新的List< KeyValuePair<的Guid,字符串>>();

{
configurationServer.Authenticate();

ReadOnlyCollection还< CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren(
新的[] {} CatalogResourceTypes.ProjectCollection,
假,
CatalogQueryOptions.None);
的foreach(CatalogNode collectionNode在collectionNodes)
{
变种collectionId =新的GUID(collectionNode.Resource.Properties [INSTANCEID]);
TfsTeamProjectCollection teamProjectCollection =
configurationServer.GetTeamProjectCollection(collectionId);

如果(teamProjectCollection == NULL)
继续;

collectionList.Add(新KeyValuePair<的Guid,字符串>(collectionId,teamProjectCollection.Name));
}
}
赶上(例外五)
{
ApplicationLogger.Log(E);
}

返回collectionList;
}

每个列表返回键值对包含集合GUID和集合名称


How to get the collections from TFS using TFS API

Please refer here for more details. This is one of the best resources on TFS stuff.

解决方案

private TfsConfigurationServer configurationServer;
configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(uri);



public IList<KeyValuePair<Guid, String>> GetCollections()
{
    //ApplicationLogger.Log("Entered into GetCollections() : ");
    var collectionList = new List<KeyValuePair<Guid, String>>();
    try
    {
        configurationServer.Authenticate();

        ReadOnlyCollection<CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren(
            new[] { CatalogResourceTypes.ProjectCollection },
            false,
            CatalogQueryOptions.None);
        foreach (CatalogNode collectionNode in collectionNodes)
        {
            var collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]);
            TfsTeamProjectCollection teamProjectCollection =
                configurationServer.GetTeamProjectCollection(collectionId);

            if (teamProjectCollection == null)
                continue;

            collectionList.Add(new KeyValuePair<Guid, String>(collectionId, teamProjectCollection.Name));
        }
    }
    catch (Exception e)
    {
        ApplicationLogger.Log(e);
    }

    return collectionList;
}

Each returned key value pair in the list contains the collection guid and collections name

这篇关于如何从TFS所有集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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