LoadFromFile(FileName: String);
FileName. Path and name of the file, from which data of synchronized dictionaries is loaded.
The LoadFromFile method loads data of synchronized dictionaries.
Executing the example requires the MDM repository with the NSI_1 identifier. Data of synchronized dictionaries is stored in the C:\Sinc.rpl file. Add links to the Metabase, Rds, Db system assemblies.
Public Class MyCallback: Object, IRdsMergeCallback
Public Sub OnProgress(Progress: Integer; Total: Integer);
Begin
Debug.WriteLine("Done: " + Progress.ToString + " out of " + Total.ToString);
End Sub OnProgress;
Public Sub OnConflict(LoadElement: IRdsDictionaryElement; CurrentElement: IRdsDictionaryElement);
Begin
Debug.Write("The element has different values: ");
Debug.Write(LoadElement.Name);
Debug.Write(" | ");
Debug.WriteLine(CurrentElement.Name);
End Sub OnConflict;
Public Sub OnBeforeProcess(Var bCancel: Boolean);
Begin
bCancel := False;
End Sub OnBeforeProcess;
Public Sub OnConflictResolve(LoadElement: Integer; CurrentElement: Integer; Var Ignor: Boolean);
Begin
Ignor := True;
End Sub OnConflictResolve;
End Class MyCallback;
Sub UserProc;
Var
MB: IMetabase;
MObj: IMetabaseObject;
NSI: IRdsDatabase;
NSIInst: IRdsDatabaseInstance;
Trans: IConnectionTransaction;
CallBack: MyCallback;
Replic: IRdsReplicator;
Begin
MB := MetabaseClass.Active;
MObj := MB.ItemById("NSI_1").Bind;
NSI := MObj As IRdsDatabase;
NSIInst := NSI.Open(Null);
Trans := NSIInst.DatabaseInstance.Connection.StartTransaction(False);
CallBack := New MyCallback.Create;
Replic := NSIInst.CreateReplicator;
Replic.LoadFromFile("C:\Sinc.rpl");
Replic.Merge(CallBack);
Trans.Commit;
End Sub UserProc;
After executing the UserPr procedure, all the dictionaries in the NSI_1 MDM repository are synchronized. The MyCallback custom class is used to control synchronization process. At the runtime, the console window displays common status of the process and element names with different values in the dictionary and the loaded file. Values from the file are restored for all elements that have different values.
See also: