Changing version is very slow

774
5
05-13-2014 04:53 AM
SanajyJadhav
Occasional Contributor II
Hello,

I am changing the version in the ArcMap by code and updating the feature classes of all layers/ standalone tables. This way they point to the data on the new version.

I have referred the code at this URL :
http://edndoc.esri.com/arcobjects/8.3/Samples/ArcMap/Versioning/Change%20Current%20Version%20in%20Ar...

Now everything is fine however the performance is very bad. It is taking a lot of time,10-12 seconds when I do this for the first time. After that, it takes very less time may be 3-4 seconds.

I am using ArcGIS 10.2.1.

So any help on this issue is highly appreciated. If anybody points me in the right directions for finding the cause behind this, it will be very helpful.

It seems that the problematic code is the function, ChangeFeatureLayers() in that code. This method consumes the largest time of the total time.

Thanks,
S.
0 Kudos
5 Replies
by Anonymous User
Not applicable
Sanajy,

Try using IChangeDatabaseVersion instead. It replaces all that code and might be faster.
0 Kudos
SanajyJadhav
Occasional Contributor II
Thanks Sean for your help.

I tried your suggestion but nothing is happening. I get the zero as the count in ISet as a return type of the IChangeDatabaseVersion::Execute. I am trying to figure out what is happening but no luck so far. Below is my code.

 private void ChangeVersionNew(ESRI.ArcGIS.ArcMapUI.IMxDocument pMxDoc, IVersion pOldVersion, IVersion pNewVersion)
        {
            try
            {
                IMapAdmin2 pMapAdmin2;

                pNewVersion.RefreshVersion();
                pMapAdmin2 = pMxDoc.FocusMap as IMapAdmin2;

                IChangeDatabaseVersion pChangeDatabaseVersion = new ChangeDatabaseVersionClass();

                ISet pSet = pChangeDatabaseVersion.Execute(pOldVersion, pNewVersion, pMxDoc.FocusMap as IBasicMap);
                pMapAdmin2.FireChangeVersion(pOldVersion, pNewVersion);

                IActiveView pActiveView = pMxDoc.FocusMap as IActiveView;
                pActiveView.Refresh();
                pMxDoc.UpdateContents();
                pNewVersion.RefreshVersion();
                return;
            }
            catch (Exception ex)
            {
            }
        }


Can you please have a look at it and let me know what is wrong with this code please?

Appreciate your help.

Thanks,
Sanjay.
0 Kudos
by Anonymous User
Not applicable
Hi Sanjay,

Here's a simple example up to the execute method, with no error checking.

    protected override void OnClick()
    {  
      //change version from current to something else

      //get the focus map
      IBasicMap basicMap = ArcMap.Document.FocusMap as IBasicMap;

      //get the current version from the first layer
      IFeatureLayer featLayer = basicMap.get_Layer(0) as IFeatureLayer;
      IDataset dataSet = featLayer.FeatureClass as IDataset;
      IVersion currentVersion = dataSet.Workspace as IVersion;

      //find the target version by name
      IVersionedWorkspace versionedWorkspace = dataSet.Workspace as IVersionedWorkspace;
      IVersion targetVersion = versionedWorkspace.FindVersion("edit1");

      //change the version
      IChangeDatabaseVersion cdv = new ChangeDatabaseVersionClass();
      ISet resultSet = cdv.Execute(currentVersion, targetVersion, basicMap);
    }


Im changing from 'default' version to 'edit1' for 3 layers and ISet.count is returning 3. The toc updates itself but the map or layers will need a refresh. I would get less than three if layers other than the first were pointing to a different version.
Is your pOldVersion correct that you know of?
0 Kudos
SanajyJadhav
Occasional Contributor II
Sean,

Thanks for the reply and the code.

The approach looks the same to what I have been trying. I will test this code and put the outcome here.

Appreciate your help.

Thanks,
S.
0 Kudos
SanajyJadhav
Occasional Contributor II
Sean,

It worked. I took your code and modified it.

Appreciate your help.

S.
0 Kudos