User Script
The userscript task (userscript
) allows users to code custom tasks.
The custom task class must implement the interface HPE.Ianus.Scripting.IScript
. For a detailed description of the match class please refer to User Script .
The user script class can be provided as:
- C# script, meaning that the code is compiled on the fly by Ianus and declared:
- inline, by adding the code in the
script
element value - by reference, providing the filename of the script on the path attribute of the
script
element. If the script file name is not absolute, the script is searched in the same path of the job script.
- inline, by adding the code in the
- Regular assembly, providing the filename of the DLL containing the class on the
assembly
attribute and the full name of the class on theclass
attribute. In this case the class can be coded in any .NET language such as C# or VB.NET but also COBOL. The latter can be very useful to reuse existing logic to handle the record type recognition.
The following attributes configure the task:
Attribute | Type | Purpose |
---|---|---|
path | string | Indicates to load the class script from the specified file |
assembly | string | Indicates to load the class assembly from the specified DLL |
class | string | Indicates the name of the class to use |
plugin | string | Indicates to load the class from the plugin alias defined in the Ianus configuration file |
Example
<?xml version="1.0" encoding="utf-8"?>
<job multithread="false">
<log name ="VAFF" level="error">FAVA</log>
<userscript name="U01">
using HPE.Ianus;
using HPE.Ianus.Scripting;
namespace TestScript
{
public class ScriptFC01 : HPE.Ianus.Scripting.IScript
{
public Task.TaskStatus Run(Task task)
{
task.Log.Error("That's my task ");
foreach (string k in task.ParentJob.Tasks.Keys)
{
task.Log.Info("{0}", k);
}
return Task.TaskStatus.Warnings;
}
}
}
</userscript>
<userscript name="UCC"
class="UserScript.SampleScript01"
assembly="C:\Ianus\Ianus\Samples\UserScript\bin\Debug\UserScript.dll"/>
<userscript name="U03" plugin="MyScript"/>
</job>
Status codes
Status | Status code | Description |
---|---|---|
Ready | -1 | Task is initialized, but not yet started |
Running | -2 | Task is running |
Success | 0 | Task completed successfully |
Warnings | 1 | Task completed with warnings |
Errors | 2 | Task completed with errors |
Aborted | 9 | Task cannot be executed |