我有一个 TFS2012 插件,它使用
公共 EventNotificationStatus ProcessEvent()
获取 WorkItemChangedEvent。它没有做太多,它只是将 WorkItemChangedEvent 添加到消息队列中,以便稍后我可以使用不同的服务来获取它。
由于某种原因,该事件总是为我更改的每个工作项触发两次,并将该事件两次添加到我的队列中。
知道为什么吗?
我使用的代码:
public EventNotificationStatus ProcessEvent(
TeamFoundationRequestContext requestContext,
NotificationType notificationType, object notificationEventArgs,
out int statusCode, out string statusMessage, out ExceptionPropertyCollection properties)
{
statusCode = 0;
properties = null;
statusMessage = String.Empty;
try
{
if (notificationType == NotificationType.Notification && notificationEventArgs is WorkItemChangedEvent)
{
var ev = notificationEventArgs as WorkItemChangedEvent;
const string queueName = ".\\private$\\tfs";
var msgQueue = new MessageQueue(queueName);
var msg = new Message(ev);
msgQueue.Send(msg, MessageQueueTransactionType.Single);
Log.Debug(string.Format("Added event for work item #{0} to queue", ev.WorkItemTitle));
}
}
catch (Exception ex)
{
Log.Fatal("Error", ex);
return EventNotificationStatus.ActionDenied;
}
return EventNotificationStatus.ActionPermitted;
}