0

TFS 2010 のコレクション、プロジェクト、および作業項目を使用して作業を開始するための良い例を探しています。

次のコードを使用して、コレクションとプロジェクトを反復処理できます (元のコーダーのおかげです)。

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

コレクションから特定のプロジェクトを読み取り、作業項目 (タスク、バグ、問題など) を反復処理したいと考えています。どんな助けでも大歓迎です。

ありがとう。

4

1 に答える 1

0

teamProjectCollection以下を使用して、レベルで任意のクエリを実行できます。

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

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

queryこれで、必要なものを提供するものに - 文字列を定式化するだけで済みます。

クエリはWIQLのようなものです。これは非常に基本的なことで、TeamProject 内のすべての作業項目を提供できます。

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


@project私たちの場合はここにありますprojectNode.Resource.DisplayName

(「名前を付けて保存」を使用してTFSでグラフィカルに設定したクエリを* .wiqファイルとして保存し、そのコンテンツをプログラムで使用できます)

于 2011-07-27T09:05:50.660 に答える