410 likes | 442 Views
Visual Studio Team System. Visual Studio 2008 SDK. Agenda:. Introduction Work Item Object Model Event System Check-in Policies. Purpose of the SDK. Integrate existing management tools Work Items Change sets Test Results Integrate error logging systems
E N D
Visual Studio Team System Visual Studio 2008 SDK
Agenda: Introduction Work Item Object Model Event System Check-in Policies
Purpose of the SDK • Integrate existing management tools • Work Items • Change sets • Test Results • Integrate error logging systems • Create bugs, tasks, or other work items from system crash reports • Extend your development experience
Architecture of the SDK • Provides an abstraction over the underlying server architecture • Object models are grouped by feature area • Provides 2 main object models • Client Object Model • Work Item Tracking • Custom Check-in Policies • Application Tier Object Model • Event System
Team Foundation Server • Core object on a team foundation server • Abstracts the common infrastructure for TFS components: • Server discovery • User credentials • Team Projects • Work Item Store • Globalization information
Work Item Object Model • Provides a managed API to Work Item Tracking components of TFS • Programmatically create or change work items • Team Explorer uses this exact same API for its native work item functionality
Work Item Store • Root node of the Work Item Object Model • Retrieve instances of individual work items • Stores information about the context of work item • Created through an instance of the TeamFoundationServer class
Object Model Architecture • Hierarchical structure • TeamFoundationServer • WorkItemStore • Project • WorkItemTypes • WorkItemType • StoredQueries • FieldDefinitions • RegisteredLinkTypes
Architecture Breakdown • TeamFoundationServer class • The server that stores the Team Foundation Database • WorkItemStore class • Database that stores all Project and related data • Project • Describes the overall project
Architecture Breakdown • WorkItemTypes • A collection containing types of work items that exist within the project (bug, task, scenario, etc) • You can create a WorkItem as soon as you know a WorkItemType within a Project • Contains a collection FieldDefinitions specific to this work item type
Architecture Breakdown • FieldDefinitions • Desription for fields used throughout a project in a WorkItemStore or in a WorkItemType • RegisteredLinkTypes • Link types available to all Projects under a WorkItemStore • Links can link to things like ”Related WorkItem”, ”Source Code File”, ”Test Result”, and so on
Work Items Facts • Uniquely identified by an ID • Defined by a WorkItemType • Belongs to a project • Contains fields which are stored in a Field collection, as definied by its WorkItemType • Previous versions of it can be retrieved by specifying the revision number or the date/ or a revision
Retrieving Work Items • Retrieved through an instance of WorkItemStore • Can be retrieved by: • WorkItem ID • URI (vstfs:///WorkItemTracking/WorkItem/[ID]) • Using the WIQL • Previous versions can be retrieved by: • ID or URI plus DateTime • ID or URI plus revision number
Work Item Query Language • SQL-like language for querying work items against the work item object model • Build more complex queries than supported in the query builder (team explorer) • Returns a WorkItemCollection of all work items matching the query string
Demo Work Item Explorer
Eventing Service • Reliable, asynchronous publish-and-subscribe event notification system • Users and Services may subscribe • Two Subscription Models • E-mail (Plain Text or HTML) • Web Services
Event Types • There are several Event types • Not well documented • EventType is defined by a schema • Schema’s are located in the TFS installation folder • C:\Program Files\Microsoft Visual Studio 2008 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 under Project Alerts
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 • Viewed and modified in Team Explorer • Visual Studio 2008 Power Tools is required
Event Subscription • Programmatically Subscribe or UnSubscribe to TFS events • Required References • Microsoft.TeamFoundation.dll • IEventService - Provides support for event subscription • Microsoft.TeamFoundation.Client.dll • TeamFoundationServer Factory – TFS instance
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 Notification Desktop Notification
Custom Check-in Policy • Visual Studio Team System object model • Not fully documented • Part of the client object model
Creating Check-in Policies • Fully customizable • Enforce company coding standards • Disallow certain design patterns • 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 • Subscribe to CheckedPendingChangesChanged event in Initialize() • Visual Studio 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
Overriding Check-in Policies • User has the possibility of override the check-in policies • Information is logged • No direct or easy way to view the log, one must query directly to the database
Demo No Tabs Custom Policy View Overriden Check-in Policies