gpt4 book ai didi

c# - 如何从 TFS API 中的产品待办列表项中检索子任务列表?

转载 作者:太空狗 更新时间:2023-10-29 20:37:26 25 4
gpt4 key购买 nike

给定某个产品待办事项 ID,我想以编程方式检索 PBI 的子任务列表。

我知道任务中没有一个字段显示“Parent PBI Id”。我有一个可以运行的代码版本,但这真的很慢,因为我确实在客户端执行了部分过滤。

查看我目前的表现:

string wiqlQuery =
string.Format(
"Select ID, [Remaining Work], State " +
"from WorkItems " +
"where (([Work Item Type] = 'Task')" +
" AND ([Iteration Path] = '{0}' )" +
" AND (State <> 'Removed')" +
" AND (State <> 'Done')) ",
sprint, storyId);

// execute the query and retrieve a collection of workitems
WorkItemCollection workItems = wiStore.Query(wiqlQuery);

if (workItems.Count <= 0)
return null;

var result = new List<TaskViewModel>();
foreach (WorkItem workItem in workItems)
{
var relatedLink = workItem.Links[0] as RelatedLink;
if (relatedLink == null) continue;
if (relatedLink.RelatedWorkItemId != storyId) continue;

Field remWorkField = (from field in workItem.Fields.Cast<Field>()
where field.Name == "Remaining Work"
select field).FirstOrDefault();
if (remWorkField == null) continue;
if (remWorkField.Value == null) continue;

var task = new TaskViewModel
{
Id = workItem.Id,
ParentPbi = relatedLink.RelatedWorkItemId,
RemainingWork = (double) remWorkField.Value,
State = workItem.State
};

result.Add(task);
}

return result;

最佳答案

作为标准,MSF Agile 中的团队项目带有一组查询。查看“工作项”->“迭代 1”->“迭代积压”。

将此查询作为 WIQL 文件保存在磁盘中是完全可能的。
将它用作修改后的 wiqlQuery 应该可以减轻您所做的大量过滤工作。

编辑(回应评论:“好的,我做到了,但查询没有提到父项和链接(子)项之间的关系”):

我打开了一个默认的“Iteration Backlog”的WIQL:

<?xml version="1.0" encoding="utf-8"?>
<WorkItemQuery Version="1">
<TeamFoundationServer>
http://****>
<TeamProject>****</TeamProject>
<Wiql>SELECT [System.Id], [System.WorkItemType], [System.Title],
[System.State], [System.AssignedTo],
[Microsoft.VSTS.Scheduling.RemainingWork],
[Microsoft.VSTS.Scheduling.CompletedWork],
[Microsoft.VSTS.Scheduling.StoryPoints],
[Microsoft.VSTS.Common.StackRank],
[Microsoft.VSTS.Common.Priority],
[Microsoft.VSTS.Common.Activity], [System.IterationPath],
[System.AreaPath] FROM WorkItemLinks WHERE
(Source.[System.TeamProject] = @project and
Source.[System.AreaPath] under @project and
Source.[System.IterationPath] under '****\Iteration 1' and
(Source.[System.WorkItemType] = 'User Story' or
Source.[System.WorkItemType] = 'Task')) and
[System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward'
and Target.[System.WorkItemType] = 'Task' ORDER BY
[Microsoft.VSTS.Common.StackRank],
[Microsoft.VSTS.Common.Priority] mode(Recursive)</Wiql>
</WorkItemQuery>

检索相关项目的查询部分应该是这个

[System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward'

关于c# - 如何从 TFS API 中的产品待办列表项中检索子任务列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7656169/

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