AutoPeriod: 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.
See also: