WorkItemStore.Query(“YourQuery")在.Net c#中从TFS获取数据时出错 [英] WorkItemStore.Query("YourQuery") Getting Error when fetching data from TFS in .Net c#

查看:20
本文介绍了WorkItemStore.Query(“YourQuery")在.Net c#中从TFS获取数据时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用以下代码从 VSTF 服务器获取数据时遇到此问题.你能帮我如何扩展它的集合大小或其他东西来实现更多的记录.

I'm getting this problem when I'm fetching data from VSTF server using following code. Can you help me how can I extend its Collection Size or something else to achieve more records.

Uri tfsUri = new Uri(uri);
 TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(tfsUri, tfsCredential);
WorkItemStore workItemStore = new WorkItemStore(tfs);
var query = workItemStore.Query(projectquery);

我在此代码的最后一行出现错误.请遵循下面给出的以下错误:

处理团队项目[MyProject]"时发生错误处理团队项目[MyProject]":VS402337:工作数量返回的项目超过了 50000 的大小限制.将查询更改为返回更少的项目.Microsoft.TeamFoundation.WorkItemTracking.Client.VerbatimMessageException:VS402337:返回的工作项数量超过了50000. 更改查询以返回更少的项目.---> System.Web.Services.Protocols.SoapException: VS402337: 数量返回的工作项超过了 50000 的大小限制.更改查询返回更少的项目.在Microsoft.TeamFoundation.WorkItemTracking.Proxy.RetryHandler.HandleSoapException(SoapException)座位Microsoft.TeamFoundation.WorkItemTracking.Proxy.WorkItemServer.QueryWorkitemCount(StringrequestId, XmlElement psQuery, Boolean useMaster, Int32&数数,日期时间&asOfDate, MetadataTableHaveEntry[] metadataHave, String&dbStamp、IMetadataRowSets&元数据)在Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.QueryWorkItemCount(Stringrequestid、XmlElement queryXml、DateTime&asof) --- 内部结束异常堆栈跟踪 --- 在Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.QueryWorkItemCount(Stringrequestid、XmlElement queryXml、DateTime&asof) 在Microsoft.TeamFoundation.WorkItemTracking.Client.Query.RunCountQuery(字符串requestId) 在Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.QueryCount(Stringwiql,IDictionary 上下文)在TeamProjectManager.Modules.WorkItemConfiguration.WorkItemTypes.WorkItemTypesViewModel.<>c__DisplayClass82_0.b__0(Object发件人,DoWorkEventArgs e) 在C:\Users\jelled\Desktop\Code\TfsTeamProjectManager\Repo\TeamProjectManager.Modules.WorkItemConfiguration\WorkItemTypes\WorkItemTypesViewModel.cs:line169 检索到 22 个工作项类型

Processing Team Project "[MyProject]" An error occurred while processing Team Project "[MyProject]": VS402337: The number of work items returned exceeds the size limit of 50000. Change the query to return fewer items. Microsoft.TeamFoundation.WorkItemTracking.Client.VerbatimMessageException: VS402337: The number of work items returned exceeds the size limit of 50000. Change the query to return fewer items. ---> System.Web.Services.Protocols.SoapException: VS402337: The number of work items returned exceeds the size limit of 50000. Change the query to return fewer items. at Microsoft.TeamFoundation.WorkItemTracking.Proxy.RetryHandler.HandleSoapException(SoapException se) at Microsoft.TeamFoundation.WorkItemTracking.Proxy.WorkItemServer.QueryWorkitemCount(String requestId, XmlElement psQuery, Boolean useMaster, Int32& count, DateTime& asOfDate, MetadataTableHaveEntry[] metadataHave, String& dbStamp, IMetadataRowSets& metadata) at Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.QueryWorkItemCount(String requestid, XmlElement queryXml, DateTime& asof) --- End of inner exception stack trace --- at Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.QueryWorkItemCount(String requestid, XmlElement queryXml, DateTime& asof) at Microsoft.TeamFoundation.WorkItemTracking.Client.Query.RunCountQuery(String requestId) at Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore.QueryCount(String wiql, IDictionary context) at TeamProjectManager.Modules.WorkItemConfiguration.WorkItemTypes.WorkItemTypesViewModel.<>c__DisplayClass82_0.b__0(Object sender, DoWorkEventArgs e) in C:\Users\jelled\Desktop\Code\TfsTeamProjectManager\Repo\TeamProjectManager.Modules.WorkItemConfiguration\WorkItemTypes\WorkItemTypesViewModel.cs:line 169 Retrieved 22 work item types

推荐答案

你有两种方法可以解决这个问题:

You have two ways to fix that:

  • 添加查询条件以返回更少的项目,就像错误一样提到的消息.

  • Add the Query conditions to return fewer items just as the error message mentioned.

例如:

SELECT * FROM WorkItems WHERE [System.TeamProject] = @project AND [System.State] = 'Active' AND [System.AssignedTo] = 'joselugo'

分成几组分别返回.有一个用于检索所有工作项类型列表的示例供您参考:(参见 Github 了解详情.)

Split into groups to return them separately. There is a sample for retrieving list of all work item types for your reference: (See Github for details.)

//查询返回 20,000 个结果的 VSO 限制.最多分成 10,000 个项目的组.var 结果 = new List();无功计数器 = 10000;var moreResults = true;而(更多结果){列表currentResults = this.WitClient.QueryByWiqlAsync(new Wiql{Query = $"SELECT System.ID FROM WorkItems WHERE System.TeamProject = '{Project}' AND {customQuery} AND System.ID >= {counter - 10000} AND System.ID <{counter}"}).Result.WorkItems.ToList();

if (currentResults.Count == 0)
{
    // Verify there are no more items
    try
    {
        results.AddRange(this.WitClient.QueryByWiqlAsync(new Wiql
        {
            Query = $"SELECT System.ID FROM WorkItems WHERE System.TeamProject = '{Project}' AND {customQuery} AND System.ID >= {counter}"
        }).Result.WorkItems.ToList());

        moreResults = false;
    }
    catch (Exception e)
    {
        if (e.ToString().Contains("VS402337"))
        {
            // There are still more results, so increment and try again.
        }
        else
        {
            throw;
        }
    }
}
else
{
    results.AddRange(currentResults);
}

counter += 10000;

}

这篇关于WorkItemStore.Query(“YourQuery")在.Net c#中从TFS获取数据时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆