ICubeMetaUpdateEx.AutoPeriod

Fore Syntax

AutoPeriod: IRubricatorAutoPeriod;

Fore.NET Syntax

AutoPeriod: Prognoz.Platform.Interop.Cubes.IRubricatorAutoPeriod;

Description

The AutoPeriod property returns parameters of time series data copy period.

Comments

By default, the start and end of copying matches the start and end of data.

Fore Example

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 a replication object
    RubUpdateEx := New CubeMetaUpdateClass.Create As ICubeMetaUpdateEx;
    // Get time series database
    Rub := mb.ItemById("TSDB").Bind As IRubricator;
    // Specify that the obtained time series database will be replicated
    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 := "Replicated time series database";
    // Specify time series replication periods
    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 replicated time series database
    RubUpdateEx.RdsDatabase := Rub.Database;
    // Specify a repository object - Database, which settings will be used
    // by replicated time series database
    RubUpdateEx.Database := MB.ItemById("DB_MSSQL").Bind As IDatabase;
    // Specify that data is replicated
    RubUpdateEx.CopyData := True;
    // Specify that nested objects of time series database are replicated
    RubUpdateEx.CopyExtraObjects := True;
    // Specify that objects are copied and mapped
    //  by unique indexes used for creating a selection
    RubUpdateEx.RemapBySelectionIndex := True;
    // Set revision name in copied time series database
    RubUpdateEx.NewRevisionName := "Replication of the entire 'TSDB' database";
    // Create an object that implements events occurring during copying
    Progress := New MyUpdateProgress.Create;
    // Replicate
    RubUpdateEx.Apply(Progress);
End Sub UserProc;

// Class that implements events that occur during replication
Class MyUpdateProgress: UpdateProgress
    // Event occurring on replication 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_COPY_FOLDER folder will have a copy of the TSDB time series database data.

Fore.NET Example

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 replication object
    RubUpdateEx := New CubeMetaUpdateClass.Create() As ICubeMetaUpdateEx;
    // Get time series database
    Rub := mb.ItemById["TSDB"].Bind() As IRubricator;
    // Specify that the obtained time series database will be replicated
    RubUpdateEx.Rubricator := Rub;
    // Specify that copying is executed into 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 := "Replicated time series database";
    // Specify 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 replicated time series database
    RubUpdateEx.RdsDatabase := Rub.Database;
    // Specify a repository object - Database, which settings will be used
    // by replicated time series database
    RubUpdateEx.Database := MB.ItemById["DB_MSSQL"].Bind() As IDatabase;
    // Specify that data will be copied
    RubUpdateEx.CopyData := True;
    // Specify that nested objects of time series database will be copied
    RubUpdateEx.CopyExtraObjects := True;
    // Specify that objects are 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 occurring during copying
    Progress := New MyUpdateProgress.Create();
    // Replicate
    RubUpdateEx.Apply(Progress);
End Sub;

// Class that implements events that occur during replication
Public Class MyUpdateProgress: IMetabaseUpdateProgress
    // Event that occurs 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:

ICubeMetaUpdateEx