Check For Open Edit Session On A Feature Class

2686
1
06-22-2012 03:24 PM
by Anonymous User
Not applicable
Original User: jflorey

Hi All,

I hope someone can help.  I've been searching the forums most of the afternoon without success.  I am writing a stand alone application in C# and ArcObjects that updates an asset management system from a single feature class in a geodatabase, and a single feature class in a geodatabase from an asset management system.  One of the requirements of the application is that the user can have multiple instances running concurrently.  Users are not supposed to run multiple instances against the same source feature class or SDE version, but I have to enforce that restriction by checking to see if the feature class source is being edited.  For SDE geodatabases, I have implemented a check of the IVersionLockInfo and that works.  For personal geodatabases, I have a not very elegant solution that simply tries to call IWorkspaceEdit StartEditing and then catches the error when it fails.  I have not found a solution for either shapefiles or file geodatabases.  StartEditing will not throw an error, even when I have started editing the same shapefile or file geodatabase inside ArcMap.  There must be a way to find out because if I open two maps on different machines, point them to the same data source and start editing on one machine, when I try to start editing on the other machine it fails, and tells me the data is already locked by another user.  If I fire up my application and try to start editing in ArcMap against the same data source, that attempt to start editing will also fail.  I've tried checking both IWorkspaceEditor.IsBeingEdited and IDatasetEdit.IsBeingEdited but neither property returns true even when I know I've started editing the geodatabase inside ArcMap.  I've also tried checking the ISchemaLock but that returns locks for all users, even if the user has not started an edit session.  Any assistance will be greatly appreciated.

Regards,
Jay Florey
Software Engineer
Reply
0 Kudos
1 Reply
by Anonymous User
Not applicable
Original User: jflorey

Hi All,

A new wrinkle to this problem.  ArcMap will still allow a user to edit features in a feature class, even when my process is running.  So here is what I have tested:
Start editing in ArcMap and start my process against the same version:  My process fails because it can't acquire a lock.
Start my process, start a second run of my process against the same version:  My process fails because it can't acquire a lock.
Start my process, start editing in ArcMap against the same version of the data:  ArcMap lets the edit session start and successfully saves changes to the data.
Here is the code that my process uses to acquire the version lock:

<snip> Code that checks for existing locks
// _args.GisWorkspace is an IWorkspace object

                    versionedEdit = _args.GisWorkspace as IMultiuserWorkspaceEdit;
                    if (!Equals(null, versionedEdit))
                    {
                        if (versionedEdit.SupportsMultiuserEditSessionMode(esriMultiuserEditSessionMode.esriMESMVersioned))
                            versionedEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMVersioned);
                        else
                            versionedEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMNonVersioned);
                    }

<snip> the rest of the process

Thanks again for any help provided.

Regards,
Jay Florey
Software Engineer
Reply
0 Kudos