如何与 TFS 连接并获取特定用户的项目列表 [英] How to connect with TFS and get list of projects for a specific user
本文介绍了如何与 TFS 连接并获取特定用户的项目列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public List<string> ListAllProjects(){
TeamFoundationServer teamFoundationServer =
TeamFoundationServerFactory.GetServer(@"http:\ld-tfs08sp1:8080\");
teamFoundationServer.Authenticate();
WorkItemStore workItemStore = new WorkItemStore(@"http:\ld-tfs08sp1:8080\");
List<string> list = new List<string>();
foreach (Project pr in workItemStore.Projects)
{
list.Add(pr.Name);
}
if (list.Count == 0)
list.Add("Not Found");
return list;
}
推荐答案
以下示例将检索 TFS 2010 中给定团队项目集合 (TPC) 的团队项目列表:
Here is an example that will retrieve a list of Team Projects for a given Team Project Collection (TPC) in TFS 2010:
static void Main(string[] args)
{
var results = GetTfsProjects(new Uri("http://mytfsserver:8080/tfs/DefaultCollection"));
}
private static List<string> GetTfsProjects(Uri tpcAddress)
{
var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tpcAddress);
tpc.Authenticate();
var workItemStore = new WorkItemStore(tpc);
var projectList = (from Project pr in workItemStore.Projects select pr.Name).ToList();
return projectList;
}
希望这会有所帮助.
这篇关于如何与 TFS 连接并获取特定用户的项目列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文