IScheduledTask.GetResults

Syntax

GetResults: IScheduledTaskResults;

Description

The GetResults method returns task history.

Comments

To reset task execution history, use the IScheduledTask.ResetResults method.

Example

Executing the example requires that the repository has a scheduled tasks container with the SCHEDULEDTASKSCONTAINER identifier.

Add links to the Fore, Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Cont: IScheduledTasksContainer;
    Tasks: IMetabaseObjectDescriptors;
    Task: IScheduledTask;
    Results: IScheduledTaskResults;
    Result: IScheduledTaskResult;
    i: Integer;
Begin
    
// Get current repository
    MB := MetabaseClass.Active;
    
// Get a container of scheduled tasks
    Cont := MB.ItemById("SCHEDULEDTASKSCONTAINER").Bind As IScheduledTasksContainer;
    
// Get the first task
    Tasks := Cont.Tasks;
    Task := Tasks.Item(
0).Bind As IScheduledTask;
    
// Get task execution history
    Results := Task.GetResults;
    
// Display history to the console window
    For i := 0 To Results.Count - 1 Do
        Result := Results.Item(i);
        Debug.Write(Result.StartDateTime.ToString + 
" | ");
        Debug.Write(Result.FinishDateTime.ToString + 
" | ");
        
If Result.Succeeded Then
            Debug.WriteLine(
"Finished successfully");
        
Else
            Debug.WriteLine(
"Finished with error");
        
End If;
    
End For;
End Sub UserProc;

After executing the example the history of the executing of first task in the scheduled tasks container is displayed in the development environment console. Date and time of the start and completion of task execution and also the result of execution - successfully or with error - are displayed.

See also:

IScheduledTask