如何从代码中显示关联工作项?

发布于 2024-08-09 03:08:31 字数 313 浏览 4 评论 0原文

我们使用内部设计工具开发一些产品,该工具将信息存储在 XML 文件中。为了提供与 TFS 的正确集成,我们还编写了一个提供程序,该提供程序可以在 TFS 中跟踪用户在使用设计器时的签入和签出操作,而无需与 Team Explorer 进行交互。

现在的要求是在签入文件时添加相关的工作项,我已经用谷歌搜索并浏览了一些 SDK 示例,但我无法理解是否有一种方法可以显示相同的 Windows 窗体,允许用户将代码关联到从代码中获取工作项,还是必须从代码中实现完整的窗口表单(检索和搜索工作项、关联它们、执行签入等)。任何信息将不胜感激,因为这两个解决方案之间在我们需要编写多少代码方面存在很大差异。

We develop some product using an internal design tool that stores information in XML files. To provide proper integration with TFS we've also coded a provider that tracks, in TFS, checkin and checkout operation from users while they're using the designer, without any need to interact with Team Explorer.

Now the requirement is to add also the related workitem when checking in files, I've googled around and browsed some SDK samples but I was not able to understand if there is a way to show the same windows form that allow user to associate code to workitem from code or do we have to implement the full windows form from code (retrieve and search workitems, associate them, perform the checkin and so on). Any info would be appreciated because between the two solution there is a lot of difference in term of how much code we need to write.

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

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

发布评论

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

评论(2

南城旧梦 2024-08-16 03:08:31

以下是一些有助于更新工作项的代码。另外,请尝试[此链接][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

Here is some code to help with updating workItems. Also, try [this link][1] for more information.

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
喜爱皱眉﹌ 2024-08-16 03:08:31

我已经与 MS 咨询公司核实过,如果不诉诸不太安全的低级代码,就无法显示 TFS 或 shell 扩展使用的签入窗口。

因此,唯一可能的解决方案是使用 TFS Api 创建一个新的 C# 控件/项目来模拟 TFS 签入窗口。

问候
马西莫

I've checked with MS consultancy and there is no way to show the checkin window used by TFS or the shell extension without resorting to low level code that is not really safe.

So only possible solution is to use the TFS Api to create a new C# control/project to mimic the TFS checkin window.

Regards
Massimo

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