IMsDatePeriod.AutoPeriodDates

Fore Syntax

AutoPeriodDates(Calculation: IMsMethodCalculation;

                Coord: IMsFormulaTransformCoord;

                Var AutoStartDate: DateTime;

                Var AutoEndDate: DateTime);

Fore.NET Syntax

AutoPeriodDates(Calculation: Prognoz.Platform.Interop.Ms.IMsMethodCalculation;

                Coord: Prognoz.Platform.Interop.Ms.IMsFormulaTransformCoord;

                var AutoStartDate: System.DateTime;

                var AutoEndDate: System.DateTime);

Parameters

Calculation. Settings that are necessary on model calculation.

Coord. Coordinate parameters in the variable, by which the calculation is executed.

AutoStartDate. Period start date

AutoEndDate. Period end date.

Description

The AutoPeriodDates method returns period limits, if conditions to calculate period start and end dates are used.

Comments

The AutoStartDate and AutoEndDate parameters should be variables. After executing the method they will contain results.

Fore Example

Executing the example requires that the repository contains a modeling container with the MS identifier containing a model with the MODEL_FREEDIM identifier.

Add links to the Metabase, Ms system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    DescrCM: IMetabaseObjectDescriptor;
    pModel: IMsModel;
    trans: IMsFormulaTransform;
    coo: IMsFormulaTransformCoord;
    calc: IMsMethodCalculation;
    Period: IMsModelPeriod;
    OutputPeriod: IMsDatePeriod;
    StDate, EndDate: DateTime;
Begin
    // Get the model
    mb := MetabaseClass.Active;
    DescrCM := mb.ItemById("MS");
    pModel := mb.ItemByIdNamespace("MODEL_FREEDIM", DescrCM.Key).Edit As IMsModel;
    // Set calculation parameters
    trans := pModel.Transform;
    coo := trans.CreateCoord(trans.Outputs.Item(0));
    calc := trans.CreateCalculation;
    // Set calculation periods
    Period := pModel.Transform.Period;
    calc.Period.IdentificationStartDate := Period.IdentificationStartDate;
    calc.Period.IdentificationEndDate := Period.IdentificationEndDate;
    calc.Period.ForecastStartDate := Period.ForecastStartDate;
    calc.Period.ForecastEndDate := Period.ForecastEndDate;
    calc.CurrentPoint := Period.IdentificationStartDate;
    OutputPeriod := trans.OutputPeriod As IMsDatePeriod;
    // Clear parameters of data unloading period
    OutputPeriod.ClearPeriod;
    // Set autoperiod parameters: data loading period is determined by current date
    OutputPeriod.AutoPeriod := MsDateAutoPeriodOptions.StartAsNow Or MsDateAutoPeriodOptions.EndAsNow;
    // Set moving of start and end dates for data unloading period
    OutputPeriod.StartOffset := 1;
    OutputPeriod.EndOffset := 2;
    // Get and display to the console period start and end dates of data loading
    OutputPeriod.AutoPeriodDates(calc, coo, StDate, EndDate);
    Debug.WriteLine("Data uploading start: " + StDate.ToString);
    Debug.WriteLine("Data upload end: " + EndDate.ToString);
    // Save changes
    (pModel As IMetabaseObject).Save;
End Sub UserProc;

After executing the example data calculation and uploading periods will be set for the model. Data uploading period will be set using conditions, period actual dates will be displayed in the console.

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;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    DescrCM: IMetabaseObjectDescriptor;
    pModel: IMsModel;
    trans: IMsFormulaTransform;
    coo: IMsFormulaTransformCoord;
    calc: IMsMethodCalculation;
    Period: IMsModelPeriod;
    OutputPeriod: IMsDatePeriod;
    StDate, EndDate: DateTime;
Begin
    // Get the model
    mb := Params.Metabase;
    DescrCM := mb.ItemById["MS"];
    pModel := mb.ItemByIdNamespace["MODEL_FREEDIM", DescrCM.Key].Edit() As IMsModel;
    // Set calculation parameters
    trans := pModel.Transform;
    coo := trans.CreateCoord(trans.Outputs.Item[0]);
    calc := trans.CreateCalculation;
    // Set calculation periods
    Period := pModel.Transform.Period;
    calc.Period.IdentificationStartDate := Period.IdentificationStartDate;
    calc.Period.IdentificationEndDate := Period.IdentificationEndDate;
    calc.Period.ForecastStartDate := Period.ForecastStartDate;
    calc.Period.ForecastEndDate := Period.ForecastEndDate;
    calc.CurrentPoint := Period.IdentificationStartDate;
    OutputPeriod := trans.OutputPeriod As IMsDatePeriod;
    // Clear parameters of data unloading period
    OutputPeriod.ClearPeriod();
    // Set autoperiod parameters: data loading period is determined by current date
    OutputPeriod.AutoPeriod := MsDateAutoPeriodOptions.msdapoStartAsNow Or MsDateAutoPeriodOptions.msdapoEndAsNow;
    // Set moving of start and end dates for data unloading period
    OutputPeriod.StartOffset := 1;
    OutputPeriod.EndOffset := 2;
    // Get and display to the console period start and end dates of data loading
    OutputPeriod.AutoPeriodDates(calc, coo, Var StDate, Var EndDate);
    System.Diagnostics.Debug.WriteLine("Data uploading start: " + StDate.ToString);
    System.Diagnostics.Debug.WriteLine("Data upload end: " + EndDate.ToString());
    // Save changes
    (pModel As IMetabaseObject).Save();
End Sub;

See also:

IMsDatePeriod