IMetabaseUpdateProgress.OnBeforeCustomObjectSaveToPef

Fore Syntax

OnBeforeCustomObjectSaveToPef(Resolver: ICustomObjectResolver);

Fore.NET Syntax

OnBeforeCustomObjectSaveToPef(Resolver: Prognoz.Platform.Interop.Metabase.ICustomObjectResolver);

Parameters

Resolver. Object used to work with custom object.

Description

The OnBeforeCustomObjectSaveToPef method implements an event that occurs before custom object is saved to PEF file.

Comments

The event occurs for each custom object contained in the update.

The event also occurs on replication of time series database containing custom objects to ZIP file.

Fore Example

Executing the example requires that the repository contains a time series database with the TSDB_PEF identifier. This database must contain a child custom object, in which any data in the XML format is written.

Add links to the Cubes, Metabase, Xml system assemblies.

Sub UserProc;
Var
    Mb: IMetabase;
    metaUpdate: ICubeMetaUpdateEx;
    Rub: IRubricator;
    Progress: MyUpdateProgress;
    objects: ICubeMetaUpdateAdditionalObjects;
    object: ICubeMetaUpdateAdditionalObject;
Begin
    // Get current repository
    Mb := MetabaseClass.Active;
    // Create an object for replication
    metaUpdate := New CubeMetaUpdateClass.Create As ICubeMetaUpdateEx;
    // Specify the repository, to which replication is executed
    metaUpdate.Metabase := Mb;
    // Get time series database
    rub := mb.ItemById("TSDB_PEF").Bind As IRubricator;
    // Specify that the obtained time series database is replicated
    metaUpdate.Rubricator := rub;
    // Specify MDM repository used for replication
    metaUpdate.RdsDatabase := rub.Database;
    // Specify that data is not replicated
    metaUpdate.CopyData := False;
    // Specify that replication is executed  with child objects
    metaUpdate.CopyExtraObjects := True;
    // Create an object for handling of events that occur during replication
    Progress := New MyUpdateProgress.Create;
    // Execute replication to file
    metaUpdate.SaveEx("C:\Replication.zip", Progress);
End Sub UserProc;

// Class that implements events that occur during replication
Class MyUpdateProgress: UpdateProgress

    // Event that occurs before saving custom objects to file
    Sub OnBeforeCustomObjectSaveToPef(Resolver: ICustomObjectResolver);
    Var
        i: Integer;
        Refs: IMetabaseCustomObjectReferences;
        Ref: IMetabaseCustomObjectReference;
        XmlVar: Variant;
        xmlDE: IXmlDomElement;
        XmlDoc: IXmlDomDocument;
    Begin
        // Output basic information about custom object
        Debug.WriteLine("Object class: " + Resolver.ClassId.ToString);
        Debug.WriteLine("Name: " + Resolver.Name);
        Debug.WriteLine("Description: " + Resolver.Description);
        Debug.WriteLine("Identifier: " + Resolver.Id);
        Debug.WriteLine("Key: " + Resolver.Key.ToString);
        // Output information about object dependencies
        Refs := Resolver.References;
        For i := 0 To Refs.Count - 1 Do
            Ref := Refs.Item(i);
            Debug.WriteLine("Object :" + Ref.Object.Name);
            Debug.WriteLine("Owner :" + Ref.Owner.Name);
        End For;
        // Read data from object to XML format
        Resolver.ReadToXML(XmlVar);
        // Present read data as a document
        XmlDoc := XmlVar As IXmlDomDocument;
        // If document contains data, output it to console window
        If (XmlDoc <> NullThen
            Debug.WriteLine("Before:");
            Debug.WriteLine(XmlDoc.xml);
            // Form new data in the XML format
            XmlDoc.loadXML("<nodes> <node1>ITEM1=13</node1> <node2>ITEM2=10</node2> </nodes>");
            Debug.WriteLine("After:");
            // Output formed data to console window
            Debug.WriteLine(XmlDoc.xml);
            // Write updated data to custom object
            Resolver.WriteFromXML(XmlDoc);
        End If;
    End Sub OnBeforeCustomObjectSaveToPef;
            
End Class MyUpdateProgress;

After executing the example, the TSDB_PEF time series database is replicated to the C:\Replication.zip file. The event that occurs before saving custom object is processed. The console window displays basic information about each custom object and information about dependencies. Data in the XML format contained in the custom object is also changed.

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example. Use Fore.NET analogs instead of Fore components.

Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.MsXml2;

Public Shared Sub Main(Params: StartParams);
Var
    Mb: IMetabase;
    metaUpdate: ICubeMetaUpdateEx;
    Rub: IRubricator;
    Progress: MyUpdateProgress;
    objects: ICubeMetaUpdateAdditionalObjects;
    object: ICubeMetaUpdateAdditionalObject;
Begin
    // Get current repository
    Mb := Params.Metabase;
    // Create an object for replication
    metaUpdate := New CubeMetaUpdateClass.Create() As ICubeMetaUpdateEx;
    // Specify the repository, to which replication is executed
    metaUpdate.Metabase := Mb;
    // Get time series database
    rub := mb.ItemById["TSDB_PEF"].Bind() As IRubricator;
    // Specify that the obtained time series database is replicated
    metaUpdate.Rubricator := rub;
    // Specify MDM repository used for replication
    metaUpdate.RdsDatabase := rub.Database;
    // Specify that data is not replicated
    metaUpdate.CopyData := False;
    // Specify that replication is executed  with child objects
    metaUpdate.CopyExtraObjects := True;
    // Create an object for handling of events that occur during replication
    Progress := New MyUpdateProgress.Create();
    // Execute replication to file
    metaUpdate.SaveEx("C:\Replication.zip", Progress);
End Sub;

// Class that implements events that occur during replication
Public Class MyUpdateProgress: IMetabaseUpdateProgress

    // Event that occurs before saving custom objects to file
    Public Sub OnBeforeCustomObjectSaveToPef(Resolver: ICustomObjectResolver);
    Var
        i: Integer;
        Refs: IMetabaseCustomObjectReferences;
        Ref: IMetabaseCustomObjectReference;
        XmlVar: object;
        xmlDE: IXmlDomElement;
        XmlDoc: IXmlDomDocument;
    Begin
        // Output basic information about custom object
        System.Diagnostics.Debug.WriteLine("Object class: " + Resolver.ClassId.ToString());
        System.Diagnostics.Debug.WriteLine("Name: " + Resolver.Name);
        System.Diagnostics.Debug.WriteLine("Description: " + Resolver.Description);
        System.Diagnostics.Debug.WriteLine("Identifier: " + Resolver.Id);
        System.Diagnostics.Debug.WriteLine("Key: " + Resolver.Key.ToString());
        // Output information about object dependencies
        Refs := Resolver.References;
        For i := 0 To Refs.Count - 1 Do
            Ref := Refs.Item[i];
            System.Diagnostics.Debug.WriteLine("Object :" + Ref.Object.Name);
            System.Diagnostics.Debug.WriteLine("Owner :" + Ref.Owner.Name);
        End For;
        // Read data from object to XML format
        Resolver.ReadToXML(Var XmlVar);
        // Present read data as a document
        XmlDoc := XmlVar As IXmlDomDocument;
        // If document contains data, output it to console window
        If (XmlDoc <> NullThen
            System.Diagnostics.Debug.WriteLine("Before:");
            System.Diagnostics.Debug.WriteLine(XmlDoc.xml);
            // Form new data in the XML format
            XmlDoc.loadXML("<nodes> <node1>ITEM1=13</node1> <node2>ITEM2=10</node2> </nodes>");
            System.Diagnostics.Debug.WriteLine("After:");
            // Output formed data to console window
            System.Diagnostics.Debug.WriteLine(XmlDoc.xml);
            // Write updated data to custom object
            Resolver.WriteFromXML(XmlDoc);
        End If;
    End Sub OnBeforeCustomObjectSaveToPef;
    
    Public Sub OnProgress(Data: IMetabaseUpdateProgressData);
    Begin
    End Sub;
    
    Public Sub OnError(Data: IMetabaseUpdateProgressData; Var Ignore: Boolean);
    Begin
    End Sub;
    
    Public Sub OnAskConstraintsHandling(Node: IMetabaseUpdateNode; Details: String; Var Handling: UpdateDataConstraintsHandlingType);
    Begin
    End Sub;
    
    Public Sub OnAskReflectRights(Var Cancel: Boolean);
    Begin
    End Sub;
    
    Public Sub OnContext(Context: IMetabaseUpdateContext);
    Begin
    End Sub;
    
    Public Sub OnResolve(Node: IMetabaseUpdateNode; Resolver: IMetabaseUpdateResolver);
    Begin
    End Sub;
    
    Public Sub OnSkip(Data: IMetabaseUpdateProgressData);
    Begin
    End Sub;
    
    Public Sub OnNullLinks(Node: IMetabaseUpdateNode; Links: IMetabaseUpdateNullLinks);
    Begin
    End Sub;
    
    Public Sub OnAfterApplyCustomObject(Resolver: ICustomObjectResolver);
    Begin
    End Sub;
End Class;

See also:

IMetabaseUpdateProgress