2017-01-10 44 views
0

我是我公司的VSTS帐户的管理员。我不时需要映射用户和项目,即列出特定用户所属的项目。徒劳无功,我看过很多VSTS的角落和缝隙,并搜索了在线文档。我很感激任何建议。VSTS列出用户参与项目

+0

你解决我们的解决方案的问题? –

回答

0

另一种方法是,你可以实现通过客户端SDK。

有简单的样品,以获得为您具体可以参考用户团队:

TfsTeamProjectCollection collection = new TfsTeamProjectCollection(new Uri("[collection url]")); 

      collection.EnsureAuthenticated(); 

      var structureService= collection.GetService<ICommonStructureService>(); 
      var teamprojects = structureService.ListAllProjects(); 
      TfsTeamService teamService = collection.GetService<TfsTeamService>(); 
      UserInfo user = new UserInfo(); 
      foreach (var tp in teamprojects) 
      { 

       var teamList = teamService.QueryTeams(tp.Uri); 
       foreach(var t in teamList) 
       { 
        var userIdentity = t.GetMembers(collection, MembershipQuery.Expanded).Where(ti=>ti.UniqueName.Equals("[user accunt, e.g. domain\\test]",StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); 
        if(userIdentity!=null) 
        { 
         user.Teams.Add(t.Name); 
         user.Alias = userIdentity.UniqueName; 
         user.DisplayName = userIdentity.DisplayName; 
        } 
       } 
      } 
      Console.WriteLine(user); 
      Console.Read();