Thursday, October 04, 2007
Posted on Thursday, October 04, 2007 11:02:35 PM (Mountain Daylight Time, UTC-06:00)  Comments [0] | 
Categories: ArcGIS Devt | ArcMap | Geodatabase

We put a lot of business logic into Class Extensions tied in on the OnCreate, OnChange, and OnDelete Object Class Extension events. If an edit violates business logic, it is rolled back and the user is informed about what was wrong. This has been working quite smoothly until today when we started creating our Object Inspectors (see previous post).

What we found was that attribute edits done through our Object Inspector (and consequently ArcDAL) were not respecting the business logic. I dropped some breakpoints into the OnChange event in one of the class extensions, and found that it was not hit when we saved changes in the Object Inspector. Yet, when I opened the table editor I would see the changes, so I knew something was happening. Here's the series of events graphically...

1) Original values in Object Inspector...

original-values

2) District Name updated and saved

update-values

3) Table editor shows the updated name, but OnChange event never fired!

table-editor

4) When I try to edit the District Name via the table editor...

table-editor-change

the OnChange event does fire, and the edit is rolled back because I do not have edit rights to that feature.

table-editor-roll-back

We traced it back to using update cursors. Turns out that updating features via FeatureClass.Update in an edit session does not store changes to the base table until the edit session is saved. Thus, the ObjectClassExtension events do not fire until you "save" the edits and end the session. We need these events to fire as the edits occur so the user is informed when business rules are broken.

The solution was to just change back to using IFeature.Store - which correctly raises the events. This was just 4 simple edits, but we have 25 feature classes in our geodatabase model. Thanks to code-generation, we just made the edits in the templates, and re-generated all the classes.

Comments are closed.