There are some great samples on how to develop custom process steps, but not really a guide. And since it is actually quite easy and is something that you often might do, I created this little guide.
Icons
First off, the most important thing of course is to find a decent icon ;-). If you would like a Neuronish icon, grap the icon collection from FAMFAMFAM. Several might look familiar..
http://www.famfamfam.com/lab/icons/silk/
Visual Studio Solution
Create a new .Net 4.0/4.5 Class Library and add the following references:
- Neuron
- Neuron.Esb
- Neuron.Esb.XmlSerializers
- Neuron.Pipelines
- Neuron.Pipelines.Design
- Neuron.Scripting
- Neuron.UI
- System.Servicemodel
Create a new resource with the 16×16 icon (in this case I have chosen to add it to Graphics\IconResource.resx).
I prefer to have all the relevant code contained in one file and you can use the following as a template:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
using System; using System.Collections.Generic; using System.ComponentModel; using System.Runtime.Serialization; using System.Windows.Forms; using Neuron.Esb; using Neuron.Esb.Pipelines; using Neuron.Pipelines; using Neuron.Pipelines.Design; namespace Integrator.CustomNeuronSteps { public class LoggingCustomStep { public class ProcessStepUISettings { /// <summary> /// Used by both the Process Step class and the UI element class to control the custom name of the Process step that appears in the Process Designer /// </summary> public const string StepName = "Write to custom log"; public static System.Drawing.Bitmap StepBitMap { get { return Graphics.IconResource.database_go; } } public const string Description = "Log the current message to our custom log"; } #region " UI related " /// <summary> /// This is the UI Element class that determines how the custom Process step will be represented in both the property grid and Process Designer. /// Except for the Process Step type (class) name and properties within the Wrapper class, nothing else needs to be changed in the UI Element class. /// </summary> public class ProcessStepUIElement : StepUIElement<ProcessStepImplementation> { public ProcessStepUIElement(Pipeline<ESBMessage> pipeline) : base(pipeline, ProcessStepUISettings.StepBitMap) { } protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); DrawLabel(e.Graphics, TypedData.Name); } public override string Label { get { return ProcessStepUISettings.StepName; } } public override object BindTo { get { return new Wrapper(this.TypedData); } } /// <summary> /// This is the wrapper class around the main custom Process Step class. It exposes the properties bound to the property grid /// These properties should map back to the ones in the custom Process Step class. This is where the Properties Type Converter can be used /// to control things like ordering of properties, as well making properties dynamically visible/invisible at design time based on /// input of user /// </summary> [fusion_builder_container hundred_percent="yes" overflow="visible"][fusion_builder_row][fusion_builder_column type="1_1" background_position="left top" background_color="" border_size="" border_color="" border_style="solid" spacing="yes" background_image="" background_repeat="no-repeat" padding="" margin_top="0px" margin_bottom="0px" class="" id="" animation_type="" animation_speed="0.3" animation_direction="left" hide_on_mobile="no" center_content="no" min_height="none"][TypeConverter(typeof(PropertiesTypeConverter))] private class Wrapper : BaseWrapper { private readonly ProcessStepImplementation step; public Wrapper(ProcessStepImplementation step) : base(step) { this.step = step; } //[PropertyOrder(0)] //[DisplayName("Description")] //[Description(ProcessStepUISettings.Description)] //public string Description { // get { // return this.step.Description; // } // set { // this.step.Description = value; // } //} //public void DynamicShowMeAttributesProvider(PropertyAttributes attributes) { // attributes.IsBrowsable = (IsEnabled == true); //} //[Category("Default")] //[DisplayName("Message")] //[PropertyOrder(2)] //[Description("Test Desc.")] //public string CustomMessage { // get { return this.step.CustomMessage; } // set { this.step.CustomMessage = value; } //} //[Category("Default")] //[DisplayName("ShowMe")] //[PropertyOrder(0)] //[Description("Show be visible only when IsEnabled is set to true.")] //[PropertyAttributesProvider("DynamicShowMeAttributesProvider")] //public string ShowMe { // get { return this.step.ShowMe; } // set { this.step.ShowMe = value; } //} } } #endregion #region " Implementation " /// <summary> /// The Display name is the name listed under the "Process Steps" UI panel to the right of the Process Designer of the Neuron ESB Explorer /// The Description is the mouse over text that pops up when the process step is selected in the "Process Steps" UI panel /// The icon that is displayed to represent the process step in the "Process Steps" UI is determined in the constructor of the UI Element class that uses the PNG image /// located in the Resources directory. /// /// ***If the same image is to be used for displaying the custom Process Step in the main designer (i.e. dragging it onto a Process), then ensure the image name in the Resource Folder is in the /// form of 'namespace'.'class'.png, and then copy that image to the Neuron Pipelines directory along with the custom process step assembly. /// Ensure that the custom process step is registered within the pipelines.config file located in the Neuron Pipelines directory /// </summary> [DataContract] [Description(ProcessStepUISettings.Description)] [DisplayName(ProcessStepUISettings.StepName)] [StepUIElement(typeof(ProcessStepUIElement))] public class ProcessStepImplementation : CustomPipelineStep { /// <summary> /// If these properties are required for design time configuration then they must be replicated in the Wrapper class of the UI Element class /// </summary> //[DataMember] //public string Description { get; set; } //[DataMember] //public string CustomMessage { get; set; } //[DataMember] //public bool IsEnabled { get; set; } //[DataMember] //public string ShowMe { get; set; } /// <summary> /// This is where the magic should happen....all code to manipulate change or process the incoming ESB Message /// </summary> /// <param name="context"></param> protected override void OnExecute(PipelineContext<ESBMessage> context) { // Do magic } } #endregion } } |
This is basically a slightly modified version of one of the samples and I have maintained many of the original comments from the Neuron ESB Sample and hope it is explanatory enough.
I have used more generic names and basically you should only need to change the name, description and icon in ProcessStepUISettings and perform the actual implementation in the OnExecute-method in ProcessStepImplementation. I suggest keeping multiple custom steps in the same assembly. This will make deployment setup etc. easier.
If you need to be able to set some properties from within the Neuron Explorer, these need to be added to both the ProcessImplementation and the wrapper class. I have included the implementation from the sample as comments, so should be pretty straight forward.
Deployment
Copy the DLL to the Pipelines folder of the Neuron installation (eg. C:\Program Files\Neudesic\Neuron ESB v3\DEFAULT\Pipelines) and modify the NeruonPipeline.config to add the DLL:
1 2 3 4 5 |
<neuron.pipelines> <stepTypes> <add name="CustomNeuronSteps" value="Integrator.CustomNeuronSteps, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8a16c08e95af7635"/> </stepTypes> </neuron.pipelines> |
Of course this can easily be automated and as part of our automated Neuron Powershell deployment, we build and copy the DLL to the Pipeline-folder.
The next time you open Neuron ESB Explorer you will see your custom steps listed on top. It will not be grouped together with the builtin steps and the custom icon is only used when you add the step to a process.
There you go. Let me know if you have any questions.[/fusion_builder_column][/fusion_builder_row][/fusion_builder_container]