SourceProblem: IMsProblem;
The SourceProblem property determines the modeling problem, which is calculated by the task in the scheduled tasks container.
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.
Executing the example requires that the repository contains:
A scheduled tasks container with the SCHEDULEDTASKSCONTAINER identifier.
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 the current repository
mb := MetabaseClass.Active;
// Create a problem in 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;
// Specify that problem will calculate modeling problem
Exe := MObj As ICalculateModelScheduledTask;
// Specify calculated modeling problem
Exe.SourceProblem := mb.ItemByIdNamespace("PROBLEM_ADV", mb.ItemById("MS").Key).Bind As IMsProblem;
// Set 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.
See also: