AutoPeriod: IRubricatorAutoPeriod;
AutoPeriod: Prognoz.Platform.Interop.Cubes.IRubricatorAutoPeriod;
The AutoPeriod property returns parameters of time series data copy period.
By default the start/end of copying matches the start/end of data.
Executing the example requires that the repository contains a time series database with the TSDB identifier, a time series database with the DB_MSSQL identifier and a folder with the TSDB_COPY_FOLDER identifier.
Add links to the Cubes, Db and Metabase system assemblies.
Sub UserProc;
Var
mb: IMetabase;
RubUpdateEx: ICubeMetaUpdateEx;
Rub: IRubricator;
Progress: IMetabaseUpdateProgress;
CrInfo: IMetabaseObjectCreateInfo;
ExpPeriod: IRubricatorAutoPeriod;
ExpPeriodDate: IRubricatorAutoPeriodDate;
Begin
// Get current repository
mb := MetabaseClass.Active;
// Create an object to copy time series database
RubUpdateEx := New CubeMetaUpdateClass.Create As ICubeMetaUpdateEx;
// Get time series database
Rub := mb.ItemById("TSDB").Bind As IRubricator;
// Determine copying time series database
RubUpdateEx.Rubricator := Rub;
// Specify that copying is executed to the current repository
RubUpdateEx.Metabase := Mb;
// Get parameters of created time series database
CrInfo := RubUpdateEx.CreateInfo;
// Specify the folder, in which it will be created
CrInfo.Parent := mb.ItemById("TSDB_COPY_FOLDER");
// Specify name and identifier of new time series database
CrInfo.Id := Mb.GenerateId("TSDB_COPY");
CrInfo.Name := "Time series database (copy)";
// Determine copying periods of time series
ExpPeriod := RubUpdateEx.AutoPeriod;
// Set period start: data start shifted by one point forward
ExpPeriodDate := ExpPeriod.Start;
ExpPeriodDate.AutoDateType := RubricatorAutoDateType.DateStart;
ExpPeriodDate.Offset := 1;
// Set period end: data end shifted by one point back
ExpPeriodDate := ExpPeriod.End_;
ExpPeriodDate.AutoDateType := RubricatorAutoDateType.DateEnd;
ExpPeriodDate.Offset := -1;
// Specify MDM repository that will be used
// by copied time series database
RubUpdateEx.RdsDatabase := Rub.Database;
// Specify a repository object - Database, which settings will be used
// by copied time series database
RubUpdateEx.Database := MB.ItemById("DB_MSSQL").Bind As IDatabase;
// Determine that data will be copied
RubUpdateEx.CopyData := True;
// Determine that time series database nested objects will be copied
RubUpdateEx.CopyExtraObjects := True;
// Determine that objects will be copied and mapped
// by unique indexes used for creating a selection
RubUpdateEx.RemapBySelectionIndex := True;
// Set revision name in copied time series database
RubUpdateEx.NewRevisionName := "The entire 'TSDB' database is copied";
// Create an object that implements events that occur during copying
Progress := New MyUpdateProgress.Create;
// Copy
RubUpdateEx.Apply(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 copy 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_COPY_FOLDER folder will have a copy of the TSDB time series database data.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Cubes;
Imports Prognoz.Platform.Interop.Db;
…
Public Shared Sub Main(Params: StartParams);
Var
mb: IMetabase;
RubUpdateEx: ICubeMetaUpdateEx;
Rub: IRubricator;
Progress: IMetabaseUpdateProgress;
CrInfo: IMetabaseObjectCreateInfo;
ExpPeriod: IRubricatorAutoPeriod;
ExpPeriodDate: IRubricatorAutoPeriodDate;
Begin
// Get current repository
mb := Params.Metabase;
// Create a copy object of time series database
RubUpdateEx := New CubeMetaUpdateClass.Create() As ICubeMetaUpdateEx;
// Get time series database
Rub := mb.ItemById["TSDB"].Bind() As IRubricator;
// Determine copied time series database
RubUpdateEx.Rubricator := Rub;
// Determine that copying is executed to the current repository
RubUpdateEx.Metabase := Mb;
// Get parameters of created time series database
CrInfo := RubUpdateEx.CreateInfo;
// Specify the folder, in which it will be created
CrInfo.Parent := mb.ItemById["TSDB_COPY_FOLDER"];
// Specify name and identifier of new time series database
CrInfo.Id := Mb.GenerateId("TSDB_COPY", 0);
CrInfo.Name := "Time series database (copy)";
// Determine periods of time series copying
ExpPeriod := RubUpdateEx.AutoPeriod;
// Set period start: data start shifted by one point forward
ExpPeriodDate := ExpPeriod.Start;
ExpPeriodDate.AutoDateType := RubricatorAutoDateType.radtDateStart;
ExpPeriodDate.Offset := 1;
// Set period end: data end shifted by one point back
ExpPeriodDate := ExpPeriod.@End;
ExpPeriodDate.AutoDateType := RubricatorAutoDateType.radtDateEnd;
ExpPeriodDate.Offset := -1;
// Specify MDM repository that will be used
// by copied time series database
RubUpdateEx.RdsDatabase := Rub.Database;
// Specify a repository object - Database, which settings will be used
// by copied time series database
RubUpdateEx.Database := MB.ItemById["DB_MSSQL"].Bind() As IDatabase;
// Determine that data will be copied
RubUpdateEx.CopyData := True;
// Specify that nested objects of time series database will be copied
RubUpdateEx.CopyExtraObjects := True;
// Determine that objects will be copied and mapped
// by unique indexes used for creating a selection
RubUpdateEx.RemapBySelectionIndex := True;
// Set revision name in copied time series database
RubUpdateEx.NewRevisionName := "The entire 'TSDB' database is copied";
// Create an object that implements events that occur during copying
Progress := New MyUpdateProgress.Create();
// Copy
RubUpdateEx.Apply(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: