IExecuteForeNetMethodScheduledTask.MethodName

Syntax

MethodName: String;

Description

The MethodName property determines the name of the .NET method, that needs to be executed at the task start.

Comments

As the value of this property, it is possible to specify the qualified identifier of any class, declared with the Public and Shared modifiers. .NET method may have parameters. Parameters may be of one of the following types:

Only the first parameter of the method may have the IMetabase type, the FirstParamIsMetabase in the task must be set to True.

If the specified .NET method has the parameters, the type of which differs from IMetabase, it is necessary to create the same number of parameters in the collection Params of object corresponding to the task. Types of parameters must correspond to those of .NET method. Values of parameters may be specified in the ParamValues property.

Example

Executing this example requires a scheduled tasks container with the TASK_CONTAINTER identifier and the Fore.NET NETSCHEDULE assembly in repository. The assembly contains a unit or form with description of the MyClass class. The Run procedure described in this class has the three parameters:

Sub UserProc;
Var
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    ForeNetExe: IExecuteForeNetMethodScheduledTask;
    Per: IScheduledTaskPeriodOneTimeOnly;
    Prop: IScheduledTaskProperties;
    Params: IMetabaseObjectParams;
    Param: IMetabaseObjectParam;
    ParamValues: IMetabaseObjectParamValues;
Begin
    MB := MetabaseClass.Active;
        CrInfo := MB.CreateCreateInfo;
        CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_TASK_EXECUTENETMETHOD;
        CrInfo.Id := "NETSCHEDULE";
        CrInfo.Name := "Execution of assembly Fore.NET";
        CrInfo.Parent := MB.ItemById("TASK_CONTAINTER");
    MObj := MB.CreateObject(CrInfo).Edit;
    //Parameters for .NET method through which values are passed
    Params := MObj.Params;
    Param := Params.Add;
    Param.Id := "IterationCount"; Param.Name := "Number of iterations";
    Param.DataType := DbDataType.Integer;
    Param := Params.Add;
    Param.Id := "Error"; Param.Name := "Error";
    Param.DataType := DbDataType.Float;
    //Started .NET method
    ForeNetExe := MObj As IExecuteForeNetMethodScheduledTask;
    ForeNetExe.Assembly := MB.ItemById("NETSCHEDULE").Bind As IForeNETAssembly;
    ForeNetExe.TypeName := "NETSCHEDULE.MyClass";
    ForeNetExe.MethodName := "Run";
    ForeNetExe.FirstParamIsMetabase := True;
    //Task execution parameters
    Prop := ForeNetExe.Properties;
    Per := Prop.CreatePeriod(ScheduledTaskPeriodType.OneTimeOnly) As IScheduledTaskPeriodOneTimeOnly;
    Per.StartMode := TaskPeriodOneTimeStartMode.OnLogon;
    Prop.Period := Per;
    //Parameters' values for .NET method
    ParamValues := Prop.ParamValues;
    ParamValues.FindById("IterationCount").Value := 10000;
    ParamValues.FindById("Error").Value := 0.0000001;
    Prop.ParamValues := ParamValues;
    MObj.Save;
End Sub UserProc;

After executing this example, in the container of scheduled tasks the new task of Fore.NET assembly execution is created. The assembly is run once on connecting to the repository. On running the assembly the Run method is executed, the specified parameters values are passed into it.

See also:

IExecuteForeNetMethodScheduledTask