02.05.2014 Views

CoreandServices.book - Ocean - Schlumberger

CoreandServices.book - Ocean - Schlumberger

CoreandServices.book - Ocean - Schlumberger

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Data Management<br />

The ITransaction interface is defined as:<br />

public interface ITransaction : IDisposable<br />

{<br />

object Context { get; }<br />

ITransactionManager Manager { get; }<br />

void Abandon ();<br />

void Abandon (out Collection exceptions);<br />

void Commit ();<br />

void Commit (out Collection exceptions);<br />

void Lock (params object[ ] objects);<br />

void LockCollection (IEnumerable objectCollection);<br />

bool TryLock (params object [ ] objects);<br />

bool TryLockCollection (IEnumerable objectCollection);<br />

event EventHandler ObjectLocked;<br />

event EventHandler TransactionAbandoned;<br />

event EventHandler TransactionAbandoning;<br />

event EventHandler TransactionCommitted;<br />

event EventHandler TransactionCommitting;<br />

}<br />

Once a transaction has been created and the reference to the ITransaction object has<br />

been returned, you can perform the methods of ITransaction according to your needs<br />

and some basic rules. The rules are:<br />

• Objects that are being updated or deleted must be locked first. If it is not locked and an<br />

attempt is made to modify the object, then a TransactionException exception will<br />

be thrown.<br />

• When an object is going to be created as the child of another object, then the parent<br />

object must be locked before the creation.<br />

• When an object is created inside a transaction, it is implicitly locked. For example, if you<br />

create an object and then want to modify its name, you do not have to lock it. The lock<br />

you placed on its parent before the creation carries through to the new child.<br />

Any object can be locked in a transaction. It is the responsibility of the<br />

ITransactionManager and ITransaction implementations in the product family to<br />

manage the mechanics of locking objects.<br />

<strong>Schlumberger</strong> Private<br />

<strong>Ocean</strong> Core 3-61

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!