Assign(Preiod: IMsDatePeriod);
Assign(Preiod: Prognoz.Platform.Interop.Ms.MsDatePeriod);
Preiod. Copied period.
The Assign method copies parameters of the specified period to the current period.
This method enables the entire copy of period parameters including internal properties.
Executing the example requires that the repository contains a modeling container with the MS identifier containing a forecasting problem with the PROBLEM_COPIED identifier.
Add links to the Metabase, Ms system assemblies.
Sub UserProc;
Var
mb: IMetabase;
MsKey: Integer;
CrInfo: IMetabaseObjectCreateInfo;
ProblemCopied, ProblemCopy: IMsProblem;
i: Integer;
CalcSettCopied, CalcSettCopy: IMsProblemCalculationSettings;
PeriodCopied, PeriodCopy: IMsModelPeriod;
OutputPeriodCopied, OutputPeriodCopy: IMsDatePeriod;
ProblemCalc: IMsProblemCalculation;
Begin
mb := metabaseClass.Active;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get copied problem
ProblemCopied := mb.ItemByIdNamespace("PROBLEM_COPIED", MsKey).Edit As IMsProblem;
// Create object for a copy problem
CrInfo := MB.CreateCreateInfo;
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_MSPROBLEM;
CrInfo.Id := MB.GenerateId("PROBLEM_COPY", MsKey);
CrInfo.Name := "Modeling problem (copy)";
CrInfo.Parent := ProblemCopied.MetabaseObject.Parent;
ProblemCopy := MB.CreateObject(CrInfo).Edit As IMsProblem;
// Copy metamodel
ProblemCopy.MetaModel := ProblemCopied.MetaModel;
// Copy problem parameters
ProblemCopy.Details := ProblemCopied.Details;
// Copy scenario
For i := 0 To ProblemCopied.Scenarios.Count - 1 Do
ProblemCopy.Scenarios.AddScenario(ProblemCopied.Scenarios.Item(i));
End For;
// Copy data loading period parameters
CalcSettCopied := ProblemCopied.CreateCalculationSettings;
OutputPeriodCopied := CalcSettCopied.OutputPeriod As IMsDatePeriod;
CalcSettCopy := ProblemCopy.CreateCalculationSettings;
OutputPeriodCopy := CalcSettCopy.OutputPeriod As IMsDatePeriod;
OutputPeriodCopy.Assign(OutputPeriodCopied);
// Copy problem calculation periods
PeriodCopied := CalcSettCopied.Period;
PeriodCopy := CalcSettCopy.Period;
PeriodCopy.Assign(PeriodCopied);
// Save copy
(ProblemCopy As IMetabaseObject).Save;
// Calculate copy problem
ProblemCalc := ProblemCopy.Calculate(CalcSettCopy);
ProblemCalc.Run;
End Sub UserProc;
After executing the example the PROBLEM_COPIED problem is copied. The created copy will be calculated.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Ms;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
MsKey: uinteger;
CrInfo: IMetabaseObjectCreateInfo;
ProblemCopied, ProblemCopy: IMsProblem;
i: Integer;
CalcSettCopied, CalcSettCopy: IMsProblemCalculationSettings;
PeriodCopied, PeriodCopy: IMsModelPeriod;
OutputPeriodCopied, OutputPeriodCopy: IMsDatePeriod;
ProblemCalc: IMsProblemCalculation;
Begin
mb := Params.Metabase;
// Get modelling container key
MsKey := mb.GetObjectKeyById("MS");
// Get copied problem
ProblemCopied := mb.ItemByIdNamespace["PROBLEM_COPIED", MsKey].Edit() As IMsProblem;
// Create object for a copy problem
CrInfo := MB.CreateCreateInfo();
CrInfo.ClassID := MetabaseObjectClass.KE_CLASS_MSPROBLEM As integer;
CrInfo.Id := MB.GenerateId("PROBLEM_COPY", MsKey);
CrInfo.Name := "Modeling problem (copy)";
CrInfo.Parent := ProblemCopied.MetabaseObject.Parent;
ProblemCopy := MB.CreateObject(CrInfo).Edit() As IMsProblem;
// Copy metamodel
ProblemCopy.MetaModel := ProblemCopied.MetaModel;
// Copy problem parameters
ProblemCopy.Details := ProblemCopied.Details;
// Copy scenario
For i := 0 To ProblemCopied.Scenarios.Count - 1 Do
ProblemCopy.Scenarios.AddScenario(ProblemCopied.Scenarios.Item[i]);
End For;
// Copy data loading period parameters
CalcSettCopied := ProblemCopied.CreateCalculationSettings();
OutputPeriodCopied := CalcSettCopied.OutputPeriod As IMsDatePeriod;
CalcSettCopy := ProblemCopy.CreateCalculationSettings();
OutputPeriodCopy := CalcSettCopy.OutputPeriod As IMsDatePeriod;
OutputPeriodCopy.Assign(OutputPeriodCopied As MsDatePeriod);
// Copy problem calculation periods
PeriodCopied := CalcSettCopied.Period;
PeriodCopy := CalcSettCopy.Period;
PeriodCopy.Assign(PeriodCopied);
// Save copy
(ProblemCopy As IMetabaseObject).Save();
// Calculate copy problem
ProblemCalc := ProblemCopy.Calculate(CalcSettCopy);
ProblemCalc.Run();
End Sub;
See also: