IMetabaseUpdate.SaveToFileNFEx

Syntax

SaveToFileNFEx(FileName: String; Progress: IMetabaseUpdateProgress);

Parameters

FileName. Full path and name of the file, to which the update will be saved.

Progress. Object implementing events occurring on creating an update.

Description

The SaveToFileNFEx method saves the update to the *.pefx file with the ability to track events.

Comments

If event handling is not required, send Null as a value of the Progress parameter.

Example

Executing the example requires that the repository contains a calculation algorithm with the ALGO identifier.

Add links to the Metabase and Xml assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    Update: IMetabaseUpdate;
    UFN: IMetabaseUpdateFolderNode;
    UON: IMetabaseUpdateObjectNode;
    Progress: IMetabaseUpdateProgress;
Begin
    MB := MetabaseClass.Active;
    // Create an update
    Update := Mb.CreateUpdate;
    UFN := Update.RootFolder;
    // Add object to update
    UON := UFN.Add(MetabaseUpdateNodeType.DataObject) As IMetabaseUpdateObjectNode;
    UON.Object := MB.ItemById("ALGO");
    // Create an object to handle events
    Progress := New MyUpdateProgress.Create;
    // Save update to file
    Update.SaveToFileNFEx("D:\Work\Algo.pefx", Progress);
End Sub UserProc;

// Class that implements events that occur during creating an update
Class MyUpdateProgress: UpdateProgress
    // Event that occurs before saving custom objects to file
    Sub OnBeforeCustomObjectSaveToPef(Resolver: ICustomObjectResolver);
    Var
        Refs: IMetabaseCustomObjectReferences;
        Ref: IMetabaseCustomObjectReference;
        XmlVar: Variant;
        XmlDoc: IXmlDomDocument;
        i: Integer;
    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;
        If Refs.Count > 0 Then
            Debug.WriteLine("Object dependencies:");
            Debug.Indent;
            For i := 0 To Refs.Count - 1 Do
                Ref := Refs.Item(i);
                Debug.WriteLine("Object: " + Ref.Object.Name);
                If Not IsNull(Ref.Owner) Then
                    Debug.WriteLine("Owner: " + Ref.Owner.Name)
                End If;
            End For;
            Debug.Unindent;
        End If;
        // 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("Object data:");
            Debug.WriteLine(XmlDoc.xml);
        End If;
    End Sub OnBeforeCustomObjectSaveToPef;
End Class MyUpdateProgress;

After executing the example the new update is created, and a calculation algorithm is added to it. When saving the update to file, the development environment console displays basic information about the object, its dependencies, and object data.

See also:

IMetabaseUpdate