Setup: ICalendarSetup;
The Setup property returns the calendar parameters back with dynamically created elements.
Use the ICalendarDimension.OpenAs to dynamically open calendar.
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:
Available levels: weeks, months, years.
Calendar start: 01.01.2000.
Calendar end: 01.01.2020.
Days off: Saturday, Sunday.
The calendar opens as a hierarchy by default.
Dictionary elements (as a flat structure, and taking changes into account) are displayed in the Memo2 component.
See also: