2

ローカルワークステーションでTFSワークステーションを監視するコードを記述しようとしていますが、現時点では、イベントを発生させるのに問題があります。

たとえば、ワークスペースに新しいフォルダーをマップする場合は、versionControl.UpdatedWorkspaceイベントをサブスクライブし、「get」を実行する場合は、versionControl.Gettingイベントにマップします。以下のコードは、動作するはずのコンソールアプリケーションですが、取得しても何も起こりません。これらのイベントを正常にサブスクライブする方法を知っている人はいますか?

VS2010、TFS 2010、WinXP SP3

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Text;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Framework.Client;
using Microsoft.TeamFoundation.Framework.Common;
using Microsoft.TeamFoundation.VersionControl.Client;

namespace TestEventHanling
{
    class Program
    {
        static void Main(string[] args)
        {
            Uri serverUri = new Uri(@"http://TfsServer:8080/tfs/collection");

            using (TfsTeamProjectCollection collection = new TfsTeamProjectCollection(serverUri, CredentialCache.DefaultCredentials))
            {

                VersionControlServer versionControl = (VersionControlServer)collection.GetService(typeof(VersionControlServer));
                versionControl.UpdatedWorkspace += new WorkspaceEventHandler(OnUpdatedWorkspace);
                versionControl.Getting += new GettingEventHandler(OnGetting);

                Console.WriteLine("Press \'q\' to quit.");
                while (Console.Read() != 'q') ;

            }
        }


        internal static void OnUpdatedWorkspace(object sender, WorkspaceEventArgs e)
        {
            foreach (WorkingFolder wf in e.Workspace.Folders)
            {
                Console.WriteLine("Workspace updated {0}", wf.ServerItem);
            }
        }

        internal static void OnGetting(Object sender, GettingEventArgs e)
        {
            Console.WriteLine("Getting: {0}, status: {1}", e.TargetLocalItem, e.Status);
        }


    }
}
4

1 に答える 1

1

私の理解では、これらはVersionControlServerのローカルインスタンスにあるイベントです。つまり、コード内でそのインスタンスを操作すると、それらが起動します。

たとえば、コードの別の場所でワークスペースを更新した場合、UpdatedWorkspaceハンドラーが起動します。

サーバー側でサブスクライブできるイベントのセットは少数ですが(チェックイン、ビルドなど)、VersionControlServerクラスを介してサーバーで何が起こっているかを監視できるかどうかはわかりません。

于 2011-03-04T15:57:25.200 に答える