IPrxDataSource.Refresh

Fore Syntax

Refresh(Dimension: IMetabaseObjectDescriptor; [Instance: IDimInstance = Null]): Boolean;

Fore.NET Syntax

Refresh(Prognoz.Platform.Interop.Metabase.IMetabaseObjectDescriptor, Prognoz.Platform.Interop.Dimensions.IDimInstance): System.Boolean;

Parameters

Dimension. The dimension included to the cube, which is a data source.

Instance. The dictionary instance to work with elements.

Description

The Refresh method updates slice dimension.

Comments

To get dictionary instance (the Instance parameter) and work with elements, use the IMetabaseObjectDescriptor.Open method and cast the dictionary to the IDimInstance interface.

Fore Example

To execute the example:

  1. Create a regular report.

  2. Add a cube as a data source containing MDM dictionaries with the D_FACTS and DIC_SOURCE identifiers. The MDM dictionaries contain attributes with the NAME and ORD identifiers.

  3. Add a slice to data area .

  4. Drag the added slice to the report sheet using Drag&Drop.

  5. Add two controls for MDM dictionaries with the D_FACTS and DIC_SOURCE identifiers.

  6. Add the Metabase, Report, Rds, Dimensions system assemblies in units.

  7. Create the first unit to work with elements of the MDM dictionary with the D_FACTS identifier:

Sub UserProc;
Var
    Report: IPRxReport;
    MB: IMetabase;
    MObj1: IMetabaseObject;
    DtSources: IPrxDataSources;
    DtSource: IPrxDataSource;
    DimI: IDimInstance;
    Str: String;
    Key, i: Integer;
    Rds: IRdsDictionaryInstance;
    Data: IRdsDictionaryElementData;
Begin
    // Get active regular report
    Report := PrxReport.ActiveReport;
    MB := Report.MetabaseObject.Metabase;
    DtSources := Report.DataSources;
    DtSource := DtSources.Item(0);
    // Get MDM dictionary with the specified identifier
    MObj1 := MB.ItemByIdNamespace("D_FACTS"159).Bind;
    // Open MDM dictionary for edit
    DimI := MObj1.Open(NullAs IDimInstance;
    Rds := DimI As IRdsDictionaryInstance;
    // Create element containing attribute data of the MDM dictionary element
    Data := Rds.CreateElementData;
    // Add name to the attribute with the NAME identifier
    Key := Rds.Attributes.FindById("NAME").Attribute.Key;
    Str := "Element " + Rds.Elements.Count.ToString;
    Data.Attribute(Key) := Str;
    // Add value to the attribute with the ORD identifier
    Key := Rds.Attributes.FindById("ORD").Attribute.Key;
    i := Rds.Elements.Count;
    Data.Attribute(Key) := i;
    // Add a created element to MDM dictionary
    Rds.Insert(Rds.Elements.Root, Data);
    // Create MDM dictionary instance
    DimI := MObj1.Open(NullAs IDimInstance;
    // Add the second element by analogy
    Data := Rds.CreateElementData;
    Key := Rds.Attributes.FindById("NAME").Attribute.Key;
    Str := "Element " + Rds.Elements.Count.ToString;
    Data.Attribute(Key) := Str;
    Key := Rds.Attributes.FindById("ORD").Attribute.Key;
    i := Rds.Elements.Count;
    Data.Attribute(Key) := i;
    Rds.Insert(Rds.Elements.Root, Data);
    // Refresh dimension in the report
    DtSource.Refresh(MObj1 As IMetabaseObjectDescriptor, DimI);
End Sub UserProc;

  1. Connect the first unit to the report.

  2. Add text with hyperlink in order to execute procedure or function. Select the first unit connected previously to the report.

  3. Create the second unit to work with elements of the MDM dictionary with the DIC_SOURCE identifier:

Sub UserProc;
Var
    Report: IPRxReport;
    MB: IMetabase;
    MObj1: IMetabaseObject;
    DtSources: IPrxDataSources;
    DtSource: IPrxDataSource;
    DimI: IDimInstance;
    Str: String;
    Key, i: Integer;
    Rds: IRdsDictionaryInstance;
    Data: IRdsDictionaryElementData;
Begin
    // Get active regular report
    Report := PrxReport.ActiveReport;
    MB := Report.MetabaseObject.Metabase;
    DtSources := Report.DataSources;
    DtSource := DtSources.Item(0);
    // Get MDM dictionary with the specified identifier
    MObj1 := MB.ItemByIdNamespace("DIC_SOURCE"159).Bind;
    // Open MDM dictionary for edit
    DimI := MObj1.Open(NullAs IDimInstance;
    Rds := DimI As IRdsDictionaryInstance;
    // Create element containing attribute data of the MDM dictionary element
    Data := Rds.CreateElementData;
    // Add name to the attribute with the NAME identifier
    Key := Rds.Attributes.FindById("NAME").Attribute.Key;
    Str := "Element " + Rds.Elements.Count.ToString;
    Data.Attribute(Key) := Str;
    // Add value to the attribute with the ORD identifier
    Key := Rds.Attributes.FindById("ORD").Attribute.Key;
    i := Rds.Elements.Count;
    Data.Attribute(Key) := i;
    // Add a created element to MDM dictionary
    Rds.Insert(Rds.Elements.Root, Data);
    // Create MDM dictionary instance
    DimI := MObj1.Open(NullAs IDimInstance;
    // Add the second element by analogy
    Data := Rds.CreateElementData;
    Key := Rds.Attributes.FindById("NAME").Attribute.Key;
    Str := "Element " + Rds.Elements.Count.ToString;
    Data.Attribute(Key) := Str;
    Key := Rds.Attributes.FindById("ORD").Attribute.Key;
    i := Rds.Elements.Count;
    Data.Attribute(Key) := i;
    Rds.Insert(Rds.Elements.Root, Data);
    // Refresh dimension in the report
    DtSource.Refresh(MObj1 As IMetabaseObjectDescriptor);
End Sub UserProc;

  1. Connect the second unit to the report.

  2. Add text with hyperlink in order to execute procedure or function. Select the second unit connected previously to the report.

In regular report, after clicking the first hyperlink, one element is added to the MDM dictionary with the D_FACTS identifier, and after clicking the second hyperlink two elements are added to the MDM dictionary with the DIC_SOURCE identifier. The difference in results is that on refreshing dimension in report, the dictionary instance to work with the DimI elements (the Instance parameter) is set and it was not set for the second unit. New elements of MDM dictionaries are displayed in the report controls.

Fore.NET Example

To execute the example:

  1. Create a regular report.

  2. Add a cube as a data source containing MDM dictionaries with the D_FACTS and DIC_SOURCE identifiers and attributes with the NAME and ORD identifiers.

  3. Add a slice to data area .

  4. Drag the added slice to the report sheet using Drag&Drop.

  5. Add two controls for MDM dictionaries with the D_FACTS and DIC_SOURCE identifiers.

  6. Create an event handler in the .NET assembly.

  7. Add links to the Metabase, Report, Rds, Dimensions system assemblies.

  8. Determine for the OnBeforeExecuteReport and OnBeforeSaveReport events adding of new elements to MDM dictionaries:

Imports Prognoz.Platform.Interop.Report;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.Rds;
Imports Prognoz.Platform.Interop.Dimensions;

Public Override Sub OnBeforeExecuteReport(Report: IPrxReport; Var Cancel: Boolean);
Var
    MB: IMetabase;
    MObj1: IMetabaseObject;
    DtSources: IPrxDataSources;
    DtSource: IPrxDataSource;
    DimI: IDimInstance;
    Str: String;
    Key: uinteger;
    i: integer;
    Rds: IRdsDictionaryInstance;
    Data: IRdsDictionaryElementData;
Begin
    MB := Report.MetabaseObject.Metabase;
    DtSources := Report.DataSources;
    DtSource := DtSources.Item[0];
    // Get MDM dictionary with the specified identifier
    MObj1 := MB.ItemByIdNamespace["D_FACTS"159].Bind();
    // Open MDM dictionary for edit
    DimI := MObj1.Open(NullAs IDimInstance;
    Rds := DimI As IRdsDictionaryInstance;
    // Create element containing attribute data of the MDM dictionary element
    Data := Rds.CreateElementData();
    // Add name to the attribute with the NAME identifier
    Key := Rds.Attributes.FindById("NAME").Attribute.Key;
    Str := "Element " + Rds.Elements.Count.ToString();
    Data.Attribute[Key] := Str;
    // Add value to the attribute with the ORD identifier
    Key := Rds.Attributes.FindById("ORD").Attribute.Key;
    i := Rds.Elements.Count;
    Data.Attribute[Key] := i;
    // Add a created element to MDM dictionary
    Rds.Insert(Rds.Elements.Root, Data);
    // Create MDM dictionary instance
    DimI := MObj1.Open(NullAs IDimInstance;
    // Add the second element by analogy
    Data := Rds.CreateElementData();
    Key := Rds.Attributes.FindById("NAME").Attribute.Key;
    Str := "Element " + Rds.Elements.Count.ToString();
    Data.Attribute[Key] := Str;
    Key := Rds.Attributes.FindById("ORD").Attribute.Key;
    i := Rds.Elements.Count;
    Data.Attribute[Key] := i;
    Rds.Insert(Rds.Elements.Root, Data);
    // Refresh dimension in report
    DtSource.Refresh(MObj1 As IMetabaseObjectDescriptor, DimI);
End Sub OnBeforeExecuteReport;

Public Override Sub OnBeforeSaveReport(Report: IPrxReport; Var Cancel: Boolean);
Var
    MB: IMetabase;
    MObj1: IMetabaseObject;
    DtSources: IPrxDataSources;
    DtSource: IPrxDataSource;
    DimI: IDimInstance;
    Str: String;
    Key: uinteger;
    i: integer;
    Rds: IRdsDictionaryInstance;
    Data: IRdsDictionaryElementData;
Begin
    MB := Report.MetabaseObject.Metabase;
    DtSources := Report.DataSources;
    DtSource := DtSources.Item[0];
    // Get MDM dictionary with the specified identifier
    MObj1 := MB.ItemByIdNamespace["DIC_SOURCE"159].Bind();
    // Open MDM dictionary for edit
    DimI := MObj1.Open(NullAs IDimInstance;
    Rds := DimI As IRdsDictionaryInstance;
    // Create element containing attribute data of the MDM dictionary element
    Data := Rds.CreateElementData();
    // Add name to the attribute with the NAME identifier
    Key := Rds.Attributes.FindById("NAME").Attribute.Key;
    Str := "Element " + Rds.Elements.Count.ToString();
    Data.Attribute[Key] := Str;
    // Add value to the attribute with the ORD identifier
    Key := Rds.Attributes.FindById("ORD").Attribute.Key;
    i := Rds.Elements.Count;
    Data.Attribute[Key] := i;
    // Add a created element to MDM dictionary
    Rds.Insert(Rds.Elements.Root, Data);
    // Create MDM dictionary instance
    DimI := MObj1.Open(NullAs IDimInstance;
    // Add the second element by analogy
    Data := Rds.CreateElementData();
    Key := Rds.Attributes.FindById("NAME").Attribute.Key;
    Str := "Element " + Rds.Elements.Count.ToString();
    Data.Attribute[Key] := Str;
    Key := Rds.Attributes.FindById("ORD").Attribute.Key;
    i := Rds.Elements.Count;
    Data.Attribute[Key] := i;
    Rds.Insert(Rds.Elements.Root, Data);
    // Refresh dimension in report
    DtSource.Refresh(MObj1 As IMetabaseObjectDescriptor, Null);
End Sub OnBeforeSaveReport;

In regular report after clicking the Refresh button on the Home ribbon tab, the event occurs, which adds one element to MDM dictionary with the D_FACTS identifier and after clicking the Save button two elements are added to MDM dictionary with the DIC_SOURCE identifier. New elements of MDM dictionaries are displayed in the report controls.

See also:

IPrxDataSource