2011-07-27 6 views
0

Je suis à la recherche d'un bon exemple pour travailler avec les collections, les projets et les éléments de travail de TFS 2010 pour commencer.Comment récupérer des projets TFS2010 à partir d'une collection spécifique

Je suis en mesure de parcourir les collections et projets en utilisant le code suivant (grâce au codeur d'origine)

Dim tfsServer As String = "http://test.domain.com:8080/tfs" 
    tfsServer = tfsServer.Trim() 
    Dim tfsUri As Uri 
    tfsUri = New Uri(tfsServer) 
    Dim configurationServer As New TfsConfigurationServer(tfsUri) 
    configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri) 

    ' Get the catalog of team project collections 
    Dim collectionNodes As ReadOnlyCollection(Of CatalogNode) 
    Dim gVar As Guid() = New Guid() {CatalogResourceTypes.ProjectCollection} 
    collectionNodes = configurationServer.CatalogNode.QueryChildren(gVar, False, CatalogQueryOptions.None) 

    Dim strName As New StringBuilder 
    Dim strCollection As New StringBuilder 

    For Each collectionNode In collectionNodes 
     Dim collectionId As Guid = New Guid(collectionNode.Resource.Properties("InstanceID")) 
     strName.Length = 0 
     Dim teamProjectCollection As New TfsTeamProjectCollection(tfsUri) 
     teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId) 
     Response.Write("Collection:" & teamProjectCollection.Name & "<br/>") 

     ' Get a catalog of team projects for the collection 
     Dim hVar As Guid() = New Guid() {CatalogResourceTypes.TeamProject} 

     Dim projectNodes As ReadOnlyCollection(Of CatalogNode) 
     projectNodes = collectionNode.QueryChildren(hVar, False, CatalogQueryOptions.None) 

     ' List the team projects in the collection 
     For Each projectNode In projectNodes 
      strName.AppendLine(projectNode.Resource.DisplayName & "<br>") 
      'System.Console.WriteLine(" Team Project: " + projectNode.Resource.DisplayName) 
     Next 

     Response.Write(strName.ToString()) 

    Next 

Je veux lire projet spécifique d'une collection et itérer workitems (tâches, bugs, problèmes, etc). Toute aide serait très appréciée.

Merci.

Répondre

1

Vous pouvez exécuter une requête que vous aimez dans le teamProjectCollection - niveau:

 WorkItemStore workItemStore = (WorkItemStore)teamProjectCollection.GetService(typeof(WorkItemStore)); 
     WorkItemCollection queryResults = workItemStore.Query(query); 

     foreach (WorkItem workitem in queryResults) 
     { 
      Console.WriteLine(workitem.Title);    
     } 

Maintenant, il suffit de formuler la query - chaîne dans quelque chose qui vous offre ce dont vous avez besoin. Les demandes sont WIQL - comme. Ce très basique peut vous donner tous les éléments de travail dans un TeamProject:

SELECT [System.Id], [System.WorkItemType], [System.Title], [System.AssignedTo], [System.State] FROM WorkItems WHERE [System.TeamProject] = @project 


@project est dans notre cas ici la projectNode.Resource.DisplayName

(Vous pouvez enregistrer toute requête que vous avez graphiquement défini dans TFS avec ' Enregistrer en tant que fichier * .wiq & puis utiliser son contenu par programmation)

+0

Merci beaucoup @pantelif. le code a fait exactement ce que je voulais. – SSiddiqui

Questions connexes