我们使用内部设计工具开发一些产品,该工具将信息存储在XML文件中。为了提供与TFS的正确集成,我们还编写了一个提供程序,用于在TFS中跟踪用户在使用设计器时的签入和签出操作,而无需与团队资源管理器进行交互。
现在要求在签入文件时添加相关的工作项,我已经用Google搜索并浏览了一些SDK示例但是我无法理解是否有办法显示允许用户使用的相同窗体从代码中将代码与工作项相关联,或者我们是否必须从代码中实现完整的Windows窗体(检索和搜索工作项,关联它们,执行签入等)。任何信息都会受到赞赏,因为在两个解决方案之间,我们需要编写多少代码就会有很多不同。
答案 0 :(得分:1)
以下是一些有助于更新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
答案 1 :(得分:0)
我已经通过MS咨询检查过了,没有办法显示TFS或shell扩展使用的签入窗口,而没有使用不太安全的低级代码。
因此,唯一可行的解决方案是使用TFS Api创建一个新的C#控件/项目来模仿TFS签入窗口。
此致 马西莫