2

我正在尝试(通过 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]]

但我总是得到一个例外。有任何想法吗?

4

1 回答 1

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";

Work Item Type Definition (WITD)如果您安装了 TFS Power Tools,您可以通过在 Visual Studio 中检查来获得正确的参考名称:

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
于 2013-02-04T15:22:31.097 回答