280 likes | 464 Views
Visual Studio Team System. Extending the Visual Studio Team System. Agenda:. TFS Event Subscription Custom Check-in Policies. TFS Event Subscription. VSTS fires Events when various things happen Can subscribe to these events There are Two Subscription Models E-mail (Plain Text or HTML)
E N D
Visual Studio Team System Extending the Visual Studio Team System
Agenda: TFS Event Subscription Custom Check-in Policies
TFS Event Subscription • VSTS fires Events when various things happen • Can subscribe to these events • There are Two Subscription Models • E-mail (Plain Text or HTML) • Web Services
Event Types There are several Event types • BUT, they are not well documented • EventType is defined by a schema • Schema’s are located in the TFS installation folder • C:\Program Files\Microsoft Visual Studio 2005 Team Foundation Server\Web Services\Services\v1.0\Transforms • SOME Schema’s are definied in the database • In the TfsIntegration database, there is a table called tbl_event_type • USE TfsIntegration SELECT [name], [event_type_schema] FROM tbl_event_type
Available Event Types RED– available through Team Explorer – Project Alerts
Subscribing to Events • Certain Events are available through the Team Explorer • Right click on a selected project in the team explorer then click on Project Alerts
Demo Team Explorer Project Alerts
Subscribing to Events • Can subscribe to events using the command line tool on the server • C:\Program Files\Microsoft Visual Studio 2005 Team Foundation Server\TF Setup\BisSubscribe.exe
E-mail Subscription (BisSubscribe) • Run BisSubscribe.exe specifying: • The EventType • The E-mail Type (Plain Text or HTML) • Recipient (address to send the mail to) • Filter expression BisSubscribe.exe /eventType CheckinEvent /address christian@commentor.dk /deliveryType EmailHtml /server MAGNI /filter ”TeamProject=’Commentor Framework’”
Web Service Subscription • Run BisSubscribe.exe specifying: • The EventType • deliveryType as Soap • Web Service URL • Filter expression BisSubscribe.exe /eventType CheckinEvent /address http://christian/Service.asmx /deliveryType Soap /server MAGNI /filter ”TeamProject=’Commentor Framework’”
Web Service Definition • Must have a specific shape • XML passed in is definied by a schema • public void Notify(string, string);
Listing your Subscriptions • There is no direct way to list what subscriptions currently exist in the TFS • To view a list of subscriptions, one must query directly to the database
Programmatic Event Subscription • Visual Studio Industry Partner SDK • Customize, Extend... Create! • Programmatically Subscribe or UnSubscribe to TFS events • IEventService (Microsoft.TeamFoundation.Server) • Provides support for event subscription
IEventService • SubscribeEvent() • User ID (string) • Event Type (string) • Filter Expression (string) • DeliveryPreference() • Address – Email address or Web Service URL • Schedule – Daily, Weekly, Immediately • Type – EmailHtml, EmailPlaintext, or Soap (Web Services) • Classification (string) • Tag or Name to for the event
Programmatic Event Subscription • Add a reference to • Microsoft.TeamFoundation • Microsoft.TeamFoundation.Client
Cancelling Subscription • UnSubscribeEvent() • Subscription ID (int)
Demo Email Subscription via C# Web Service Subscription via C# Web Service Sample
Custom Check-in Policy • Visual Studio Team System object model • Not fully documented • Part of the VSIP SDK
Creating Check-in Policies • Fully customizable • Enforce company coding standards • Disallow tabs • Code documentation standards • Etc.
Creating a Check-in Policy • Create a new Class Library project • Add the [Serializable] attribute to the class • Add a reference to Microsoft.TeamFoundation.VersionControl.Client.dll • Make the class implement the following: • IPolicyDefinition • IPolicyEvaluation
IPolicyDefinition • Determines how the check-in policy is displayed to the user
IPolicyEvaluation • During the actual Check-in • Calls Initialize() then Evaluate()
Evaluating the Check-in • Initialize() is passed reference to IPendingCheckin • This gives access to any pending changes • Evaluate() returns an array of PolicyFailure objects
CheckedPendingChangesChanged • IPolicyEvaluate has PolicyStateChanged event definied on the interface • Visual Studio subscribes to this event • Policy can subscribe to CheckedPendingChangesChanged event in Initialize() • Subscribe to CheckedPendingChangesChanged event in Initialize() • VSTS fires CheckedPendingChangesChanged event to signal change of files being checked in • When files [de]selected in the Pending Check-ins Window • Respond to CheckedPendingChangesChanged event by: • Re-evaluating the Policy • Firing PolicyStateChanged event • Pass list of Policy Failures
Deplying Check-in Policies • Add registry entry on the server and clients • Assembly must be copied to: • Team Foundation Server machine • User workstations
Policy Error • Policy must be installed properly both on the server and client • Error dialog is shown otherwise
Demo No Tabs Custom Policy