IScheduledTask.GetResults

Fore Syntax

GetResults: IScheduledTaskResults;

Fore.NET Syntax

GetResults: Prognoz.Platform.Interop.KeFore.IScheduledTaskResults;

Description

The GetResults method returns task history.

Comments

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

Fore 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.

Fore.NET Example

The requirements and result of the Fore.NET Example execution match with those in the Fore Example.

Imports Prognoz.Platform.Interop.KeFore;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    Cont: IScheduledTasksContainer;
    Tasks: IMetabaseObjectDescriptors;
    Task: IScheduledTask;
    Results: IScheduledTaskResults;
    Result: IScheduledTaskResult;
    i: Integer;
Begin
    
// Get current repository
    MB := Params.Metabase;
    
// 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];
        System.Diagnostics.Debug.Write(Result.StartDateTime.ToString() + 
" | ");
        System.Diagnostics.Debug.Write(Result.FinishDateTime.ToString() + 
" | ");
        
If Result.Succeeded Then
            System.Diagnostics.Debug.WriteLine(
"Finished successfully");
        
Else
            System.Diagnostics.Debug.WriteLine(
"Finished with error");
        
End If;
    
End For;
End Sub;

See also:

IScheduledTask