Consider an example of creating a task that executes the unit.
Executing the example requires that the repository contains a scheduled tasks container with the NewSTCont identifier and a unit with the Module_1 identifier. The unit contains the Main procedure.
Sub Main;
Var
MB: IMetabase;
CrInfo: IMetabaseObjectCreateInfo;
MObj: IMetabaseObject;
Exe: IExecuteSubScheduledTask;
Period: IScheduledTaskPeriodWeekly;
Prop: IScheduledTaskProperties;
Begin
MB := MetabaseClass.Active;
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_TASK_EXECUTESUB;
CrInfo.Id := "Task_module_execute";
CrInfo.Name := "Unit execution";
CrInfo.Parent := MB.ItemById("NewSTCont");
MObj := MB.CreateObject(CrInfo).Edit;
Exe := MObj As IExecuteSubScheduledTask;
Exe.Assembly := (MB.ItemById("Module_1").Bind As IModule).Assembly;
Exe.SubName := "Main";
Prop := Exe.Properties;
Period := Prop.CreatePeriod(ScheduledTaskPeriodType.Weekly) As IScheduledTaskPeriodWeekly;
Period.DaysOfWeek(CalendarDayOfWeek.Monday) := True;
Period.DaysOfWeek(CalendarDayOfWeek.Wednesday) := True;
Period.DaysOfWeek(CalendarDayOfWeek.Friday) := True;
Period.StartTime := DateTime.ComposeTimeOfDay(12, 0, 0, 0);
Prop.Period := Period;
MObj.Save;
End Sub Main;
After executing the example a new task of unit execution is created in the scheduled tasks container. The unit will be running on Mondays, Wednesdays and Fridays at 12:00.
For details on work with different tasks refer to description of the following interfaces:
ICalculateCubeScheduledTask is a task of the calculation of the calculated cube.
ICalculateReportScheduledTask is a task of the calculation of the regular report.
IExecuteSubScheduledTask is a task of unit execution.
IExecuteForeNetMethodScheduledTask is a task of the Fore.NET assembly execution.
IExecuteEtlScheduledTask is a task of the Etl task execution.
ICalculateModelScheduledTask is a task of the modeling task calculation.
See also: