IScheduledTaskResults.FindCurrent

Syntax

FindCurrent(Current: DateTime): IScheduledTaskResult;

Parameters

Current is date and time relative to which the search is executed.

Description

The FindCurrent method searches the record in the task execution history. The search of the first record that has date and time of the execution less than the Current value is performed.

Example

Executing the example requires that the repository contains a scheduled tasks container with the TASK_CONTAINTER identifier.

Sub Main;

Var

MB: IMetabase;

Cont: IScheduledTasksContainer;

Tasks: IMetabaseObjectDescriptors;

Task: IScheduledTask;

Results: IScheduledTaskResults;

Result: IScheduledTaskResult;

d: DateTime;

Begin

MB := MetabaseClass.Active;

Cont := MB.ItemById("TASK_CONTAINTER").Bind As IScheduledTasksContainer;

Tasks := Cont.Tasks;

Task := Tasks.Item(0).Bind As IScheduledTask;

Results := Task.GetResults;

d := DateTime.AddDays(DateTime.Now, -7);

Result := Results.FindCurrent(d);

If Result <> Null Then

Debug.WriteLine(Result.StartDateTime.ToString + " " + Result.FinishDateTime.ToString);

If Result.Succeeded Then

Debug.WriteLine("Finished successfully");

Else

Debug.WriteLine("Finished with error");

End If;

End If;

End Sub Main;

After executing the example the record that corresponds to the task launching happened a week ago relative to the current date and time is searched in the history of the first task execution. If the search is successful, the date and time of task execution start and completion are displayed, and the result is also displayed. (Completed successfully/with error).

See also:

IScheduledTaskResults