gpt4 book ai didi

c# - 如何使用c#在tfs 2012中获取保存的查询

转载 作者:太空狗 更新时间:2023-10-29 21:28:12 25 4
gpt4 key购买 nike

我需要在“我的查询”文件夹中获取 TFS 2012 中的查询。我找到了 this article .但接下来会给出所有查询。

Folder Hierarchy

我想从“我的查询”文件夹中获取查询。这是我到目前为止尝试过的:

string selectedProject = this.listProjects.SelectedItem.ToString();
TfsTeamProjectCollection teamProjectCollection = TFSDetail.GetTeamProjectDetails(UrlPath);
if (teamProjectCollection != null)
{
Project detailsOfTheSelectedProject = null;
WorkItemStore workItemStore =
(WorkItemStore)teamProjectCollection.GetService(typeof(WorkItemStore));

string folder = "My Queries";
var project = workItemStore.Projects[selectedProject];
QueryHierarchy queryHierarchy = project.QueryHierarchy;
var queryFolder = queryHierarchy as QueryFolder;
QueryItem queryItem = queryFolder[folder];
queryFolder = queryItem as QueryFolder;
}

当我添加 queryFolder 来观看时,它会给出以下输出:

Watch Window

我如何访问结果并获取这些值?

最佳答案

我通过以下方式解决了这个问题:

var project = workItemStore.Projects[selectedProject];
QueryHierarchy queryHierarchy = project.QueryHierarchy;
var queryFolder = queryHierarchy as QueryFolder;
QueryItem queryItem = queryFolder[folder];
queryFolder = queryItem as QueryFolder;
foreach (var item in queryFolder)
{
listQueries.Items.Add(item.Name);
}

关于c# - 如何使用c#在tfs 2012中获取保存的查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17825451/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com