IMsMetaModelVisualController.FillWithModel

Fore Syntax

FillWithModel(Model: IMsModel;
              ScenarioKeys: Array;
              Period: IMsModelPeriod;
              LoadPeriod: IMsModelPeriod;
              Problem: IMsProblem;
              [Workbook: IMetabaseObject = Null;]
              [IncludeFact: Boolean = True]);

Fore.NET Syntax

FillWithModel(Model: Prognoz.Platform.Interop.Ms.IMsModel;
              ScenarioKeys: System.Array;
              Period: Prognoz.Platform.Interop.Ms.IMsModelPeriod;
              LoadPeriod: Prognoz.Platform.Interop.Ms.IMsModelPeriod;
              Problem: Prognoz.Platform.Interop.Ms.IMsProblem;
              Workbook: Prognoz.Platform.Interop.Metabase.IMetabaseObject;
              IncludeFact: boolean);

Parameters

Model. Internal model.

ScenarioKeys. Array of scenario keys.

Period. Period of data loading.

LoadPeriod. Period of data displaying.

Problem. Modeling problem, to which the loading is performed.

Workbook. External workbook, to which the results should be unloaded. Optional parameter.

IncludeFact. Determines whether to include model data by the Fact scenario.

Description

The FillWithModel method fills the internal workbook with the model data by the set scenarios.

Comments

To filter data by the scenario dictionary, use the Problem parameter. It allows to load data only by the specified problem, not by all scenarios in the modeling container. It is also used to determine whether the scenario modelling is used.

If Workbook = Null, the internal workbook with loaded data is returned by the IMsMetaModelVisualController.VariableWorkbook or the IMsMetaModelVisualController.Workbook property, if it is required to specify the MsWorkbookType.Variable value as value of the WorkbookType parameter.

The IncludeFact parameter is considered if scenario modeling is used, and key of the Fact scenario is missing in the ScenarioKeys parameter.

Fore Example

Executing the example requires that the repository contains a modeling container with the MS identifier containing a modeling problem with the FILLMODEL identifier created in the web application. This problem must contain equation. Several scenarios must be used on problem calculation.

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

Sub FillWithModel;
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    Meta: IMsMetaModel;
    MetaVisual: IMsMetaModelVisualController;
    SimpleModel: IMsModel;
    ScArr: Array Of Integer;
    Target: IUiCommandTarget;
    pr: IMsProblem;
    Period: IMsModelPeriod;
    i: Integer;
    ChainEn: IMsCalculationChainEntries;
Begin
    mb := MetabaseClass.Active;
    // Get modeling container
    MsObj := mb.ItemById("MS");
    // Get modeling problem
    pr := mb.ItemByIdNamespace("FILLMODEL", MsObj.Key).Bind As IMsProblem;
    // Get metamodel
    Meta := pr.MetaModel;
    MetaVisual := Meta.VisualController;
    // Get the model
    ChainEn := Meta.CalculationChain;
    For i := 0 To ChainEn.Count - 1 Do
        If ChainEn.Item(i).Type = MsCalculationChainEntryType.Model Then
            SimpleModel := (ChainEn.Item(i) As IMsCalculationChainModel).Model;
        End If;
    End For;
    // Create an array of scenario keys
    ScArr := New Integer[1];
    // Add first scenario key
    ScArr[0] := (MsObj.Bind As IMsModelSpace).ScenarioTree.Item(0).Key;
    Period := SimpleModel.Transform.Period;
    // Fill the workbook with the data from the model
    MetaVisual.FillWithModel(SimpleModel, ScArr, Period, Period, pr, NullFalse);
    // Open the workbook
    Target := WinApplication.Instance.GetObjectTarget(MetaVisual.VariableWorkbook);
    Target.Execute("Object.Edit"Null);
End Sub FillWithModel;

After executing the example a workbook is opened that is filled with internal model data without considering data by the Fact scenario.

Fore.NET Example

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

Imports Prognoz.Platform.Interop.Ms;
Imports Prognoz.Platform.Interop.Ui;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    MsObj: IMetabaseObjectDescriptor;
    Meta: IMsMetaModel;
    MetaVisual: IMsMetaModelVisualController;
    SimpleModel: IMsModel;
    ScArr: Array Of integer;
    Target: IUiCommandTarget;
    Wa: IWinApplicationClass;
    pr: MsProblem;
    Period: IMsModelPeriod;
    i: Integer;
    ChainEn: IMsCalculationChainEntries;
Begin
    mb := Params.Metabase;
    // Get modeling container
    MsObj := mb.ItemById["MS"];
    // Get modeling problem
    pr := mb.ItemByIdNamespace["FILLMODEL", MsObj.Key].Bind() As MsProblem;
    // Get metamodel
    Meta := pr.MetaModel;
    MetaVisual := Meta.VisualController;
    // Get the model
    ChainEn := Meta.CalculationChain;
    For i := 0 To ChainEn.Count - 1 Do
        If ChainEn.Item[i].Type = MsCalculationChainEntryType.mccetModel Then
            SimpleModel := (ChainEn.Item[i] As IMsCalculationChainModel).Model;
        End If;
    End For;
    // Create an array of scenario keys
    ScArr := New integer[1];
    // Add first scenario key
    ScArr[0] := (MsObj.Bind() As IMsModelSpace).ScenarioTree.Item[0].Key As integer;
    Period := SimpleModel.Transform.Period;
    // Fill the workbook with the data from the model
    MetaVisual.FillWithModel(SimpleModel, ScArr As system.Array, Period, Period, pr, NullFalse);
    // Open the workbook
    Wa := New WinApplicationClassClass();
    Target := Wa.Instance[Null].GetObjectTarget(MetaVisual.VariableWorkbook);
    Target.Execute("Object.Edit"NullNull);
End Sub;

See also:

IMsMetaModelVisualController