1

XML ファイルに情報を格納する社内設計ツールを使用して、一部の製品を開発しています。TFS との適切な統合を提供するために、チーム エクスプローラーと対話する必要なく、デザイナーを使用しているユーザーのチェックインおよびチェックアウト操作を TFS で追跡するプロバイダーもコーディングしました。

ファイルをチェックインするときに関連する作業項目も追加する必要があるため、いくつかの SDK サンプルをグーグル検索して参照しましたが、ユーザーがコードを関連付けることができる同じ Windows フォームを表示する方法があるかどうかを理解できませんでした。コードから作業項目を作成するか、コードから完全な Windows フォームを実装する必要がありますか (作業項目の取得と検索、それらの関連付け、チェックインの実行など)。2 つのソリューションには、記述する必要があるコードの量に大きな違いがあるため、情報をいただければ幸いです。

4

2 に答える 2

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
于 2009-10-26T13:34:57.773 に答える
0

MS コンサルタントに確認しましたが、TFS またはシェル拡張で使用されるチェックイン ウィンドウを表示するには、安全ではない低レベル コードを使用する必要があります。

したがって、可能な唯一の解決策は、TFS Api を使用して新しい C# コントロール/プロジェクトを作成し、TFS チェックイン ウィンドウを模倣することです。

よろしくマッシモ

于 2010-06-10T10:03:58.437 に答える