State: ScheduledTaskState;
State: Prognoz.Platform.Interop.KeFore.ScheduledTaskState;
The State property returns task state at the current moment.
To get task execution history, use the IScheduledTask.GetResults property.
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;
i: integer;
Task: IScheduledTask;
Begin
// Get current repository
MB := MetabaseClass.Active;
// Get a container of scheduled tasks
Cont := MB.ItemById("SCHEDULEDTASKSCONTAINER").Bind As IScheduledTasksContainer;
// Display state of all tasks
Tasks := Cont.Tasks;
For i := 0 To Tasks.Count - 1 Do
Task := Tasks.Item(i).Bind As IScheduledTask;
Debug.Write("Task: " + (Task As IMetabaseObjectDescriptor).Name + " State: ");
Select Case (Task.State As Integer)
Case 0: Debug.WriteLine("Inactive");
Case 1: Debug.WriteLine("Ready");
Case 2: Debug.WriteLine("Is Progress");
Case 3: Debug.WriteLine("Finished");
Case 4: Debug.WriteLine("Error");
End Select;
End For;
End Sub UserProc;
After executing the example tasks list and state of each task are displayed in the development environment console.
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;
i: integer;
Task: IScheduledTask;
Begin
// Get current repository
MB := Params.Metabase;
// Get a container of scheduled tasks
Cont := MB.ItemById["SCHEDULEDTASKSCONTAINER"].Bind() As IScheduledTasksContainer;
// Display state of all tasks
Tasks := Cont.Tasks;
For i := 0 To Tasks.Count - 1 Do
Task := Tasks.Item[i].Bind() As IScheduledTask;
System.Diagnostics.Debug.Write("Task: " + (Task As IMetabaseObjectDescriptor).Name + " State: ");
Select Case (Task.State As Integer)
Case 0: System.Diagnostics.Debug.WriteLine("Inactive");
Case 1: System.Diagnostics.Debug.WriteLine("Ready");
Case 2: System.Diagnostics.Debug.WriteLine("In Progress");
Case 3: System.Diagnostics.Debug.WriteLine("Finished");
Case 4: System.Diagnostics.Debug.WriteLine("Error");
End Select;
End For;
End Sub;
See also: