PrepareC(Context: IMetabaseUpdateContext);
PrepareC(Context: Prognoz.Platform.Interop.Metabase.IMetabaseUpdateContext);
Context. Additional settings of the update object.
The PrepareC method checks the correctness of update considering the additional settings.
The correspondence of object parameters in the update and respective objects in the repository is checked when executing the method. Objects in the update are assigned the ApplyState property.
NOTE. The ApplyState property is set only for update objects which correspond to the repository objects. The PrepareC method is automatically called after calling the ApplyEx method, before updating objects. The OnBeforeApplyUpdate custom event can be used to check objects readiness for updating.
If the Context parameter is set to Null, the verification is performed without additional settings.
Executing the example requires the C:\Update.pefx update file and an object with the BD2 identifier in the repository. Add a link to the Metabase system assembly.
Sub UserProc;
Var
MB: IMetabase;
MU: IMetabaseUpdate;
Root: IMetabaseUpdateFolderNode;
Node: IMetabaseUpdateNode;
ObjectNode: IMetabaseUpdateObjectNode;
i: Integer;
State: IMetabaseUpdateObjectApplyState;
UpdateCxt: IMetabaseUpdateContext;
NewObject: IMetabaseObject;
Begin
MB := MetabaseClass.Active;
MU := MB.CreateUpdate;
MU.LoadFromFileNF("C:\Update.pefx");
UpdateCxt := MU.CreateUpdateContext;
NewObject := MB.ItemById("BD2").Bind As IMetabaseObject;
UpdateCxt.RegisterIdChange(NewObject.ClassId, "BD1", "BD2", NewObject);
MU.PrepareC(UpdateCxt);
Root := MU.RootFolder;
For i := 0 To Root.Count - 1 Do
Node := Root.Item(i);
If Node.NodeType = MetabaseUpdateNodeType.Object Then
ObjectNode := Node As IMetabaseUpdateObjectNode;
State := ObjectNode.ApplyState;
Select Case State.State
Case MetabaseUpdateObjectApplyState.CreateNew:
Debug.WriteLine("Update object: " + ObjectNode.ObjectId + "; Status: Creating a new one");
Case MetabaseUpdateObjectApplyState.EditExisting:
Debug.WriteLine("Update object: " + ObjectNode.ObjectId + "; Status: Updating an existing one.");
Case MetabaseUpdateObjectApplyState.Conflict Or MetabaseUpdateObjectApplyState.ConflictKey:
Debug.WriteLine("Update object: " + ObjectNode.ObjectId + "; Status: Conflict. The object with the same key already exists.");
Case MetabaseUpdateObjectApplyState.Conflict Or MetabaseUpdateObjectApplyState.ConflictId:
Debug.WriteLine("Update object: " + ObjectNode.ObjectId + "; Status: Conflict. The object with the same identifier already exists.");
Case MetabaseUpdateObjectApplyState.Conflict Or MetabaseUpdateObjectApplyState.ConflictClassId:
Debug.WriteLine("Update object: " + ObjectNode.ObjectId + "; Status: Conflict.The existing object has another class.");
Case MetabaseUpdateObjectApplyState.Conflict Or MetabaseUpdateObjectApplyState.ConflictObjectNotFound:
Debug.WriteLine("Update object: " + ObjectNode.ObjectId + "; Status: Conflict. The repository object which has the Update Only type.");
Case MetabaseUpdateObjectApplyState.Conflict Or MetabaseUpdateObjectApplyState.ConflictMissingMetadata:
Debug.WriteLine("Update object: " + ObjectNode.ObjectId + "; Status: Conflict. The update does not contain the metadata for creating the object.");
End Select;
End If;
End For;
End Sub UserProc;
After executing the example the Update.pefx file is loaded and verified considering possible overriding of the reference of the updated object to the object with the BD2 identifier of the consumer repository. The state of readiness for updating is displayed in a development environment console for the objects, that are in the root folder of the update, and for corresponding repository objects.
See also: