【问题标题】:workitem.Save() storing multiple(duplicate) items into TFSworkitem.Save() 将多个(重复)项目存储到 TFS
【发布时间】:2018-01-09 08:02:34
【问题描述】:

我使用下面的代码将工作项存储到 TFS 中,但有时当 TFS 不可用/或某些异常时,它会将具有相同详细信息的 4 个项目存储到 TFS 中。我正在使用下面的代码。

private static void SaveWorkItemtoTFS(WorkItem wi, ref int retryCount)
        {

            try
            {                
                retryCount++;                
                wi.Save();
            }
            catch (Exception ex)
            {
                if (retryCount <= 3)
                {
                    Thread.Sleep(TimeSpan.FromSeconds(5));
                    wi.SyncToLatest();
                    SaveWorkItemtoTFS(wi, ref retryCount);
                }
                else
                {
                    throw ex;
                }
            }
        }

我只想存储唯一的项目。但它存储了 4 个具有相同细节的项目。你能帮忙吗?

例外情况是: 技术信息(针对管理员): 操作已超时---> System.Net.WebException:操作已超时 在 System.Net.HttpWebRequest.GetResponse() 在 Microsoft.TeamFoundation.Client.Channels.TfsHttpWebRequest.SendRequestAndGetResponse(HttpWebRequest webRequest, WebException& webException) --- End of inner exception stack trace --- atTfsProj.BusinessLogic.SaveWorkItemtoTFS(WorkItem wi, Int32& retryCount) atTfsProj.BusinessLogic.SaveWorkItemtoTFS(WorkItem wi, Int32& retryCount)@ 987654324@TfsProj.BusinessLogic.SaveWorkItemtoTFS(WorkItem wi, Int32& retryCount) atTfsProj.BusinessLogic.SaveWorkItemtoTFS(WorkItem wi, Int32& retryCount) atTfsProj.BusinessLogic.AddNewCertificationTaskIntoTFS(RequestModel objRequestId)`RequestModel, String requestId, String clientRe p>

这个错误只发生过一次,也无法重现。

【问题讨论】:

  • 同步到最新的ID是否可用?您能否告诉我们您使用的是哪个 TFS 版本以及具体发生了哪些异常?
  • 可以分享详细的异常信息吗?

标签: c# api recursion tfs


【解决方案1】:

根据异常,从 TFS Server 获取响应时发生错误。当您通过Save() 方法创建工作项时,它会先向TFS Server 发送请求,然后等待响应来检查工作项是否创建成功。因此,在您的问题中,条件是创建工作项请求已成功发送并且工作项已成功创建,但代码未从 TFS 服务器获得响应,导致抛出异常并再次尝试了 3 次。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    • 2023-03-03
    • 1970-01-01
    • 2013-07-09
    • 1970-01-01
    • 2019-11-15
    • 2023-03-29
    相关资源
    最近更新 更多