Objective
允许在MSF Agile过程模板的描述字段Rich HTML格式。
Note: MSF CMMI过程默认情况下支持HTML格式。为了使用它,你必须启用格式工具栏(见下文第6步) 。
Work Item Customization
步骤1:添加一个新的HTML描述字段
由于System.Description字段定义字符串类型,而不是我们需要创建一个新的字段输入的HTML :
第2步:更改工作项目布局
用它代替System.Description
第3步:刷新工作项缓存
右击团队资源管理器“工作项目” ,然后选择“刷新”
步骤4:启用格式工具栏
Visual Studio的工具栏上单击鼠标右键,找到并单击“格式”
A new toolbar will appear:
结果
点击进入说明字段,并使用工具栏来格式化您的输入:
可选步骤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