IRdsDictionaryInstance.CreateBatch

Fore Syntax

CreateBatch(BatchType: RdsDictionaryBatchType): IRdsDictionaryBatch;

Fore.NET Syntax

CreateBatch(BatchType: Prognoz.Platform.Interop.Rds.RdsDictionaryBatchType): Prognoz.Platform.Interop.Rds.IRdsDictionaryBatch;

Parameters

BatchType. Type of elements batch.

Description

The CreateBatch method creates elements batch of the MDM dictionary.

Comments

The batch is used to execute any operations over all elements in the batch simultaneously.

Fore Example

Executing the example requires that the repository contains a version table MDM dictionary with the DICT identifier.

Add links to the Metabase, Rds system assemblies.

Sub UserProc;
Var
    mb: IMetabase;
    RdsDictObj: IMetabaseObject;
    DictInst: IRdsDictionaryInstance;
    DictBatch: IRdsDictionaryBatch;
    DelBatch: IRdsDictionaryBatchDelete;
Begin
    // Get current repository
    mb := MetabaseClass.Active;
    // Get dictionary
    RdsDictObj := mb.ItemById("DICT").Edit;
    DictInst := RdsDictObj.Open(NullAs IRdsDictionaryInstance;
    // Create a batch for deleting elements
    DictBatch := DictInst.CreateBatch(RdsDictionaryBatchType.Delete);
    If DictBatch.BatchType = RdsDictionaryBatchType.Delete Then
        DelBatch := DictBatch As IRdsDictionaryBatchDelete;
        // Set the end date of value validity for elements
        DelBatch.CloseDate := DateTime.Parse("30.12.2999");
    End If;
    // Delete elements and display result in the console window
    Debug.WriteLine("Number of processed elements: " + DelBatch.Execute.ToString);
    Debug.WriteLine(Number of deleted elements:  + DelBatch.Count.ToString);
    RdsDictObj.Save;
End Sub UserProc;

After executing the example a batch for deleting elements is created, the end date of value validity for elements is set to 30.12.2999. The number of processed and deleted elements is displayed in the console window.

Fore.NET Example

The requirements and result of the Fore.NET Example execution match with those in the Fore Example.

Imports Prognoz.Platform.Interop.Rds;

Public Shared Sub Main(Params: StartParams);
Var
    mb: IMetabase;
    RdsDictObj: IMetabaseObject;
    DictInst: IRdsDictionaryInstance;
    DictBatch: IRdsDictionaryBatch;
    DelBatch: IRdsDictionaryBatchDelete;
Begin
    // Get current repository
    mb := Params.Metabase;
    
// Get dictionary
    RdsDictObj := mb.ItemById["DICT"].Edit();

    DictInst := RdsDictObj.Open(NullAs IRdsDictionaryInstance;
    // Create a batch for deleting elements
    DictBatch := DictInst.CreateBatch(RdsDictionaryBatchType.rdbtDelete);
    If DictBatch.BatchType = RdsDictionaryBatchType.rdbtDelete Then
        DelBatch := DictBatch As IRdsDictionaryBatchDelete;
        // Set the end date of value validity for elements
        DelBatch.CloseDate := DateTime.Parse("30.12.2999");
    End If;
    // Delete elements and display result in the console window
    System.Diagnostics.Debug.WriteLine("Number of processed elements: " + DelBatch.Execute().ToString());
    System.Diagnostics.Debug.WriteLine("Number of deleted elements: " + DelBatch.Count.ToString());
    RdsDictObj.Save();
End Sub;

See also:

IRdsDictionaryInstance