如何以编程方式将 NewLines 添加到 TFS 工作项文本框?

发布于 2024-09-25 03:47:01 字数 1154 浏览 4 评论 0原文

我有一个 Web 系统,它与我们的 TFS 工作项系统有一些挂钩。我想做的一件事是,当执行某个操作时,它会在一个字段中获取当前文本,并在“一般注释”字段中发表评论,宣布该字段之前的内容(是的,我知道,历史包含但上级希望在 gen 评论中看到这一点)。

我遇到的问题是 TFS 似乎忽略了我的字符串中的 Environment.NewLines 。因此,使用以下代码:

                    item.Fields[GENCOMMENTS].Value = string.Concat(DateTime.Now.ToShortDateString()
                                , " - QA Dashboard - Required By Date Reason set to \"Hotfix\", but previously contained \""
                                , item.Fields[REQBYDTREASON].Value.ToString()
                                , "\"."
                                , Environment.NewLine
                                , Environment.NewLine
                                , Environment.NewLine
                                , item.Fields[GENCOMMENTS].Value.ToString());

假设我的一般注释部分包含:

THIS SENTENCE WAS ALREADY IN GENERAL COMMENTS

保存工作项时,我在一般注释部分中得到以下输出

9/29/2010 - QA Dashboard - Required By Date Reason set to "Hotfix", but previously contained "hotfixtest".THIS SENTENCE WAS ALREADY IN GENERAL COMMENTS

为什么它会忽略新行以及如何在工作项中添加新行?

谢谢,

I have a web system that has a few hooks into our TFS work item system. One of the things I am trying to do is that when a certain action is performed, it takes the current text in one field and makes a comment in the "General Comments" field announcing what the field was previously (Yes I know, history contains this but the higher ups want this in the gen comments).

The problem I am having is that TFS seems to be ignoring Environment.NewLines that I have in my string. So with this code:

                    item.Fields[GENCOMMENTS].Value = string.Concat(DateTime.Now.ToShortDateString()
                                , " - QA Dashboard - Required By Date Reason set to \"Hotfix\", but previously contained \""
                                , item.Fields[REQBYDTREASON].Value.ToString()
                                , "\"."
                                , Environment.NewLine
                                , Environment.NewLine
                                , Environment.NewLine
                                , item.Fields[GENCOMMENTS].Value.ToString());

So assuming my general comments section contains:

THIS SENTENCE WAS ALREADY IN GENERAL COMMENTS

I get the following output in the general comments section when the work item is saved

9/29/2010 - QA Dashboard - Required By Date Reason set to "Hotfix", but previously contained "hotfixtest".THIS SENTENCE WAS ALREADY IN GENERAL COMMENTS

Why is it ignoring the new lines and how can I get a new line into the work item?

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

感情废物 2024-10-02 03:47:01

TFS 工作项内容通常作为 HTML 进行处理。这很可能发生在这里,因此它忽略了文本中无关的换行符。尝试将内容包装在

 块中或使用 

并查看是否可以解决问题。

TFS work item content is often processed as HTML. That's likely happening here and hence it's ignoring the extraneous newlines in the text. Try wrapping the content in a <pre> block or using <p> and see if that fixes the issue.

岁吢 2024-10-02 03:47:01

RTF 或 HTMl 控件将使用并呈现 html 标记 - 因此取决于控件。尝试向多行控件添加和格式化富文本,然后在控制台应用程序中对其进行调试 - 浏览字段值 - 您将看到 html 标记。

RTF or HTMl controls will use and render html markup - so depends on the control. Try adding and formatting rich text to a multiline control and then debug it in a console app - browse the field value - you'll see html tags.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文