ICalendarDimension.Setup

Fore Syntax

Setup: ICalendarSetup;

Fore.NET Syntax

Setup: Prognoz.Platform.Interop.Dimensions.ICalendarSetup;

Description

The Setup property returns the calendar parameters back with dynamically created elements.

Comments

Use the ICalendarDimension.OpenAs to dynamically open calendar.

Fore Example

Executing the example requires that the repository containing a time series database with the FC_COMM identifier. You will also need a form that contains a button with the Button1 identifier and two Memo components with the Memo1 and Memo2 identifiers. Add links to the Metabase, Cube and Dimensions system assemblies. This example handles the OnClick event for the button.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    mb: IMetabase;
    Rub: IRubricator;
    CalendarObj: IMetabaseObject;
    Calendar: ICalendarDimension;
    CalendDimInst: IDimInstance;
    DynamicCalendInst: IDynamicCalendarInstance;
    Setup: ICalendarSetup;
    Iterator: IDimIterator;
Begin
    mb := MetabaseClass.Active;
    Rub := mb.ItemById("FC_COMM").Edit As IRubricator;
    CalendarObj := Rub.EditCalendar As IMetabaseObject;
    Calendar := CalendarObj As ICalendarDimension;
    Calendar.DefaultOpenType := CalendarOpenType.Hierarchical;
    CalendDimInst := Calendar.OpenAs(CalendarOpenType.Flat);
    DynamicCalendInst := CalendDimInst As IDynamicCalendarInstance;
    Setup := Calendar.Setup;
    Iterator := DynamicCalendInst.Iterator(Setup);
    Memo1.Clear;
    Memo1.Lines.Add("Old values");
    While Iterator.Next Do
        Memo1.Lines.Add(CalendDimInst.Elements.Name(Iterator.Element));
    End While;
    Setup.Levels := DimCalendarLevelSet.Week Or DimCalendarLevelSet.Month Or DimCalendarLevelSet.Year;
    Setup.StartDay := DateTime.Parse("01.01.2000");
    Setup.EndDay := DateTime.Parse("01.01.2020");
    Setup.WeekLevel.RestDays := DayOfWeekSet.SaturdaySunday;
    CalendarObj.Save;
    CalendDimInst := Calendar.OpenAs(CalendarOpenType.Flat);
    DynamicCalendInst := CalendDimInst As IDynamicCalendarInstance;
    Iterator := DynamicCalendInst.Iterator(Setup);
    Memo2.Clear;
    Memo2.Lines.Add("New values");
    While Iterator.Next Do
        Memo2.Lines.Add(CalendDimInst.Elements.Name(Iterator.Element));
    End While;
End Sub Button1OnClick;

After executing the example the calendar of time series database is opened dynamically in the flat view. Dictionary elements are displayed in the Memo1 component. Next calendar parameters are changed and saved:

Dictionary elements (as a flat structure, and taking changes into account) are displayed in the Memo2 component.

Fore.NET Example

Executing the example requires that the repository contains a time series database with the FC_COMM identifier. There Should also be a .NET form containing a button with the button1 identifier and two ListBox components with the listBox1 and listBox2 identifiers. This example handles the Click event for the button.

Imports Prognoz.Platform.Interop.Dimensions;
Imports Prognoz.Platform.Interop.Cubes;

Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
    mb: IMetabase;
    Rub: IRubricator;
    CalendarObj: IMetabaseObject;
    Calendar: ICalendarDimension;
    CalendDimInst: IDimInstance;
    DynamicCalendInst: IDynamicCalendarInstance;
    Setup: ICalendarSetup;
    Iterator: IDimIterator;
Begin
    mb := Self.Metabase;
    Rub := mb.ItemById["FC_COMM"].Edit() As IRubricator;
    CalendarObj := Rub.EditCalendar() As IMetabaseObject;
    Calendar := CalendarObj As ICalendarDimension;
    Calendar.DefaultOpenType := CalendarOpenType.caoptyHierarchical;
    CalendDimInst := Calendar.OpenAs(CalendarOpenType.caoptyFlat);
    DynamicCalendInst := CalendDimInst As IDynamicCalendarInstance;
    Setup := Calendar.Setup;
    Iterator := DynamicCalendInst.Iterator[Setup];
    listBox1.Items.Clear();
    listBox1.Items.Add("Old values");
    While Iterator.Next() Do
        listBox1.Items.Add(CalendDimInst.Elements.Name[Iterator.Element]);
    End While;
    Setup.Levels := DimCalendarLevelSet.dclsWeek Or DimCalendarLevelSet.dclsMonth Or DimCalendarLevelSet.dclsYear;
    Setup.StartDay := DateTime.Parse("01.01.2000");
    Setup.EndDay := DateTime.Parse("01.01.2020");
    Setup.WeekLevel.RestDays := DayOfWeekSet.dowsSaturdaySunday;
    CalendarObj.Save();
    CalendDimInst := Calendar.OpenAs(CalendarOpenType.caoptyFlat);
    DynamicCalendInst := CalendDimInst As IDynamicCalendarInstance;
    Iterator := DynamicCalendInst.Iterator[Setup];
    listBox2.Items.Clear();
    listBox2.Items.Add("New values");
    While Iterator.Next() Do
        listBox2.Items.Add(CalendDimInst.Elements.Name[Iterator.Element]);
    End While;
End Sub;

After executing the example the calendar of time series database is opened dynamically in the flat view. Dictionary elements are displayed in the listBox1 component. Next calendar parameters are changed and saved:

Dictionary elements (as a flat structure, and taking changes into account) are displayed in the listBox2 component.

See also:

ICalendarDimension