而不是簽入策略,您可以創建偵聽器來偵聽CheckInEvent。一旦事件被觸發,發出通知。那些服務器端插件正在實現ISubscriber interface,請參閱this blog後如何編寫和調試它們。
下面是從this blog代碼顯示的代碼在響應入住事件的示例實現,你可以參考一下吧:
namespace Sample.SourceControl.Server.PlugIns
{
public class CodeCheckInEventHandler : ISubscriber
{
public string Name
{
get { return "CodeCheckInEventHandler"; }
}
public SubscriberPriority Priority
{
get { return SubscriberPriority.Normal; }
}
public EventNotificationStatus ProcessEvent(TeamFoundationRequestContext requestContext, NotificationType notificationType, object notificationEventArgs, out int statusCode, out string statusMessage, out Microsoft.TeamFoundation.Common.ExceptionPropertyCollection properties)
{
statusCode = 0;
properties = null;
statusMessage = String.Empty;
try
{
if (notificationType == NotificationType.Notification && notificationEventArgs is WorkItemChangedEvent)
{
CheckinNotification ev = notificationEventArgs as CheckinNotification;
TeamFoundationApplication.Log(string.Format("New Changeset was checked in by {0}. ID: {1}, comments: {2}", ev.ChangesetOwnerName, ev.Changeset, ev.Comment), 123, System.Diagnostics.EventLogEntryType.Information);
}
}
catch (Exception ex)
{
TeamFoundationApplication.LogException("Sample.SourceControl.Server.PlugIns.CodeCheckInEventHandler encountered an exception", ex);
}
return EventNotificationStatus.ActionPermitted;
}
public Type[] SubscribedTypes()
{
return new Type[1] { typeof(CheckinNotification) };
}
}
}