|Interface to be implemented to monitor changes to elements. More...|
|The interface to write changes in the context of a transaction to elements, XAttributes, and models. More...|
|This interface provides a transaction mechanism for handling changes to persistent elements and models. More...|
The Transaction Manager enables you to save changes, journal transactionable changes during a session, and to organize changes into units called transactions.
Use the Transaction Manager in order to add, save changes to, or to delete elements, XAttributes or models.
Note that the Transaction Manager does not write anything to disk. See DgnFile::ProcessChanges.
Here are a few common patterns:
The element is now persisent in the specified model.
Note that you could make multiple changes to the EditElementHandle before writing to the model.
The XAttribute is now persistent in the element's model.
Or, you could call ITxn::ReplaceXAttributeData to update the persistent XAttribute to store completely different data.
A transaction is defined as a set of changes that are treated as a unit. All changes and deletions are made as part of a transaction. Most transactions are undoable and can be reversed or reinstated as a unit. Undoable transactions support TxnMonitor listeners.
The Transaction Manager implements the ITxnManager interface. This interface has methods to query the current transaction, to register TxnMonitors, and to reverse, cancel, or reinstate transactions.
All changes are made in the context of the current transaction. There is always a current transaction running. You don't have to start or create one. ITxnManager::GetCurrentTxn returns the current transaction.
ITxnManager::CloseCurrentTxn defines a boundary that ends the current transaction and starts a new one. Setting a transaction boundary validates the preceeding changes (ITxnManager::ValidateCurrentTxn). Validating an undoable transaction also notifies TxnMonitor listeners. For an undoable transaction, setting a transaction boundary defines an undo point.
The current transaction implements the ITxn interface. The ITxn inteface provides methods to write changes to elements, XAttributes, and models. The EditElementHandle methods to add, replace, and delete elements turn around and call the appropriate methods on the current transaction.
Here is a simple example of using the transaction manager to add two elements to a model and then close the transaction.
These two adds can now be reversed by calling ITxnManager::ReverseSingleTxn.