SQL 2008 R2 Master Data Services (MDS) has a basic plugin framework which allows you to handle events when business rule workflows are kicked off. You implement your custom plugins by:
1) Creating a class that implements IWorkflowTypeExtender. This is contained in the following assembly:
C:\Program Files\Microsoft SQL Server\Master Data Services\WebApplication\bin\Microsoft.MasterDataServices.Core.dll
2) Build and deploy the file to the bin directory (typically "C:\Program Files\Microsoft SQL Server\Master Data Services\WebApplication\bin") or a subdirectory of it if you use a PrivatePath (discussed below).
3) Modify the "
Microsoft.MasterDataServices.Workflow.exe.config" file to point to your new assembly:
<configuration>
<configsections>
<section name="loggingConfiguration" requirepermission="true" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectiongroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Microsoft.MasterDataServices.Workflow.Properties.Settings" requirepermission="false" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
</sectiongroup>
</configsections>
4) Add another section to your config file that indicates what workflows to listen to (based on the value flag)
<applicationSettings>
<Microsoft.MasterDataServices.Workflow.Properties.Settings>
<setting name="ConnectionString" serializeAs="String">
<value>Server=.;Database=MasterDataServices;Integrated Security=SSPI</value>
</setting>
<setting name="WorkflowTypeExtenders" serializeAs="String">
<value>PAC=CompanyName.MasterDataWorkflow.WorkflowExtender, CompanyName.MasterDataWorkflow;OOB=Microsoft.MasterDataServices.Workflow.WorkflowTypeTest, Microsoft.MasterDataServices.Workflow, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91</value>
</setting>
</Microsoft.MasterDataServices.Workflow.Properties.Settings>
</applicationSettings>
<appSettings>
The plugin will allow you to obtain information about the calling workflow via the
StartWorkflow(string workflowType, System.Xml.XmlElement dataElement) method that must be implemented as part of the interface of IWorkflowTypeExtender. You receive all the business context data via the data element parameter as an Xml snippet.
Once you have deployed this assembly and update the config files, the simplest way to debug inside Visual Studio is to go to your Project Properties, Debug Tab and Set the Startup Program to be
"C:\Program Files\Microsoft SQL Server\Master Data Services\WebApplication\bin\Microsoft.MasterDataServices.Workflow.exe".
After doing that, add a commandline parameter of
"-console" which will give you a visual display of workflow plugins that have been loaded into the MDS Workflow Application Domain. It also allows you to print out to the console via Console.WriteLine() to assist with your development and debugging efforts.
Debug Setup
The MDS Workflow Console window:
As a best practice, use a PrivatePath in your Assembly Bindings in your Microsoft.MasterDataServices.Workflow.exe.config file. This will allow fusion to find your custom binaries in a subfolder rather than the binary root. Keeping all custom binaries in subfolders will help you to avoid file naming conflicts or bloating your root MDS workflow bin directory.
The simplest way to see what's going on is to just render the Xml from the workflow handler to the MDS workflow console window via an XmlTextWriter e.g.
public void StartWorkflow(string workflowType, System.Xml.XmlElement dataElement)
{
Console.WriteLine("workflow type: {0} ", workflowType);
var writer = new XmlTextWriter(Console.Out);
writer.Formatting = Formatting.Indented;
dataElement.WriteTo(writer);
DDK