Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to programatically stop/abort/undo an edit operation inside a ArcSDE environment. My environment is currently Oracle, ArcSDE 9.3.1 and in our custom code (I inherited a large ugly portion of a system) the developers do use StartEditing/StartEditOperation and StopEditing/StopEditOperation workflow, but they ONLY use IWorkspaceEdit interface and not Imultiversion interface.

Unfortunately, out database is NOT versioned and all edits done with ArcMap are done by uncheking the option of Undo/Redo - hence, all my undos fails (COM Exception).

I'm trying to capture a OnDeleteEvent and inside it, I check for a certain condition, and then I call AbortOperation, but the operation is not aborted. I need to stop the whole edit session and ask to not save to "rollback" my edits. This consistent with ESRI docs.

My guess here is, the delete already happened and commited to the database? If yes, what is an strategy to not allow this certain edit to happen? There are some other scenarios that I need to cancel the edit operation. I know that IEditEvents2 has a BeforeStopOperation event, but ESRI explicitely tells us not to call AbortOperation inside these events.

There are also other problems with this setup: I check for all edits on a stopEditOperation and generate some notifications with it. All edits come to me as empty. THis might have something to do with it?

Please, help?

Thanks guys!

Exemple code (onDeleteEvent):

    void events_OnDelete(IObject obj)
    {
        ITable table = null;
        IDataset dataset = obj.Table as IDataset;

        IFeatureWorkspace workspace = dataset.Workspace as IFeatureWorkspace;
        IWorkspaceEdit edit = workspace as IWorkspaceEdit;

        edit.EnableUndoRedo();

        IQueryFilter filter = new QueryFilterClass();

        try
        {
            foreach (string s in VariousTables())
            {
                table = workspace.OpenTable(s);

                if (s.Contains("vertex"))
                    filter.WhereClause = "clause A";
                else
                    filter.WhereClause = "clause B";

                if (table.RowCount(filter) > 0)
                {
                    edit.AbortEditOperation(); --> this still deletes the point
                    // edit.UndoEditOperation() --> this breaks, as the workspace does not support Undos
                    break;
                }
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show("ErroR",ex);
        }
    }
share|improve this question
    
in a versioned db there are tables called add, delete, and update. Without these and the db managing them all edits go directly to "default". The only way around this without using versioning in sde is to build your own in the db. Oracle is capable of this. SDE is simply using the tables, triggers, and permissions already built into the db. But for me I am not. I'll use sde versioning. –  Brad Nesom Apr 5 '11 at 15:48
    
Thanks for the opinion Brad. The issue is that there is a rather big ammount of code, small period of time and some features that depend on this to be developed :(. –  George Apr 5 '11 at 16:30
    
Too bad that there's not an OnBeforeDelete. My guess is that you're getting the event too far along in the process to prevent it. Perhaps somewhere higher in the event chain would prove useful? –  Michael Todd Apr 5 '11 at 17:13
1  
Does this help: "If you are using the OnCreate, OnDelete or OnChange methods in a class extension to validate edit operations, you should not call AbortEditOperation on the workspace if your logic indicates that the edit operation is invalid. Instead, raise an error which will be propagated to the application that is performing the edit on the class." From here. –  Michael Todd Apr 5 '11 at 17:31
    
Yeap Todd it does help! i'll try that. You might want to convert your comment to an answer so you can receive the proper thanks! –  George Apr 6 '11 at 12:49

2 Answers 2

up vote 3 down vote accepted

According to the documentation here, you need to raise an error rather than using AbortEditOperation when you want to cancel an edit in OnDelete.

If you are using the OnCreate, OnDelete or OnChange methods in a class extension to validate edit operations, you should not call AbortEditOperation on the workspace if your logic indicates that the edit operation is invalid. Instead, raise an error which will be propagated to the application that is performing the edit on the class.

share|improve this answer

A few notes:

Take out the following line

EnableUndoRedo

It does nothing at this point since it is used only during the internal implementation of startediting to figure out how it needs to generate its own internal state tree during versioned editing.

You are using non-versioned (aka short transaction) editing. Throwing E_FAIL as Todd suggested will work, however I would be careful with calling Search on the same table that you want to potentially abort. Why? Certain operations (like Search) have to flush before they can give you accurate results.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.