Skip to content

Using a Microsoft Workflow Sample as a Custom Workflow Activity

Note: It is recommended that the Neuron process documentation be reviewed before running this sample. The documentation thoroughly describes each process component individually and describes how to configure each one as well as how to construct a process and associate it with a Neuron Publisher or Subscriber. See the Configuration Notes section at the end of this document for more information.

Overview

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.

Note: Before continuing this sample, install the Windows Workflow (WF) Samples from the download link found on the Windows Workflow Samples page.

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

  1. 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:
  1. Open the xaml file and observe that the flowchart-based workflow contains two In arguments (promoCode, numberOfKids) and an Out argument (discount):
  1. Compile the project.
  2. 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).
Note: If the project has dependent assemblies, copy them to the Workflows folder as well.

Create a new Neuron Configuration

  1. 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.
  2. Click on the Processes section in the left navigation pane.
  1. From the new button dropdown, select Create Workflow
  1. Select Normal Workflow and click the Create Workflow button:
  1. You will see a new tab that contains the workflow designer with the toolbox on the right side.
  2. In the toolbox, find the Sequence activity in the Control Flow group and drag it on to the Workflow designer:
  1. Scroll the toolbox until you find the PromotionalDiscountWorkflow activity:
  1. 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:
  1. 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:
  1. Click the line that says “Create Variable”, enter “theDiscount” as the variable name and then in the Variable type column, select Browse for Types
  1. In the Type Name field, enter “System.Double”, select “Double” and click the OK button:
  1. The variable should now look like the following:
  1. Add a WriteLine activity (Primitives group) after the PromotionalDiscountWorkflow activity but inside the Sequence activity:
  1. 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:
  1. Select the PromotionalDiscountWorkflow activity in the designer and set the properties in the property grid as shown:
  1. Test the workflow by clicking the Test Workflow button . In the Edit Test Message dialog, leave the default values and click the OK button.
  2. The PromotionalDiscountWorkflow and WriteLine activities will write trace messages to the Output window:
Was this article helpful?
Dislike 0
Next: Importing a Microsoft Workflow Sample