Run .Net Script

Applies To: Opalis 6.3

The Run .Net Script object can run scripts written in VB.Net, JScript, C#, and Windows PowerShell. The Run .Net Script object is compatible with .Net CLR version 2.0 and later.

Use the Run .Net Script object to run scripts that parse data or run functions against available APIs.

Configuring the Run .Net Script Object

To configure the Run .Net Script object you need to know the code you want to run, the libraries that you will be using and the data that you will want to publish.

To configure the Run .Net Script object

  1. From the Objects pane, drag a Run .Net Script object to the active Policy.

  2. Double-click the Run Program object icon. The Properties dialog opens.

  3. For information about the settings on the Details tab and the Advanced tab, see the following tables.

  4. For information about the settings on the Published Data tab see Configuring Run .Net Script Published Data.

  5. For information about the settings on the General tab, the Run Behavior tab, and other tabs if applicable, see Common Tabs.

Details Tab

Element Configuration Instructions

Type

Select the language that you will use for your script, use the ellipsis (...) button to browse for the language.

Script

Type the code that will be executed when the object runs.

Advanced Tab

Element Configuration Instructions

Namespace

Add a Namespace for each .Net namespace that will be used within your code. This will allow you to call the code without using fully-qualified names for each of the classes. Opalis recommends adding System namespace to every Run .Net Script object.

References

Add each of the Assembly (DLL) references that contain the libraries that you want to use. Add the System.dll located in the Windows\Microsoft.Net\Framework\<.Net Version> directory.

Configuring Run .Net Script Published Data

Add each of the Published Data elements that you want this object to publish. Every published data item that you add will be available on the Data bus. It is important to determine if a Published Data item will be multi-valued. The Run .Net Script object automatically correlates multi-valued data from different items by aligning them. For example, if you choose to publish two items labeled “Name” and “Email” as Collections, the Run .Net script will try to line up each item in the Name collection with each item in the Email collection. If the collections are not equally sized, then the Run .Net Script object will create blank values for the collection that has fewer items.

To configure published data

  1. Click the Published Data tab. Click Add. The Published Data dialog appears.

  2. Type the Name of the published data. This will be the element name that appears when other objects subscribe to the data published by the Run .Net Script object.

  3. Select the Type of the data. If the type you want is not available, select String. Use the ToString method of the object to assign a value to this published data.

  4. If this data will be multi-valued, select Collection. When using a collection you must use the Add method to add items to the collection. If you are not using the collection you can use the assignment operator (=) to assign the value.

  5. Type the Variable name that you will use in your script to assign a value to this item. The Run .Net Script object will automatically create a .Net Property for this item. If this variable is a collection it will be created using a List<T>, where T is the Type that you selected. If it is not a collection the property will be created using a String, Int, or DateTime based on the Type that you selected. Use unique naming to make sure that your variable name does not collide with existing variables within your script or with classes and keywords available in .Net. We recommend prefixing variables with “OPD_”. For example, if you want to name your variable “myString”, you would name it “OPD_myString”.

The following table lists the element names and descriptions of the data published by this object. For information about the published data elements that are common to all objects, see Policy Workflow Rules.

Run .Net Script Published Data

Element Name Description

Standard Error

Any stderr output returned by the Run .Net Script object.

Namespaces

The namespaces used.

Standard Output

The stdout returned by the Run .Net Script object.

References

The Assemblies used in the object.

Script Body

The script that was run.

Script Language

The language that was selected for the script.