如何从特定集合中检索 TFS2010 项目

发布于 2024-11-26 06:42:58 字数 1899 浏览 1 评论 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

我想从集合中读取特定项目并迭代工作项(任务、错误、问题等)。任何帮助将不胜感激。

谢谢。

I'm looking around for a good example to work with TFS 2010 collections,projects, and workitems to start with.

I am able to iterate through collections and Projects using the following code (thanks to original coder)

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

I want to read specific project from a collection and iterate through workitems (tasks,bugs,issues,etc). Any help would be highly appreciated.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁对谁错谁最难过 2024-12-03 06:42:58

您可以在 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 文件,然后以编程方式使用其内容)

You can run any query you like in the teamProjectCollection - level with:

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

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

Now you only have to formulate the query - string in something that provides you with what you need.

Queries are WIQL - like. This very basic can give you all work items within a TeamProject:

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

@project is in our case here the projectNode.Resource.DisplayName

(You can save any query you 've graphically set in TFS with 'Save as' as a *.wiq file & then use it's content programmatically)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文