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 following code is a simple example of the use of the IDataSourceManager.<br />

// Get the product family installed DataSourceManager<br />

IDataSourceManager dsm = DataManager.DataSourceManager;<br />

// Get the registered DataSources<br />

ReadOnlyCollection sources = dsm.Sources;<br />

// Add a new source, MockDataSource is defined earlier<br />

MockDataSource mds = new MockDataSource(“MyMockSource”);<br />

//MockDataSource defined earlier<br />

dsm.AddSource(mds);<br />

// Get the data source<br />

IDataSource dataSource = dsm.GetSource(“MyMockSource”);<br />

// Remove the data source<br />

dsm.RemoveSource(dataSource);<br />

Transactions<br />

Transactions are required when data is being created, updated, or deleted. Transactions<br />

make changes to data more efficient by grouping them so that fewer events are received.<br />

For example, if you modify the values of data in a well log without a transaction, then you<br />

will receive an event for each log sample you change. If each event causes the log to be<br />

redrawn in your window, then your performance will suffer due to the repeated refreshing<br />

of the window. However, if you enclose the code that updates the log samples in a<br />

transaction, then only one event will be received at the end of all the log sample changes<br />

when the transaction is committed. <strong>Ocean</strong> Petrel will not permit the modification of an<br />

internally hosted domain object outside a transaction and will throw an exception if it is<br />

attempted.<br />

Working with transactions requires a few simple steps. These include:<br />

1 Creating the transaction<br />

2 Locking the appropriate data<br />

3 Modifying the data<br />

4 Committing the transaction (may mean different things depending on the data<br />

persistence mechanism)<br />

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

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

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

Saved successfully!

Ooh no, something went wrong!