2011-07-27 17 views
0

TFS 2010のコレクション、プロジェクト、および作業項目を使い始める良い例を探しています。特定のコレクションからTFS2010プロジェクトを取得する方法

私は、次のコードを使用してコレクションやプロジェクトを通じて(元コーダのおかげで)反復処理することができる午前

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 

私は(タスク、バグ、問題、コレクションから特定のプロジェクトを読み込んで、作業項目を反復処理したいです等)。どんな助けも高く評価されます。

ありがとうございました。 - あなたが必要なものを提供します何かの文字列

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

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

今すぐあなただけ queryを策定する必要がありますとレベル -

答えて

1

あなたがteamProjectCollectionで好きなクエリを実行することができます。

クエリはWIQLのようです。これは非常に基本的にはTeamProject以内にあなたにすべての作業項目を与えることができます:

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


@projectがここに私たちのケースであるprojectNode.Resource.DisplayName

(あなたは「グラフィカルにTFSに設定された」VEの任意のクエリを保存することができます「* .wiqファイル」として保存して&の内容をプログラムで使用してください)

+0

ありがとうございます。コードはまさに私が望むものでした。 – SSiddiqui

関連する問題