In the previous post (link , link ) we saw how to use the TFS 2010 object model to connect to a TFS server and recover the project collection therein.
Niche In this post we will see ways to retrieve the properties of these projects within the project collections.
Query on server nodes
The first way is to use a mechanism similar to that seen in the previous post for the recovery of the collections based on the use of the method QueryChildren property CatalogNode:
- Dim tfs = TfsConfigurationServerFactory . GetConfigurationServer ( New Uri ( "http://server:8080/tfs" )
-                                                                 New UICredentialsProvider ())
- Dim allProjects = tfs.CatalogNode.QueryChildren({ CatalogResourceTypes .TeamProject},
-                                            True ,
-                                            CatalogQueryOptions .IncludeParents)
In questo caso otteniamo una collezione in sola lettura di CatalogNode nella cui proprietà Resource sono presenti le proprietà del progetto (nome, descrizione, etc., etc.).
Poichè abbiamo utilizzato l’opzione IncludeParents, otteniamo che, per ogni catalogNode, la proprietà Parent contiene il nodo relativo alla collection di appartenenza.
Il parametro recurse=true nella precedente query è fondamentale in quanto i progetti non sono direttamente contenuti nel server.
Se mettiamo recurse=false otteniamo una collezione vuota.
Se volessimo ottenere i progetti contenuti in una specific collection, we could use a LINQ query like this:
- Dim tfs = TfsConfigurationServerFactory . GetConfigurationServer ( New Uri ( "http://server:8080/tfs" ) ,
- , & # 160; , & # 160; ; New UICredentialsProvider ())
- Dim allProjects = tfs.CatalogNode.QueryChildren({ CatalogResourceTypes .TeamProject},
-                                            True ,
-                                            catalog query options . Include parents)
- Dim collProjects = From n In allProjects . OfType ( Of CatalogNode ) ()
- & # 160; ; Where = n.ParentNode.Resource.DisplayName "DomusDotNet"
-                      Select n
Query sui nodi della Project Collection
Un altro modo per ottenere i progetti presenti all’interno di una collection è quello di eseguire una query sui nodi contenenti le risorse direttamente su un’istanza di TfsTeamProjectCollectionNel precedente post della serie, abbiamo visto i tre modi possibili per TfsTeamProjectCollection get an instance of the class. Suppose, then to have one and want to retrieve the properties of the projects in it:
- Dim collProjects tfsColl1.CatalogNode.QueryChildren = ({ CatalogResourceTypes . TeamProject},
- & # 160; , & # 160; , & # 160; False ,
-                                                          CatalogQueryOptions .None)
In questo caso non serve la recursione e il recupero dei nodi padre perchè i progetti sono gerarchicamente disposti sotto la collection.
 
0 comments:
Post a Comment