SaveEx(FileName: String; Progress: IMetabaseUpdateProgress);
SaveEx(FileName: string; Progress: Prognoz.Platform.Interop.Metabase.IMetabaseUpdateProgress);
FileName. Name of the file to which the time series database is to be saved.
Progress. Object that implements event occurring on copying.
The SaveEx method copies time series database to file including handling of events that occur during copying.
After executing the example a ZIP archive is created that contains required files with information about time series database and time series data. Specify the path and name of the file together with the ZIP extension as value of the FileName parameter.
Executing the example requires that the repository contains a time series database with the TSDB identifier.
Add links to the Cubes and Metabase system assemblies.
Sub UserProc;
Var
Mb: IMetabase;
RubUpdateEx: ICubeMetaUpdateEx;
Rub: IRubricator;
Progress: MyUpdateProgress;
Begin
// Get current repository
Mb := MetabaseClass.Active;
// Create a copying object
RubUpdateEx := New CubeMetaUpdateClass.Create;
// Get time series database
Rub := Mb.ItemById("TSDB").Bind As IRubricator;
// Determine copying time series database
RubUpdateEx.Rubricator := Rub;
// Create an object that implements events that occur during copying
Progress := New MyUpdateProgress.Create;
// Save to file
RubUpdateEx.SaveEx("C:\Replication.zip", Progress);
End Sub UserProc;
// Class that implements events that occur during copying
Class MyUpdateProgress: UpdateProgress
// Event occurring on copying errors
Sub OnError(Data: IMetabaseUpdateProgressData; Var Ignore: Boolean);
Begin
Debug.WriteLine("Update object copying error '" + Data.Node.Label + "'");
Debug.WriteLine("Error text: " + Data.Error.Message);
If Data.Object <> Null Then
Debug.WriteLine("Error source: " + Data.Object.Id);
Debug.WriteLine("Object key: " + Data.Object.Key.ToString);
End If;
Debug.WriteLine("Object is skipped");
Ignore := True;
End Sub OnError;
End Class MyUpdateProgress;
After executing the example the TSDB time series database is saved to the C:\Replication.zip file. If errors occur on copying, they are displayed in the console window.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Cubes;
…
Public Shared Sub Main(Params: StartParams);
Var
Mb: IMetabase;
RubUpdateEx: ICubeMetaUpdateEx;
Rub: IRubricator;
Progress: MyUpdateProgress;
Begin
// Get current repository
Mb := Params.Metabase;
// Create a copying object
RubUpdateEx := New CubeMetaUpdateClass.Create();
// Get time series database
Rub := Mb.ItemById["TSDB"].Bind() As IRubricator;
// Determine copied time series database
RubUpdateEx.Rubricator := Rub;
// Create an object that implements events that occur during copying
Progress := New MyUpdateProgress.Create();
// Save to file
RubUpdateEx.SaveEx("C:\Replication.zip", Progress);
End Sub;
…
// Class that implements events that occur during copying
Public Class MyUpdateProgress: IMetabaseUpdateProgress
// Event occurring on copying errors
Public Sub OnError(Data: IMetabaseUpdateProgressData; Var Ignore: Boolean);
Begin
System.Diagnostics.Debug.WriteLine("Update object copying error '" + Data.Node.Label + "'");
System.Diagnostics.Debug.WriteLine("Error text: " + Data.Error.Message);
If Data.Object <> Null Then
System.Diagnostics.Debug.WriteLine("Error source: " + Data.Object.Id);
System.Diagnostics.Debug.WriteLine("Object key: " + Data.Object.Key.ToString());
End If;
System.Diagnostics.Debug.WriteLine("Object is skipped");
Ignore := True;
End Sub;
Public Sub OnContext(Context: IMetabaseUpdateContext);
Begin
End Sub;
Public Sub OnProgress(Data: IMetabaseUpdateProgressData);
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 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 OnBeforeCustomObjectSaveToPef(Resolver: ICustomObjectResolver);
Begin
End Sub;
Public Sub OnAfterApplyCustomObject(Resolver: ICustomObjectResolver);
Begin
End Sub;
End Class MyUpdateProgress;
See also: