none
Master Data Services 2012 and SharePoint WorkFlow

    Debate general

  • During a discussion on this thread, we have discovered than MDS 2012 doesn't fire SharePoint WorkFlow with the Master Data Services  Workflow Windows Service (Microsoft.MasterDataServices.Workflow.Exe)

    The SharePoint WorkFlow Extender :

    Since i need making a SharePoint Workflow with MDS 2012, i have create the extender for SharePoint.

    You can get the source code from the extender here : SharePointExtenderForMDS2012

    By The Way, if you know how works an extender for MDS 2012, here is the code for the extender (included in the Project i have linked)

    using System;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Xml;
    using System.Xml.Linq;
    using Microsoft.MasterDataServices.WorkflowTypeExtender;
    namespace Sharepoint.WorkflowExtender
    {
    public class SPWorkflow : IWorkflowTypeExtender
    {
    public void StartWorkflow(string workflowType, System.Xml.XmlElement dataElement)
    {
    var doc = XDocument.Parse(dataElement.OuterXml);
    Dictionary<string, object> strs = new Dictionary<string, object>();
    try
    {
    var externalAction =
    (
    from e in doc.Elements()
    select new
    {
    Type = (string)e.Element(« Type »),
    SendData = (string)e.Element(« SendData »),
    Action_ID = (string)e.Element(« Action_ID »),
    Server = (string)e.Element(« Server_URL »),
    Model_ID = (int)e.Element(« Model_ID »),
    Model_Name = (string)e.Element(« Model_Name »),
    Entity_ID = (int)e.Element(« Entity_ID »),
    Entity_Name = (string)e.Element(« Entity_Name »),
    Version_ID = (int)e.Element(« Version_ID »),
    Member_ID = (int)e.Element(« Member_ID »),
    MemberData = new
    {
    Name = (string)e.Element(« MemberData »).Element(« Name »),
    Code = (string)e.Element(« MemberData »).Element(« Code »),
    Attributes = e.Element(« MemberData »).Elements().ToDictionary(ae => ae.Name, ae => ae.Value)
    }
    }
    ).Single();
    var member = externalAction.MemberData;
    DispatchSPWorkflow(externalAction.Server, externalAction.Action_ID, dataElement, strs);
    }
    catch (Exception)
    {
    throw;
    }
    }
    private static void DispatchSPWorkflow(string serverUrl, string workflowName, XmlNode dataElement,
    Dictionary<string, object> sites)
    {
    SPSite sPSite;
    SPWorkflowAssociation sPWorkflowAssociation;
    object obj = null;
    if (sites.TryGetValue(serverUrl, out obj))
    {
    sPSite = (SPSite)obj;
    }
    else
    {
    sPSite = new SPSite(serverUrl);
    sites[serverUrl] = sPSite;
    }
    SPWeb sPWeb = sPSite.OpenWeb();
    SPWorkflowManager workflowManager = sPSite.WorkflowManager;
    sPWeb.WorkflowAssociations.UpdateAssociationsToLatestVersion();
    foreach (SPWorkflowAssociation workflowAssociation in sPWeb.WorkflowAssociations)
    {
    if (!(workflowAssociation.Name == workflowName) || !workflowAssociation.AllowManual)
    {
    continue;
    }
    sPWorkflowAssociation = workflowAssociation;
    break;
    }
    if (sPWorkflowAssociation != null)
    {
    workflowManager.StartWorkflow(null, sPWorkflowAssociation, dataElement.OuterXml, 1);
    }
    }
    }
    }

    As always, this code is provided "as is" :)

    You have (sorry in french) the explanation here : Master Data Services 2012 and SharePoint WorkFlow - Part 1

    A complete Solution :

    To make a complete a solution, which contains the Extender and a WorkFlow Sample, i create a second blog post who explain all the tasks to achieve this goal.

    You can get the full source code (Extender AND Workflow project) here : SharePointExtenderForMDS2012AndWorkFlow

    And by the way, you ll have explanations (again in french :)) here : Master Data Services 2012 and SharePoint WorkFlow - Part 2


    Sébastien Pertus. Bewise

    martes, 17 de julio de 2012 15:28

Todas las respuestas