Reputation: 2976
I am trying to subscribe to CheckinEvent
in TFS 2010 using TFS IEventService
. For some reason I keep getting:
Event type <<event type>> does not exist
for WorkItemChangedEvent
and CheckinEvent
. What am I doing wrong?
var serverUri = new Uri("http://TFS_SERVICE:8080/tfs");
var server = TfsConfigurationServerFactory.GetConfigurationServer(serverUri);
var eventService = server.GetService<IEventService>();
var preference = new DeliveryPreference
{
Schedule = DeliverySchedule.Immediate,
Type = DeliveryType.Soap,
Address = "http://localhost:61773/NotifyService.asmx"
};
int eventId = eventService.SubscribeEvent("CheckinEvent", null, preference);
Upvotes: 2
Views: 539
Reputation: 26992
You are querying the Event Service at the Configuration Server level. These event types only exist at the team project collection level, which I assume is where you actually want to create your event subscription. You would need to change your code to something like the following:
var serverUri = new Uri("http://TFS_SERVICE:8080/tfs/collection");
TfsTeamProjectCollection collection = new TfsTeamProjectCollection(serverUri);
var eventService = collection.GetService<IEventService>();
var preference = new DeliveryPreference
{
Schedule = DeliverySchedule.Immediate,
Type = DeliveryType.Soap,
Address = "http://localhost:61773/NotifyService.asmx"
};
int eventId = eventService.SubscribeEvent("CheckinEvent", null, preference);
Please note that the URI needs to include your collection name.
Upvotes: 4
Reputation: 1270
Instead of using the TfsConfigurationServerFactory
, use the TfsTeamProjectCollectionFactory.GetTeamProjectCollection()
method. These events exist at the collection level, rather than the server level.
Upvotes: 1