Modeless Rollback() a transaction after Commit()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi:
Here is a question ---
1. Suppose I have a modeless dialog containing the following buttons:
- DoSomethingButton
- RollbackButton to rollback what have been committed by DoSthButton
2. I click DoSomethingButton, in the buttong click event, I raise an external event, which looks like: 3. MakeSomeChangeEvent.Raise().
4. I created a Transaction field, so that this field can be accessed everywhere in my WPF dialog.
5. I instantiate the Transaction field, Start() it, make some changes into my document(like creating a Duct). I must Commit() it before leaving this API context, otherwise Revit pops a warning and rollback all changes automatically. But I don't dispose this Transaction field.
6. I click Rollback button, raise another event which looks like: RollbackEvent.Raise()
7. In the event handler, I called TransactionField.Rollback(). It doesn't work.
I am researching another solution:
- use PostCommand() to post an Undo command.
- use a TransactionGroup to assimilate this DoSomethingTransasction, keep the trans group alive during the whole life of my WPF dialog. Then commit transaction and assimilate it into TransactionGroup. Commit transaction, but not commit the transaction group. In another external event which looks like: RollbackGroupEvent, I rollback this group so as to rollback all smaller transactions in it.
Just wanna have some discussions with everyone. Do you have any experience?
Suppose the above question has been solved,
And then comes a further question:
In a modelss dialog, I have 2 groups of buttons, which do the following things:
- FirstCommitEvent.Raise() and FirstRollbackEvent.Raise()
- SecondCommitEvent.Raise() and SecondRollbackEvent.Raise()
Possible to modeless rollback 2 different transactions? Cuz posting Undo command can only rollback the last transaction(or transaction group), and if I want to Undo more than 1 transaction, I cannot know which is the final Undo one.
After all, wanna talk about my purpose:
I supply a modeless dialog to do a complicated operation which might be composed of many smaller transactions(a transaction can live only inside one API context). During the lifetime of the modeless dialog, user might want to do a basic task, oberve the result and decide what to do next.
Is it possible?