题
我们使用内部设计工具开发一些产品,该工具将信息存储在 XML 文件中。为了提供与 TFS 的正确集成,我们还编写了一个提供程序,该提供程序可以在 TFS 中跟踪用户在使用设计器时的签入和签出操作,而无需与 Team Explorer 进行交互。
现在的要求是在签入文件时添加相关的工作项,我已经用谷歌搜索并浏览了一些 SDK 示例,但我无法理解是否有一种方法可以显示相同的 Windows 窗体,允许用户将代码关联到从代码中获取工作项,还是必须从代码中实现完整的窗口表单(检索和搜索工作项、关联它们、执行签入等)。任何信息将不胜感激,因为这两个解决方案之间在我们需要编写多少代码方面存在很大差异。
解决方案 2
我已经与 MS 咨询公司核实过,如果不诉诸不太安全的低级代码,就无法显示 TFS 或 shell 扩展使用的签入窗口。
因此,唯一可能的解决方案是使用 TFS Api 创建一个新的 C# 控件/项目来模拟 TFS 签入窗口。
关于Massimo
其他提示
以下是一些有助于更新workItems的代码。另外,请尝试[此链接] [1]以获取更多信息。
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.WorkItemTracking.Client;
namespace WorkItemTrackingSample2
{
class Program
{
static void Main(string[] args)
{
// Connect to the server and the store.
TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer("YourTfsServerNameHere");
WorkItemStore workItemStore = (WorkItemStore)tfs.GetService(typeof(WorkItemStore));
// Get a specific WorkItem from the store.
// Replace "12345" with a WorkItem ID appropriate for testing.
WorkItem workItem = workItemStore.GetWorkItem(12345);
// Save the existing Priority so we can restore it later.
int oldPriority = (int)workItem.Fields["Priority"].Value;
// Set the Priority to an arbitrarily high number.
workItem.Fields["Priority"].Value = 9999;
// Display the results of this change.
if (workItem.IsDirty)
Console.WriteLine("The workItem has changed, but has not been saved.");
if (workItem.IsValid() == false)
Console.WriteLine("The workItem is not valid.");
if (workItem.Fields["Priority"].IsValid == false)
Console.WriteLine("The workItem's Priority field is not valid.");
// Tries to save the invalid WorkItem.
try
{
workItem.Save();
}
catch (ValidationException)
{
Console.WriteLine("The workItem threw a ValidationException.");
}
// Set the priority to a more reasonable number.
if (oldPriority == 1)
workItem.Fields["Priority"].Value = 2;
else
workItem.Fields["Priority"].Value = 1;
// If the WorkItem is valid, saves the changed WorkItem.
if (workItem.IsValid())
{
workItem.Save();
Console.WriteLine("The workItem saved this time.");
}
// Restore the WorkItem's Priority to its original value.
workItem.Fields["Priority"].Value = oldPriority;
workItem.Save();
}
}
}
[1]: http://msdn.microsoft.com/en-us/library/bb130323(VS.80).aspx
不隶属于 StackOverflow