积极答复者
如何快速得到一个workitem相关联的workitem的类型呢

问题
-
hi,
我用的是TFS2008
假设我现在有个work item type是 persona,我想得到link到这个persona上的所有的 type是 product backlog item 的work item,我该怎么做的,我现在的做法会很慢。
我是这么做的,我先根据这个persona的 id 得到这个persona 的workitem,然后循环查看它的links,看看每个link的类型
WorkItem
personaWi = GetWorkItem(personaID);foreach (Link l in personaWi.Links)
{
if (l is RelatedLink)
{
WorkItem wi = GetWorkItem(((RelatedLink)l).RelatedWorkItemId);
if (wi.Type.Name == "Product Backlog Item")
{
do something to save the product backlog item
但是我发现每次都要调用GetWorkItem(((RelatedLink)l).RelatedWorkItemId), 这会要浪费很长时间,几乎调用一次要1秒钟左右,假如这个persona有100 个workitem,那么会等待相当长的时间。
请问有谁遇到过这个问题,可以帮助我吗
谢谢
}
}}
答案
全部回复
-
Hi,
如果relatedworkitem 很多的话, 可能是有这个问题, 因为GetWorkItem这个方法需要重新会服务器查询, 消耗的时间包括服务器查询的时间和网络上传输的时间. 你可以尝试在服务器(AppTier)上运行这个程序, 这样可以节省网络上消耗的时间.
Ruiz Yi [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-
怎么在 AppTier 上运行呢?我现在用了WIQL来查询,首先我先得到这个persona的所有relatedID,然后检索的时候用 where workitemID in (ids). 根据检索出来的workitem的type分类,这样只要调用一次服务器查询,感觉快了很多.
- 已建议为答案 liujj_xujjModerator 2011年3月11日 2:40
-
Hi,
这也是一个好办法, 一次获取所有的WorkItem, 主要就是节省服务器和客户端的来回多次消耗的传输时间.
直接将这个程序运行在TFS的服务器也是要节省传输消耗的网络上的时间.
Ruiz Yi [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
-