Integrating Scripts into Workflows

Caution
Test the script(s), processes and/or data file(s) thoroughly in a test environment, and customize them to meet the requirements of your organization before attempting to use it in a production capacity.  (See the legal notice here)

 

Note: The workflow sample mentioned in this article can be downloaded from the Opalis project on CodePlex:  http://opalis.codeplex.com

 

Overview

Examples that demonstrate the use of the Run .Net Script Activity which enables the integration of .NET scripting and code to be integrated into Workflows

 

Getting Started

These examples require the .NET Framework and PowerShell.

1. PowerShell: Count Files

This Workflow uses PowerShell to count the number of files in a given folder. The Custom Start Activity is used to obtain a folder name using a parameter:

The Run .Net Script Activity 'Count Files in Folder' runs a PowerShell script that subscribes to the Published Data 'Folder' from the Custom Start Activity:

The value of variable '$numFiles' is made available as Published Data 'Number of Files' on the Opalis Databus:

The Send Platform Activity subscribes to the Published Data 'Number of Files' from the Run .Net Script Activity to display the resulting output:

Running the example Workflow

Launch the Workflow '1. PowerShell: Count Files' by starting it from the Operator Console or by running it using the Testing Console. When prompted, enter a valid folder name (without trailing '\'):

Check the Operator Console Event screen or the Workflow Testing Console log to see the resulting output.

2. C#: UNIX Time

This Workflow uses the Run .Net Script Activity 'Calculate UNIX Time' to run two lines of C# code that calculate a UNIX Time Stamp (based on seconds since the standard epoch of 1/1/1970):

The appropriate .NET Namespaces and Assembly are referenced in the 'Advanced' tab:

The value of variable 'output' is made available as Published Data 'Unix Time' on the Opalis Databus:

The Send Platform Activity subscribes to the Published Data 'Unix Time' from the Run .Net Script Activity to display the resulting output:

Running the example Workflow

Launch the Workflow by using Start, or by running it using the Workflow Testing Console. Check the Opalis Designer Events tab or the Testing Console log to see the resulting output.

More Information

Refer to the Run .NET Script Online Help for more information.

Share this post :