locked
storing WorkflowService MetaData in xamlx RRS feed

  • Question

  • I need to provide some additional info about a workflow template to the client. for example I may specify authorization , ui rules, or a list of primary states in a state workflow. promoting a property is not appropriate since it relies on persistence and is really instance data. I need it for the workflow template and prefer to define it in the workflow template and maybe retrieve it with  WorkflowInspectionServices. Any suggestions?

    • Edited by MarkBosley Tuesday, December 4, 2012 9:02 PM
    Tuesday, December 4, 2012 9:02 PM

Answers

  • Our solution is to use Workflow Instance Extention to store this information. In this case every activity could easily access it. We host workflows in WAS using AppFabric. When new WorkflowServiceHost is created, we load workflow metadata from database (you could also use .config or any other sources) and register new Workflow Extention, providing this metadata to it. Therefor every workflow of certain type share the same meta information.

    protected override WorkflowServiceHost CreateWorkflowServiceHost(WorkflowService service, Uri[] baseAddresses)
    {
    	WorkflowServiceHost host = base.CreateWorkflowServiceHost(service, baseAddresses);
    
    	//Load additional information about workflow
    	var descriptor = LoadDefinition(service.Name.LocalName);
    
    	//Register workflow extention
    	host.WorkflowExtensions.Add(() => new WorkflowContextExtention(descriptor));
    
    	return host;
    }

    Another idea would be to inject some "system" variable with default value that contains additional metadata. In our case it's not appropriate solution, because we allow editing workflows in workflow Designer by end-users and there is no way to make this variable hidden.

    Regards
    Alex

    • Marked as answer by MarkBosley Thursday, December 13, 2012 4:40 PM
    Friday, December 7, 2012 10:46 AM

All replies

  • Hi,

    You can create a workflow template by using IActivityTemplateFactory. For the detailed information, please refer to:

    IActivityTemplateFactory

    http://blogs.msdn.com/b/kushals/archive/2009/11/12/iactivitytemplatefactory.aspx

    Thanks.


    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, December 5, 2012 11:32 AM
  • good info for another scenario. But It does not address what I am looking for. I want to query metadata from outside the workflow. For example let's say I have an operation called Booked. And only certain people can call that operation. I want to define who has permissions to call that operation in the WF and I want to query for permissions on the client so I can enable/disable the button that will invoke the operation. I do not want to add tables and store this metadata for this workflow there. I want to query the workflow. I want the worfklow designer to configure everything in the workflow. Another scenario that would benefit from this would be editable default parameters for an operation.Let's say an operation takes a list of email addresses and we want to define the defaults in the workflow but we need the client to retrieve the default email address list so the user can modify before calling the operation.
    Wednesday, December 5, 2012 5:33 PM
  • Hi,

    You can store the data in a variable, the default value present in xaml file. Then, you can load the xaml file, inspect the workflow tree:

    Serializing Workflows and Activities to and from XAML

    http://msdn.microsoft.com/en-us/library/ff458319.aspx

    Activity Tree Inspection

    http://msdn.microsoft.com/en-us/library/ee358719.aspx


    Leo Tang [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, December 7, 2012 1:41 AM
  • Our solution is to use Workflow Instance Extention to store this information. In this case every activity could easily access it. We host workflows in WAS using AppFabric. When new WorkflowServiceHost is created, we load workflow metadata from database (you could also use .config or any other sources) and register new Workflow Extention, providing this metadata to it. Therefor every workflow of certain type share the same meta information.

    protected override WorkflowServiceHost CreateWorkflowServiceHost(WorkflowService service, Uri[] baseAddresses)
    {
    	WorkflowServiceHost host = base.CreateWorkflowServiceHost(service, baseAddresses);
    
    	//Load additional information about workflow
    	var descriptor = LoadDefinition(service.Name.LocalName);
    
    	//Register workflow extention
    	host.WorkflowExtensions.Add(() => new WorkflowContextExtention(descriptor));
    
    	return host;
    }

    Another idea would be to inject some "system" variable with default value that contains additional metadata. In our case it's not appropriate solution, because we allow editing workflows in workflow Designer by end-users and there is no way to make this variable hidden.

    Regards
    Alex

    • Marked as answer by MarkBosley Thursday, December 13, 2012 4:40 PM
    Friday, December 7, 2012 10:46 AM
  • LeoTang,

    How would I load the workflow instance? In the example for Activity Tree Inspection there is a reference to the workflowInstance. In the case of a WorkflowService(xamlx) the instance is created in another thread. So from a normal WCF service I need to locate(by correlationId) and load a particular instance before I can use the WorkflowInspectionServices to inspect the value. suggestion?

    • Edited by MarkBosley Tuesday, December 11, 2012 12:40 AM
    Monday, December 10, 2012 6:15 PM