jasontroebuck

IConflictsWindow3 not seeing version reconciliation conflicts

Discussion created by jasontroebuck on Nov 9, 2012
We are working on a reconcile and post add-in for one of our departments.  I'm able to successfully complete the task if there are no conflicts or if I specify which version 'wins'.  We would like to utilize the integrated ArcMap functionality for conflict display and resolution.

Unfortunately, when trying to display the conflict window, I'm having issues.  First of all, the conflict window does not specify that there are any conflict classes even though the IVersionEdit4 object specifies there are and the reconcile result is 'true'.  Secondly, if I try to display the conflict window anyway, the window opens and ArcMap crashes--even if I surround the code in a try block.

I'm open to suggestions.  I am not particularly interested in manually finding the sources of the conflict when the functionality is there to accomplish the task in ArcMap natively and the code is exposed in ArcObjects to accomplish the task.

Am I missing something? Do I need to somehow assign which class the conflict is to the window?

Here's the code in question:
bool ReconcileToDefault(Version ToReconcile, out bool? hadConflicts)
        {
            ChangeDataSourceToDefault(ToReconcile); //changes datasources in map document to default version to prevent lock issues
            hadConflicts = null;
            IVersionedWorkspace wkspc = (IVersionedWorkspace)DBConnect.ConnectToDB("sde.DEFAULT", true);
            if (wkspc == null) return false;
            IVersion Reconcile = wkspc.FindVersion(ToReconcile.name);
            //EventListener evtListener = new EventListener(Reconcile);
            IMultiuserWorkspaceEdit muWorkspaceEdit = (IMultiuserWorkspaceEdit)Reconcile;
            IWorkspaceEdit workspaceEdit = (IWorkspaceEdit)Reconcile;
            IVersionEdit4 versionEdit = (IVersionEdit4)muWorkspaceEdit;
            muWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);
            workspaceEdit.StartEditOperation();
            //Open the conflict resolution window. (ArcMap bombs out here, so I'm trying a different way)
            //if (cWin == null)
            //{
            //    IEditor editor = (IEditor)ArcMap.Application.FindExtensionByCLSID(new UID() { Value = "esriEditor.Editor" });
            //    cWin = (IConflictsWindow3)editor.FindExtension(new UID() { Value = "esriEditor.ConflictsWindow" });
            //    cWin.Reset();
            //    cWin.Visible = true;
            //}
            hadConflicts = versionEdit.Reconcile4("sde.DEFAULT", false, false, false, true); //I set acquire locks to true if I'm actually posting.
            if (hadConflicts == true)
            {
                versionEdit.ConflictClasses.Reset();
                var cl = ConflictResolutionDialog.CurrentClass; //variable is null with current database state
                IConflictClass first = versionEdit.ConflictClasses.Next(); //variable is a valid IConflictClass with current database state
                //MessageBox.Show(ConflictResolutionDialog.HasConflicts().ToString()); //displays false
                //MessageBox.Show(String.Format("Had {0} Conflicts.",ConflictResolutionDialog.ClassCount)); //conflict count = 0
                //ConflictResolutionDialog.Visible = true; //causes arcmap to crash
            }
            //versionEdit.Post("sde.DEFAULT"); //works just fine
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(false);//generally set this to true if I post
            return true;
        }




Thanks for your attention,

Jason Roebuck
GIS Programmer Analyst, City of Auburn, Alabama
jroebuck@auburnalabama.org

Outcomes