ICalculateModelScheduledTask.SourceProblem

Fore Syntax

SourceProblem: IMsProblem;

Fore.NET Syntax

SourceProblem: Prognoz.Platform.Interop.Ms.MsProblem;

Description

The SourceProblem property determines the modeling problem, which is calculated by the task in the scheduled tasks container.

Comments

One task in the scheduled tasks container can calculate only one modeling problem. To calculate several modeling problems, use several tasks in the scheduled tasks container.

Fore Example

Executing the example requires that the repository contains:

  1. A scheduled tasks container with the SCHEDULEDTASKSCONTAINER identifier.

  2. A modeling container with the MS identifier containing a modeling problem with the PROBLEM_ADV identifier.

Add links to the Fore, Metabase, Ms system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    CrInf: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    Exe: ICalculateModelScheduledTask;
    Per: IScheduledTaskPeriodDaily;
    Prop: IScheduledTaskProperties;
Begin
    
// Get current repository
    mb := MetabaseClass.Active;
    
// Create task in the scheduled tasks container
    CrInf := mb.CreateCreateInfo;
    CrInf.ClassId := MetabaseObjectClass.KE_CLASS_TASK_CALCULATEMODEL;
    CrInf.Id := mb.GenerateId(
"MODELLING_TASK", mb.GetObjectKeyById("SCHEDULEDTASKSCONTAINER"));
    CrInf.Name := 
"Modeling problem calculation";
    CrInf.Parent := mb.ItemById(
"SCHEDULEDTASKSCONTAINER");
    MObj := mb.CreateObject(CrInf).Edit;
    
// Determine that task will calculate modeling problem
    Exe := MObj As ICalculateModelScheduledTask;
    
// Determine modeling problem being calculated
    Exe.SourceProblem := mb.ItemByIdNamespace("PROBLEM_ADV", mb.ItemById("MS").Key).Bind As IMsProblem;
    
// Determine problem calculation frequency
    Prop := Exe.Properties;
    Per := Prop.CreatePeriod(ScheduledTaskPeriodType.Daily) 
As IScheduledTaskPeriodDaily;
    Per.StartDateTime := DateTime.Now;
    Prop.Period := Per;
    
// Save changes
    MObj.Save;
End Sub UserProc

After executing the example a task calculating modeling problem will be created in the scheduled tasks container.

Fore Example

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

Imports Prognoz.Platform.Interop.KeFore;
Imports Prognoz.Platform.Interop.Ms;


Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    CrInf: IMetabaseObjectCreateInfo;
    MObj: IMetabaseObject;
    Exe: ICalculateModelScheduledTask;
    Per: IScheduledTaskPeriodDaily;
    Prop: IScheduledTaskProperties;
Begin
    
// Get current repository
    mb := Params.Metabase;
    
// Create task in the scheduled tasks container
    CrInf := mb.CreateCreateInfo();
    CrInf.ClassId := MetabaseObjectClass.KE_CLASS_TASK_CALCULATEMODEL 
As integer;
    CrInf.Id := mb.GenerateId(
"MODELLING_TASK", mb.GetObjectKeyById("SCHEDULEDTASKSCONTAINER"));
    CrInf.Name := 
"Modeling problem calculation";
    CrInf.Parent := mb.ItemById[
"SCHEDULEDTASKSCONTAINER"];
    MObj := mb.CreateObject(CrInf).Edit();
    
// Determine that task will calculate modeling problem
    Exe := MObj As ICalculateModelScheduledTask;
    
// Determine modeling problem being calculated
    Exe.SourceProblem := mb.ItemByIdNamespace["PROBLEM_ADV", mb.ItemById["MS"].Key].Bind() As MsProblem;
    
// Determine problem calculation frequency
    Prop := Exe.Properties;
    Per := Prop.CreatePeriod(ScheduledTaskPeriodType.stptDaily) 
As IScheduledTaskPeriodDaily;
    Per.StartDateTime := DateTime.Now;
    Prop.Period := Per;
    
// Save changes
    MObj.Save();
End Sub;

See also:

ICalculateModelScheduledTask