我正在尝试(通过wql)获取已经处理过的所有任务,这意味着有人为他们记录了时间。 现在,我在记忆中这样做:
foreach (WorkItem wi in workItems)
{
foreach (Revision item in wi.Revisions)
{
try
{
// elided...
myTask.TimeSpent = item.Fields["Completed Work"].Value == null ?
0 : (double)item.Fields["Completed Work"].Value;
}
}
}
我希望能够在初始查询中执行此操作:
var query = "SELECT [System.Id] FROM WorkItems
WHERE [System.TeamProject] = '@project'
and [System.WorkItemType]='Task' *and [System.WorkItem.Completed_Work] <> 0*";
我尝试了不同的方法钻进“已完成的工作”字段:
[System.WorkItemRevisions.Completed_Work],
[System.WorkItem[Revisions[Completed_Work]]],
[System.WorkItem.Revisions.[Completed Work]]
但我总是得到例外。 有什么想法吗?
答案 0 :(得分:1)
问题是您用于CompletedWork
的引用名称,而另一个问题是@project
,因为该语句未在项目上下文中调用,因此@project
应该没有工作。这是我如何使用它的一个例子:
string query = "SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = '" + SelectedTeamProject + "' AND [System.WorkItemType]='Task' AND [Microsoft.VSTS.Scheduling.CompletedWork] <> 0";
如果您安装了TFS Power Tools,则可以通过检查Visual Studio中的Work Item Type Definition (WITD)
来获取正确的引用名称:
Tools-> Process Editor-> Work Item Types-> Open WIT from Server
Choose the Team Project Collection and the TeamProject where the Task is in
Open the Task definition and watch out for the Completed Work field and check the reference name for it