C# activity

Use the C# Script activities to write .Net scripts.

The TotalAgility Designer allows you to create two types of .Net Script activities: C# and VB.Net.

When configuring a script, right-click on the rule editor and select the process and server variables to add to the script.

TotalAgility can validate and run a script without requiring the script developer to build and deploy .Net assemblies. The .Net compliance of TotalAgility reduces development time and increases the ease of deployment.

  • The C# script activity is compiled compilation at design time. It needs the full path to any referenced DLL, as it is being used as a reference for .NET compiler.

  • At runtime, the C# script activity uses .NET loading rules to find the referenced assembly once the C# script assembly is compiled; it does not use the file path.

When the compiled C# script assembly executes and looks for referenced DLLs, it checks the GAC first and then current directory such as .NET framework 64 folder.

You must either use full path such as C:\lib\helper.dll or place the DLL into the .NET framework 64 folder.

Example of C# script

In this sample C# script, firstname and surname are input variables. The value of these variables is used to construct the value of the fullname variable, which is an output variable.

using System; 
using Agility.Server.Scripting.ScriptAssembly;
 namespace MyNamespace
{
     public class Class1
 {
  public Class1() 
  {
  }
   [StartMethodAttribute()] 
  public void Method1(ScriptParameters sp) 
  {
	string firstname = {string}sp.InputVariables["FirstName((Process variable)"].ToString();
	string surname = {string}sp.InputVariables["surname(Process variable)"].ToString();
	sp.OutputVariables"[fullname]" = firstName + " " + surname ;
   }
 }
}

The script only works if firstname and surname are set as input variables, and fullname is set as an output variable.

How to: Configure a C# activity