[tfs] Using rich HTML descriptions instead of plain text

Objective

允许在MSF Agile过程模板的描述字段Rich HTML格式。

Note: MSF CMMI过程默认情况下支持HTML格式。为了使用它,你必须启用格式工具栏(见下文第6步) 。

Work Item Customization

步骤1:添加一个新的HTML描述字段

由于System.Description字段定义字符串类型,而不是我们需要创建一个新的字段输入的HTML :

2AddNewField

3AddNewField

第2步:更改工作项目布局

用它代替System.Description

4EditLayout

第3步:刷新工作项缓存

右击团队资源管理器“工作项目” ,然后选择“刷新” 

5RefreshWIs

步骤4:启用格式工具栏

Visual Studio的工具栏上单击鼠标右键,找到并单击“格式” 

6EnableFormattingToolbar

A new toolbar will appear:

7FormattingToolbar

结果

点击进入说明字段,并使用工具栏来格式化您的输入:

8UsingRichFormatting

 

可选步骤5 :复制旧的描述,以及新的HTML

这将是一个很可惜的失去现有的描述,以便让我们写使用Team Foundation对象模型,以“老”的描述复制到新的HTML字段一个小工具:

static void CopyOldDescriptions()
{
    // TODO: Change these values:
    string tfsName = "servertogo";
    string tfsProjectName = "WorkItemCustomization";
    string tfsHtmlDescriptionFieldName = "DescriptionHtml";
    string tfsWorkItemType = "Task";

    using (TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(tfsName))
    {
        WorkItemStore wit = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
        WorkItemCollection result = wit.Query(String.Format("SELECT [System.Id] FROM WorkItems WHERE [System.TeamProject] = '{0}' AND [System.WorkItemType] = '{1}'", tfsProjectName, tfsWorkItemType));
        List<WorkItem> affectedWorkItems = new List<WorkItem>();
        foreach (WorkItem wi in result)
        {
            if (wi.Description.Length > 0)
            {
                // Set new description
                string value = (string)wi[tfsHtmlDescriptionFieldName];
                if (String.IsNullOrEmpty(value))
                {
                    wi[tfsHtmlDescriptionFieldName] = wi.Description.Replace("\n", "<br>");
                }
                else
                {
                    wi[tfsHtmlDescriptionFieldName] += "<br><p>Old description:</p><p>" + wi.Description.Replace("\n", "<br>") + "</p>";
                }

                // Delete old description
                wi.Description = String.Empty;

                affectedWorkItems.Add(wi);
            }
        }

        if (affectedWorkItems.Count > 0)
        {
            wit.BatchSave(affectedWorkItems.ToArray());
            MessageBox.Show("Items updated: " + affectedWorkItems.Count);
        }
        else
        {
            MessageBox.Show("Nothing to do.");
        }
    }
}

快乐有你 :-)

from: http://msmvps.com/blogs/vstsblog/archive/2009/01/11/using-rich-html-descriptions-instead-of-plain-text.aspx 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值