IScheduledTaskPeriodMonthly.Months

Syntax

Months(Index: CalendarMonth): Boolean;

Parameters

Index. A month for which it is necessary to determine whether the calculation took place.

Description

The Months property determines whether the calculation should be performed in the month, index of which is determined by the Index property. If the property is set to True, the calculation is performed.

Example

Executing the example requires that the repository contains a scheduled tasks container with the TASK_CONTAINTER identifier and a unit with the Module_1 identifier. The unit contains the Main procedure.

Sub UserProc;
Var
    MB: IMetabase;
    CrInfo: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    Exe: IExecuteSubScheduledTask;
    Per: IScheduledTaskPeriodMonthly;
    Prop: IScheduledTaskProperties;
    i: Integer;
Begin
    MB := MetabaseClass.Active;
    CrInfo := MB.CreateCreateInfo;
    CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_TASK_EXECUTESUB;
    CrInfo.Id := "MODULE_EXECUTOR";
    CrInfo.Name := "Unit execution";
    CrInfo.Parent := MB.ItemById("TASK_CONTAINTER");
    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;
    Per := Prop.CreatePeriod(ScheduledTaskPeriodType.Monthly) As IScheduledTaskPeriodMonthly;
    Per.DayOfWeek := CalendarDayOfWeek.Monday;
    Per.WeekOfMonth := CalendarWeekOfMonth.Third;
    For i := 1 To 12 Do
        Per.Months(i As CalendarMonth) := True;
    End For;
    Per.StartTime := DateTime.ComposeTimeOfDay(12000);
    Prop.Period := Per;
    MObj.Save;
End Sub UserProc;

After executing the example a new task of unit execution is created in the scheduled tasks container. The unit will be running every third Monday of the month at 12:00.

See also:

IScheduledTaskPeriodMonthly