Using a Microsoft Workflow Sample as a Custom Workflow Activity
- Neuron ESB
- Samples and Walkthroughs
- Workflow Samples
- Using a Microsoft Workflow Sample as a Custom Workflow Activity
There are many Workflow Foundation (WF) samples available on the Microsoft Developer Network. Since Neuron ESB hosts its own Workflow Foundation runtime, many samples from Microsoft can be used in Neuron ESB with little or no modifications.
Some sample workflows can be used as a single custom activity that appears in the Workflow Toolbox of Neuron Explorer. This has the advantage of encapsulating multiple workflow activities into a single activity that can then be used in the Workflow Designer in Neuron ESB.
This sample uses the FlowChartWithFaultHandling sample as an activity in the Neuron Explorer Workflow Toolbox.
Running the Sample
Open the Sample
Note: This sample does not open a Neuron ESB Configuration or Visual Studio solution. It only opens this documentation page.
To open this sample documentation, see the topic Using the Neuron Samples and select the Custom Workflow Activity from Microsoft Samples sample.
Configure the Sample
- From the location where you installed the Microsoft Workflow sample, open the FlowChartWithFaultHandling sample found at \WF_WCF_Samples\WF\Basic\Built-InActivities\FlowChartWithFaultHandling\DesignerWorkflow\CS. This project consists of the PromotionalDiscountWorkflow.xaml file as well as a Program.cs file that invokes the workflow:
- Open the xaml file and observe that the flowchart-based workflow contains two In arguments (promoCode, numberOfKids) and an Out argument (discount):
- Compile the project.
- Copy the compiled project, FlowChartWithFaultHandling.exe, to the Workflows folder of the Neuron program files installation directory (C:\Program Files\Neudesic\Neuron ESB v3\DEFAULT\Workflows).
Create a new Neuron Configuration
- If Neuron ESB Explorer is already opened, close it and re-open it and create a new Neuron Configuration (for this sample you do not need to configure a topic, publish or subscriber). You will not be able to see the custom workflow activity in the toolbox until you close and re-open the ESB Explorer.
- Click on the Processes section in the left navigation pane.
- From the new button dropdown, select Create Workflow
- Select Normal Workflow and click the Create Workflow button:
- You will see a new tab that contains the workflow designer with the toolbox on the right side.
- In the toolbox, find the Sequence activity in the Control Flow group and drag it on to the Workflow designer:
- Scroll the toolbox until you find the PromotionalDiscountWorkflow activity:
- When you drag the PromotionalDiscountWorkflow activity into the Sequence activity, it will appear on the designer and the In and Out arguments will show in the Property Grid:
- Variables are scoped to an activity. Click the header of the Sequence activity in the designer to make it the active activity then click the Variables tab:
- Click the line that says “Create Variable”, enter “theDiscount” as the variable name and then in the Variable type column, select Browse for Types
- In the Type Name field, enter “System.Double”, select “Double” and click the OK button:
- The variable should now look like the following:
- Add a WriteLine activity (Primitives group) after the PromotionalDiscountWorkflow activity but inside the Sequence activity:
- In the WriteLine activity, enter “theDiscount.ToString()” in the Text property. You can do this directly on the activity in the designer, through the property grid or via a popup window that shows when you click the ellipsis button to the right of the textbox in the property grid:
- Select the PromotionalDiscountWorkflow activity in the designer and set the properties in the property grid as shown:
- Test the workflow by clicking the Test Workflow button . In the Edit Test Message dialog, leave the default values and click the OK button.
- The PromotionalDiscountWorkflow and WriteLine activities will write trace messages to the Output window: