Line | |
---|
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;
|
---|
8 | using HeuristicLab.Clients.Common;
|
---|
9 |
|
---|
10 | namespace HeuristicLab.Services.Hive.DataAccess {
|
---|
11 | public class TransactionManager {
|
---|
12 | public Disposable<TransactionScope> OpenTransaction() {
|
---|
13 | TransactionScope transaction = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = ApplicationConstants.IsolationLevelScope });
|
---|
14 | var disposable = new Disposable<TransactionScope>(transaction);
|
---|
15 | disposable.OnDisposing += new EventHandler<EventArgs<object>>(disposable_OnDisposing);
|
---|
16 | return disposable;
|
---|
17 | }
|
---|
18 |
|
---|
19 | void disposable_OnDisposing(object sender, EventArgs<object> e) {
|
---|
20 | TransactionScope scope = (TransactionScope)e.Value;
|
---|
21 | scope.Complete();
|
---|
22 | scope.Dispose();
|
---|
23 | }
|
---|
24 | }
|
---|
25 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.