How to react to the saving of an edit session?

1181
4
08-11-2021 08:11 AM
alehmann
New Contributor III

We have the need in our application to maintain some kind of audit tables (these are not audit tables in the classical sense, but conceptually very similar) that contain certain changes to the customer's data. The way we did it in ArcObjects was to subscribe to the IEditEvents_On*** events and handle our own logic in there.

Because we only want to record the state of an object at the end of an edit session, we can't just write our audit data at the end of each edit operation but have to "compress" all the changes that happen in an edit session into one single change.

The problem we're facing is that apparently there are no events to subscribe to for when edits are saved. We can call Project.Current.SaveEditsAsync() - but so can the user via the UI without us knowing. Is there any way to react to the saving of an edit session in a similar way to how we can handle the different stages of an EditOperation (i. e. EditStartedEvent, EditCompletedEvent)?

Tags (2)
0 Kudos
4 Replies
Wolf
by Esri Regular Contributor
Esri Regular Contributor

If you are using an Enterprise Geodatabase you should take a look at this built-in feature:  What is archiving?—ArcGIS Pro | Documentation

 

0 Kudos
CharlesMacleod
Esri Regular Contributor

>>>The problem we're facing is that apparently there are no events to subscribe to for when edits are saved.<<<<

you might find this useful: https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Editing#editcompletedevent 

specifically an args.CompletedType == EditCompletedType.Save

alehmann
New Contributor III

The CompletedType is indeed helpful, thank you! I somehow completely missed that these events are also fired when the edit session changes. I'll have to check the behaviour in the scenario when the user completely disables editing, though. My guess is the edit session is saved completely but I won't have a chance to execute another edit operation to save my audit data.

Is there any chance to react to the saving of an edit session before it's completed? Like the editcompleting event (that specifically refers to an edit operation as far as I can tell).

0 Kudos
CharlesMacleod
Esri Regular Contributor

No, not if u did not initiate the save. In you particular workflow it looks like a separate commit will be required (for the audits).

In general, any event that provides you with an (event args with an) "Operation", allows u to enlist in that ongoing transaction. Off the top of my head I think that's the EditCompleting, Started, and Row events. In all those cases u have access to the EditOperation "in play" - whether u initiated that operation or not.

0 Kudos