【问题标题】:How to get "Repro Steps" of a list of work items?如何获取工作项列表的“复制步骤”?
【发布时间】:2016-12-16 13:35:34
【问题描述】:

我的团队已经使用 VSTS 8 个月了。现在,我们的客户要求获得 VSTS 中工作项的“复制步骤”。 有没有什么办法可以得到没有HTML格式的“Repro Steps”的内容?

【问题讨论】:

    标签: visual-studio azure-devops


    【解决方案1】:

    不,因为 Repro Steps 值是可以包含图像等的富文本......。因此,如果只返回没有 HTML 格式的数据,则该值是不正确的。

    但是,您可以删除 HTML 标记编程。

    简单代码:

     public static string StripHTML(string input)
            {
                return Regex.Replace(input, "<.*?>", String.Empty);
            }
    
    
    
    var u = new Uri("[collection URL]"");
     VssCredentials c = new VssCredentials(new Microsoft.VisualStudio.Services.Common.WindowsCredential(new NetworkCredential("[user name]", "[password]")));
     var connection = new VssConnection(u, c);
                var workitemClient = connection.GetClient<WorkItemTrackingHttpClient>();
                var workitem = workitemClient.GetWorkItemAsync(96).Result;
                object repoValue = workitem.Fields["Microsoft.VSTS.TCM.ReproSteps"];
                string repoValueWithOutformat = StripHTML(repoValue.ToString());
    

    【讨论】:

    • 谢谢@starain-MSFT,但是,它是否适用于“复制步骤”中的图像?
    • @shinjidev Repro Steps中image的值是带有img标签的URL,你可以通过请求该URL获取图片(例如IE中的浏览器)。注意:URL是编码的,需要替换&到 &
    • 不错@starain-MSFT。它工作得非常好。非常感谢:)
    猜你喜欢
    • 2017-08-11
    • 1970-01-01
    • 1970-01-01
    • 2021-04-19
    • 1970-01-01
    • 2018-09-19
    • 1970-01-01
    • 2015-04-09
    • 2017-03-31
    相关资源
    最近更新 更多