Rev | Line | |
---|
[4649] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Linq;
|
---|
| 4 | using System.Text;
|
---|
| 5 | using HeuristicLab.Services.Hive.Common;
|
---|
| 6 | using System.Transactions;
|
---|
| 7 | using HeuristicLab.Common;
|
---|
[5055] | 8 | using HeuristicLab.Clients.Common;
|
---|
[4649] | 9 |
|
---|
| 10 | namespace HeuristicLab.Services.Hive.DataAccess {
|
---|
| 11 | public class TransactionManager {
|
---|
| 12 | public Disposable<TransactionScope> OpenTransaction() {
|
---|
[4796] | 13 | TransactionScope transaction = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = ApplicationConstants.IsolationLevelScope });
|
---|
[4649] | 14 | var disposable = new Disposable<TransactionScope>(transaction);
|
---|
[5055] | 15 | disposable.OnDisposing += new EventHandler<EventArgs<object>>(disposable_OnDisposing);
|
---|
[4649] | 16 | return disposable;
|
---|
| 17 | }
|
---|
| 18 |
|
---|
[5055] | 19 | void disposable_OnDisposing(object sender, EventArgs<object> e) {
|
---|
| 20 | TransactionScope scope = (TransactionScope)e.Value;
|
---|
| 21 | scope.Complete();
|
---|
| 22 | scope.Dispose();
|
---|
[4649] | 23 | }
|
---|
| 24 | }
|
---|
| 25 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.