1

I am trying to understand Esri example of reconciling and post with C#. Could someone give me some hints or point me in the right direction. The reconcile and post in Arcmap toolbox has edit version and target version as optional. Is a variable in this code related to a sde connection?

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);
   }
}
2
  • Hi exploregis, I do not understand what are you trying to do in your workflow. Probably you can describe what do you need to do.
    – Katah
    Sep 14, 2015 at 7:33
  • Looks close. Couple comments: i) You can only post if( !conflicts && versionEdit.CanPost()) ii) Are you sure targetVersion is in lineage of editVersion ? Feb 18, 2017 at 6:33

1 Answer 1

1

Both IVersion objects that your method has are coming from an IWorkspace instance. How you got the workspace (from a SDE connection, from your map objetc, etc.) I didn't know it. Is is something that occurs before the call to your method...

In ArcMap you can avoid to give an specific version due to you are already in an specific version from a Workspace, so ArcMap is getting such version as edit version, and then using the parent version as target version. You can modify that, but ArcMap is giving you like a "predefine" parameters for your post and reconcile.

Hint 1: I recommend you to read the ESRI Versioning Technical Paper. That document is a little older, but will give you a clear picture about versioning in a ESRI environment.

Hint 2: Always refresh the version IVersion.Refresh() before starting and edit operation. That will avoid to get a previous state of the database, so getting the last state will avoid in most cases future problems when trying to reconcile/post.

1
  • Thanks for the help. It gave me something to work with. I haven't used this site enough to get above the 15 points needed for a up vote for your answer.
    – exploregis
    Sep 15, 2015 at 2:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.