.NET Script Heater, dynamic .NET Script Code
With the .NET Script Heater you can equip your FlowHeater Definition with your own .NET coding in C# or VB.NET. In principle, all the .NET functions provided by the .NET Framework 4.5 are available. This means there is now unlimited scope for building dynamic transformations.
Anything that you have so far not been able to achieve with the supplied functions, you can easily program in DOTNET yourself with the help of the .NET Script Heater. Both DOTNET programming languages C# (CSharp) and VB.NET (Visual Basic) are supported.
Note: Extremely extensive scripts can be employed. Even complex classes and own .NET DLLs can be included!
Run at: The options available are as follows.
Start: The script is run once, when starting the processing step in which the Heater is present. If this option is selected, no values can be passed to the Heater, and the Heater has no output.
Standard: The script is called once each record, provided the output value is retrieved.
Per row/record: The script is called each row/record, regardless of whether the output value is retrieved.
End: The script is run once, at the end of the processing step in which the Heater is present. If this option is selected, no values can be passed to the Heater, and the Heater has no output.
Language: Select the desired programming language. C# (C-sharp) and VB.NET (Visual Basic) are available.
Check syntax: With this button you can check the script entered for possible errors.
Description: Enter some descriptive text here. This will be displayed as a ToolTip in the Designer when you hover the mouse over the .NET Script Heater.
Abort processing if an error occurs: When this option is checked all processing is terminated if an error occurs in the script at runtime. Note: You should only deactivate this option for test purposes or when troubleshooting!
Using / Import: Enter any Using (C#) or Import (VB.NET) statements here that are required by the script.
DLLs: Enter all DLLs that need to be loaded before running the script. If you want to use your own DLLs, they must either be available in the Global Assembly Cache (GAC) or you have to specify the DLLs with a complete path. e.g. “C:\DEV\myown.dll”. All DotNet DLLs from .NET Framework versions 2.0 to 4.5 are supported.
Initials: Two characters that are displayed to distinguish the particular “Custom Script” Heater on the Designer workspace.
Display name: The name of the “Custom Script” Heater that is displayed in the selection area.
Save as: This button opens a “save file” popup window, allowing you to store the user script for later use. The library path mentioned above is predefined as the default path. Here you can group your user scripts into subfolders (only one level). The folder name is taken as the group name. To ensure that the same scripts are always used on different computers or in a team, the library path also supports UNC paths and network drives.
Amend script in library: An existing “Custom Script” Heater is opened, allowing you to make changes to the script and to save these changes to update the underlying script. Note: Only the underlying script is changed. Other Heaters that have already used an older script version remain unaffected!
Access to parameters and data type conversion
The .NET Script Heater makes use of the same mechanisms as FlowHeater itself. Incoming data types are automatically converted into the necessary data types according to the format settings on the WRITE Adapter. In order to make use of these, five functions are available.
Note: x = 0 is the first parameter
Warning: In all functions, if the return value is NULL then the contents could not be converted.
The heater parameters can be accessed using the InValues array with the methods listed above. The sequence of parameters is the same as defined in Designer.
The result of your own transformation function is delivered as a return value for further processing by FlowHeater. The following .NET data types can be returned at present.
- A complex If-Then-Elseif…Else example. The .NET Script Heater is also introduced here, as an alternative and much more elegant way of achieving the same thing
- For data that is filtered by the Filter Heater, the filtered records are written to a separate file for further processing by the .NET Script Heater.
- Advanced Excel CSV data export. Here data grouping with the help of the .NET Script Heater is carried out.
or inspect the following short C# (C-sharp) Script code extracts for a brief introduction
Simple counter, returning 1, 2, 3, and so on… according to the number of records processed.
Extended counter including invocation of an additional function. Returning this time 2, 4, 6, and so on... according to the number of records processed.
A somewhat more complex calculation using an additional class, which processes the first heater parameter.