ArcObjects SDK: How to disable auto-commit mode in non-versioned editing

4747
5
Jump to solution
07-30-2014 07:26 AM
FabianFusholler
New Contributor II

Hi,

does anyone know how to disable auto-commit mode in non-versioned editing environment with ArcObjects?

At 10.2.1 there is a new setting available in edit options "Automatically save changes after each edit". Per default this option is activated. So any change during an edit session is committed immediately.

See ArcGIS Help 10.2 - Configuring an ArcMap edit session to perform nonversioned edits

A bug related to this option is reported, see NIM098991 - The option to 'Automatically save changes after ea..

I did neither find any interface or property in ArcObjects SDK nor any registry key to set this option.

Any suggestions or experiences?

Thanks.

0 Kudos
1 Solution

Accepted Solutions
FabianFusholler
New Contributor II

Meanwhile i've got a response from ESRI:

As this functionality is newly introduced in ArcGIS 10.2.1, it hasn't been exposed to ArcObjects for development yet, and there is no individual interface/method to deal with this function.

Nevertheless, as this bug has already been  fixed in ArcGIS 10.3, my hope is that there will be some interface to deal with.

View solution in original post

0 Kudos
5 Replies
FabianFusholler
New Contributor II

Meanwhile i've got a response from ESRI:

As this functionality is newly introduced in ArcGIS 10.2.1, it hasn't been exposed to ArcObjects for development yet, and there is no individual interface/method to deal with this function.

Nevertheless, as this bug has already been  fixed in ArcGIS 10.3, my hope is that there will be some interface to deal with.

0 Kudos
FabianFusholler
New Contributor II

There only workarounds to handle this bug I can imaging are both about automating GUI by doing the clicks for you.

Anyone who is familar with AutoHotKey (http://www.autohotkey.com) could try to get a macro going. Let it open the edit options dialog, selecting versioning tab on its propertysheet and unchecking the two Checkboxes for multiversioning and auto-commit.

With a few nasty hacks it's possible to get another temporary workaound by code. The workaround is about automating GUI by using WinAPI aswell:

1. Ensure "Versioning" tab is focussed in edit options propertysheet when opening edit options dialog: a registry key will do that for you (HKEY_CURRENT_USER\Software\ESRI\Desktop10.2\ArcMap\PropertySheets\EditOptions. Set default key to value=2.

2. Start a new thread perfoming all following steps from step 4 to 5 (because edit options dialog is modal). Thread must begin with a short sleep (about 500ms) to ensure, that edit options dialog is opened when starting GUI automation

3. Execute Command to open edit options dialog: UID "esriEditor.PropertiesCommand" in the main thread. Dialog will appear.

4. Use WinAPI to get handles to the two checkboxes and to the OK button. A good example about how to query handles see here. As mentioned in step 2 this must be done outside the main thread.

5. Performing clicks by sending windows messages WM_LBUTTONDOWN + WM_LBUTTONUP to mutliversioning checkbox, then to auto-commit checkbox and at least to OK-Button.

This workaound ist not very safe and it isn't suitable for production environments. But for development and testing purposes it works for me and saves a lot of time during development.

Hope it helps someone.

0 Kudos
AlpineTech
New Contributor III

I am with you on this, also waiting anxiously for the fix related to the bug and the hooks in the API.  This bug causes data to be to corrupted and is an inconvenience so I hope ESRI has put a high priority on it...

0 Kudos
FelixArnet1
New Contributor II

I also hope that an interface will be provided soon. I did not find anything in ArcGIS 10.3 though.

Meanwhile i created a workaround by saving, editing and reloading the editor.

    public static void EnsureNonAutoCommit(IEditor editor)
    {
      string tempName = Path.Combine(Path.GetTempPath(), "mistraEditor.tmp");
      {
        IBlobStream blobStream = new MemoryBlobStreamClass();
        IStream stream = blobStream;
        ((IPersistStream)editor).Save(stream, 1);
        blobStream.SaveToFile(tempName);
      }
      using (BinaryWriter w = new BinaryWriter(new System.IO.FileStream(tempName, FileMode.Open)))
      {
        w.Seek((int)w.BaseStream.Length - 2, SeekOrigin.Begin);

        // for AutoCommit, the last two bytes are 255
        w.Write(new byte[] { 0, 0 });
      }
      {
        FileStreamClass cStr = new FileStreamClass();
        IFile fi = cStr;
        fi.Open(tempName, esriFilePermission.esriReadOnly);
        IStream str = cStr;
        ((IPersistStream)editor).Load(str);
      }
    }

0 Kudos
by Anonymous User
Not applicable

This property is now exposed in the 10.4 SDK as IEditProperties5.AutoSaveNonVersionedEdit. Its a Boolean with get/set access.