English

How To: Use ArcObjects to detect conflicts during a geodatabase reconcile operation

Summary

Instructions provided describe how to programmatically detect conflicts found during a reconcile operation using ArcObjects.

Procedure

The following ArcObjects code snippet can be used to detect conflicts that arise during a reconcile operation:

Code (C#):

public void ReconcileandPost(IVersion editVersion, IVersion targetVersion)
{
    IMultiuserWorkspaceEdit muWorkspaceEdit = (IMultiuserWorkspaceEdit)editVersion;
    IWorkspaceEdit workspaceEdit = (IWorkspaceEdit2)editVersion;
    IVersionEdit4 versionEdit = (IVersionEdit4)workspaceEdit;

    if (muWorkspaceEdit.SupportsMultiuserEditSessionMode(esriMultiuserEditSessionMode.esriMESMVersioned))
    {
        muWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);
        //Reconcile with the target version.
        bool conflicts = versionEdit.Reconcile4(targetVersion.VersionName, true, false, false, false);
        if (conflicts) MessageBox.Show(" Conflicts Detected ");
        else MessageBox.Show(" No Conflicts Detected ");
        workspaceEdit.StartEditOperation();
        //Post to the target version.
        if (versionEdit.CanPost()) versionEdit.Post(targetVersion.VersionName);
        workspaceEdit.StopEditOperation();
        workspaceEdit.StopEditing(true);
    }
}
Note that there is an interface called IVersionEdit4, and a method called Reconcile4. This method takes five parameters; the third parameter (a Boolean) allows you to detect conflicts. Once conflicts are detected, you can use the IVersionEdit4.ConflictClasses property to enumerate through each conflict, and handle it programmatically. See the link below to this property.

Related Information