IMetabaseUpdateProgress.OnBeforeCustomObjectSaveToPef

Syntax

OnBeforeCustomObjectSaveToPef(Resolver: ICustomObjectResolver);

Parameters

Resolver. Object that is used to work with a custom object.

Description

The OnBeforeCustomObjectSaveToPef method implements an event that occurs before a 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.

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 the 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
        // Display 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);
        // Display 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, display it in the 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:");
            // Display formed data in the 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 handled. 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.

See also:

IMetabaseUpdateProgress