Click here to Skip to main content
Click here to Skip to main content

TFS Event Handler Prototype Configuration Demystified

By , 21 Aug 2007
 

Introduction

There are a number of config options for the TFS Event Handler Prototype. I will describe all of them in depth here. The first step is to set the Windows Communication Foundation service options, which really only requires you to change one value.

<system.serviceModel>
    <services>
        <service name="RDdotNet.TeamFoundation.NotificationService">
            <endpoint address="http://[LocalMacheneName]:8677" 
                binding="basicHttpBinding"
                bindingConfiguration="" 
                contract="RDdotNet.TeamFoundation.INotificationService" />
        </service>
    </services>
</system.serviceModel>

The important one is the [LocalMacheneName] variable, which should be set to the local machine name, or the domain name that points to your computer if you have a crazy proxy.

The next step is to set the real options for this software. This starts with the <RDdotNet.TeamFoundation> options, and requires you to set a number of things.

<BaseAddress url="http://[LocalMacheneName]:3624/" />

Again, you need to set the machine name, but make sure that the port is different.

<TeamServers>
    <TeamServer name="[TFS Server Name]"
                url="http://[TFS Server Name]:8080/"
                subscriber="[Subscriber AD Account]"
                mailAddressFrom="[From Email Address]"
                mailFromName="[Form name]"
                mailServer="[email relay server]"
                logEvents="True"
                testMode="True"
                testEmail="[email to send testes to]"
                eventLogPath="C:\temp\TFSEventHandler\">
    </TeamServer>
</TeamServers>

In the Team Servers section, you need to list of all of the team servers that you are going to be handling events for. The system will automatically add event subscriptions for all Team Servers added here, but I have only tested with two, and I now always run the service on the TFS server.

TeamServer Options
Name Type Description
name System.String This should be a friendly name for the Team Foundation Server
url System.Uri The URI for the TFS you wish to connect to, including protocol and port
mailFromAddress System.String The address from which you want all emails sent by the system to say that they are sent
mailFromName System.String The display name of the from email address
mailServer System.String The mail server that you have permission for to send emails
logEvents System.Boolean A true or false value that enables logging of all events within that system; excellent for debugging...
testMode System.Boolean When in test mode, all emails sent by the system will only be sent to the email address defined by testEmail; set to false for production
testEmail System.String The email address that, when testMode is enabled, will receive all emails sent from the system
eventLogPath System.String The location that the event logs will be written to; all events received get assigned a System.Guid, and all logs pertaining to that event get saved in the corresponding folder
subscriber System.String The AD account name of the account that is writing the events; set to the name of your TFSSetup or TFSService accounts

Now you are ready to set the event handlers. These are defined within the "Events" section:

  • AclChangedEvent
  • Branchmovedevent
  • BuildCompletionEvent
  • BuildStatusChangeEvent
  • CommonStructureChangedEvent
  • DataChangedEvent
  • IdentityChangedEvent
  • IdentityCreatedEvent
  • IdentityDeletedEvent
  • MembershipChangedEvent
  • WorkItemChangedEvent

Now you need to add handlers for the events. Example:

<Event eventType="WorkItemChangedEvent">
  <Handlers>
    <Handler type="RDdotNet.TeamFoundation.WorkItemTracking.AssignedToHandler"
       assemblyFileName="RDdotNet.TeamFoundation.WorkItemTracking.AssignedTo.dll"
       assemblyFileLocation="~\EventHandlers\WorkItemTracking\">
    </Handler>
  </Handlers>
</Event>

<Event eventType="WorkItemChangedEvent">
  <Handlers>
    <Handler type="RDdotNet.TeamFoundation.WorkItemTracking.AssignedToHandler"
       assemblyFileName="RDdotNet.TeamFoundation.WorkItemTracking.AssignedTo.dll"
       assemblyFileLocation="~\EventHandlers\WorkItemTracking\">
    </Handler>
  </Handlers>
</Event>
</Events>

As you can see, you are theoretically allowed to use any event. Please keep in mind that only the WorkItemChangedEvent and the CheckInEvent have been tested. When you add the "Event" tag with the corresponding eventType (which is an enumerator), this tells the system which specific events to subscribe to.

You can then add handlers to an event. These handlers are fired whenever these events are received.

Name Type Description
eventType RDdotNet.TeamFoundation. EventTypes Enumerator that defines the list of possible events.
type System.Type This must be a valid type in the assembly listed in assemblyFileName
assemblyFileName System.String This must be a valid assembly found in the assemblyFileLocation
assemblyFileLocation System.String A location within the server's file system that holds this assembly; ~ denotes the application's root

If you are using friendly server names or TeamPlain, you can change the TFS server links to be TeamPlain ones using the UrlReplacements config element:

<UrlReplacements>
    <!-- The Url Replaces change the url listed in the event to valid public items
    Examples:
        This item changes the TFS url to a TeamPlain v1 url
        <Replace eventType="WorkItemChangedEvent" 
          old=":8080/WorkItemTracking/WorkItem.aspx?artifactMoniker=" 
          new="/workitem.aspx?id=" />
                    
        These items change the server location to a public host header:
        <Replace eventType="WorkItemChangedEvent" 
          old="[ServerProductionEnviromentName]" 
          new="[PublicProductionEnviromentUri]" />
        <Replace eventType="WorkItemChangedEvent" 
          old="[ServerDevelopmentEnviromentName]" 
          new="[PublicDevelopmentEnviromentUri]" />
    -->
</UrlReplacements>

This works by replacing values within the URL in the events. You specify the event type, what to look for, and what to replace it by. This allows greater control and the integration of TeamPlain into your world. If a task is assigned to someone outside of your departmental sphere who you have given permission to TFS but who knows nothing about it, they will still get an email that will link them through to TeamPlain.

And, that is it, you are all set. If you have installed the service and set the account that is used to run the service, you should get no errors when starting. No guarantees though :)

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

About the Author

Martin Hinshelwood
Instructor / Trainer Northwest Cadence
United States United States
Member

Martin Hinshelwood is an Senior ALM Consultant at Northwest Cadence, but also a Microsoft Visual Studio ALM MVPs in Washington, US (Formally UK) and has over 9 years experience in the software industry. He is a member of the Visual Studio ALM Rangers and is also a Professional Scrum Trainer. He regularly writes on his Processes, Practices & Tools blog, and speaks often on Scrum, good practices and Visual Studio ALM.

 

Martin aims to provide Strategic and Tactical consulting on successful implementations of new Processes, Practices & Tools within both small and large organisations across the world. These would include, but not be limited to:

 
  • Scrum Mentoring & Training - Scrum Master Training, Scrum Developer Training, Scrum Mentoring, Scrum Coaching
  •  
  • Practice improvements – Requirements (Backlog,Limiting Work In Progress, Relative Complexity, Acceptance Criteria, Planning Poker, User Stories, Use Cases, Visualisation) , Teams (Team Protection, Commitment), Code (Unit Testing, Branching, Continuous Integration, TDD, ), Test (Acceptance Test Driven Development, Automation, ), Release & Configuration (Continuous Delivery, Continuous Deployment)
  •  
  • Visual Studio ALM Implementation, upgrades & Training - Visual Studio, Team Foundation Server, Team Foundation Build & Microsoft Test Manager

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralException while running testapp [modified]membermarceloramos22 Nov '07 - 10:17 
I have built and installed this app. but the service does not start, and If I run the TestAPP form I get the following exception:
 
Message "An error occurred creating the configuration section handler for RDdotNet.TeamFoundation: Exception has been thrown by the target of an invocation. (C:\TFS_Event_Handler_(PROTOTYPE)\RDdotNet.TeamFoundation.TestApp\bin\Debug\RDdotNet.TeamFoundation.TestApp.vshost.exe.config line 36)" String
 
The inner exception returns me:
 
Message "Cannot create an abstract class." String
Source "mscorlib" String
 

On my config file I set all the variables as described on this post. Can anyone help me with what am I doing wrong?
 
PS: It seems that Me("HandlerConfig") is where the inner exception happens.
 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 22 Aug 2007
Article Copyright 2007 by Martin Hinshelwood
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid