• User's guide
  • API
Search Results for

    Show / Hide Table of Contents
    • Concepts
    • Installation
    • Configuration
      • Overview
      • License
      • Datasources
      • Configuration
      • Plug-Ins
      • Codepages
      • Environment Variables
      • Include files
      • Example
    • Jobs
      • Jobs
      • Include
      • Multi-Threaded Jobs
      • Tracking Jobs
    • Tasks
      • Overview
      • Copy Check
      • Excel
      • File Compare
      • File Copy
      • File Dump
      • File Edit
      • File Format
      • Foreach
      • Generate
      • IMS/DB Data Conversion
      • JCL Submit
      • Listcat
      • Log
      • Powershell
      • Set Environment Variable
      • Sql
      • Stored Procedure Compare
      • Table Compare
      • Table Copy
      • Table Load
      • Table Scan
      • Table Unload
      • User Script
    • Layouts
      • Overview
      • XML Definition
      • COBOL Definition
      • Field data Types
    • Extensibility
      • Extending Ianus
      • Column Comparators
      • Column Converters
      • Record Comparators
      • File Editors
      • User Script
      • Record Layout Match Class
      • Column Layout Match Class
      • User Fields
      • Codepages
      • Resources
    • Usage
      • Command Line
      • Monitors
      • Programmatically
      • Unit Testing
    • Known Issues
    • Disclaimers

    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.
    • Regular assembly, providing the filename of the DLL containing the class on the assembly attribute and the full name of the class on the class 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
    In This Article
    Back to top Copyright 2021 - Hewlett-Packard Enterprise