Reconcile and Post through C#.Net

489
0
08-01-2011 05:31 AM
PaulRichards
New Contributor
Hi,
I am trying to update the feature class attributes which is inside a geometric network along with FMAutoUpdaters enabled.  I've created a version to edit the session (C#) and then disabled the AutoUpdaters for performing the edits.  After setting all the new values to the feature class, I am trying to Reconcile it and Post.

Reconciling is executing without any error, When I try to check for .CanPost() method, it is returning false.  I am using the below code...

private bool PostVersion(IFeatureWorkspace pWorkSpace, string strVersionName)
        {
            IVersionedWorkspace pVWSpace = null;
            //IVersionEdit pVSEdit = null;
            IVersionEdit3 pVSEdit = null;
            IVersion pVersion = null;
            IWorkspaceEdit pWSEdit = null;

            try
            {
                pVWSpace = (IVersionedWorkspace)pWorkSpace; //Get the current versioned workspace
                pVersion = (IVersion)pVWSpace.FindVersion(strVersionName);
                string sParentVersionName = null;
                pVWSpace = (IVersionedWorkspace)DoStartEditing(pWorkSpace);
                pVSEdit = (IVersionEdit3)pVWSpace;
                if (pVersion.HasParent())
                {
                    sParentVersionName = pVersion.VersionInfo.Parent.VersionName;
                }
                else { return false; }

                if ((sParentVersionName != null))
                {
                    pWSEdit = (IWorkspaceEdit)pWorkSpace;
                    pWSEdit.StopEditOperation();

                    //Perform the Reconcile
                    if (pVSEdit.Reconcile(sParentVersionName))
                    {
                        //If conflicts are detected, abort operation
                        //pVSEdit.AbortOperation();
                        return false;
                    }
                    else
                    {
                        pVersion = pVSEdit.StartEditingVersion;
                        if (pVSEdit.CanPost())
                        {
                            pVSEdit.Post(sParentVersionName);
                        }
                    }
                }
                else { return false; }
                return true;
            }
            catch (Exception ex)
            {
                if (ex.Message == System.Configuration.ConfigurationManager.AppSettings["ERR_VERSION_EXIST"].ToString())
                {
                    return false;
                }
                ErrorLog.WriteErrorLog("In clsSynchronizeAboveGround.cs inside PostVersion :" + ex.Message.ToString());
            }
            finally
            {
                DoStopEditing(pWorkSpace);
                GC.Collect();
            }
            return false;
        }

Any help???

Thanks,
~Paul
0 Kudos
0 Replies