Changeset 8270
- Timestamp:
- 07/10/12 09:56:20 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS/HeuristicLab.Services.Hive.DataAccess/3.3/TransactionManager.cs
r7259 r8270 22 22 using System; 23 23 using System.Transactions; 24 using HeuristicLab.Services.Hive.DataAccess;25 24 26 namespace HeuristicLab.Services.Hive.DataAccess { 27 public class TransactionManager : ITransactionManager { 25 namespace HeuristicLab.Services.Hive.DataAccess { 26 public class TransactionManager : ITransactionManager { 28 27 public void UseTransaction(Action call, bool serializable = false, bool longRunning = false) { 29 28 int n = 10; 30 29 while (n > 0) { 31 TransactionScope transaction = CreateTransaction(serializable, longRunning);30 //TransactionScope transaction = CreateTransaction(serializable, longRunning); 32 31 try { 33 32 call(); 34 transaction.Complete();33 //transaction.Complete(); 35 34 n = 0; 36 35 } 37 36 catch (System.Data.SqlClient.SqlException e) { 38 37 n--; // probably deadlock situation, let it roll back and repeat the transaction n times 39 LogFactory.GetLogger(typeof(TransactionManager).Namespace).Log(string.Format("Exception occured, repeating transaction {0} more times. Details: {1}", n, e.ToString())); 38 LogFactory.GetLogger(typeof(TransactionManager).Namespace).Log(string.Format("Exception occured, repeating transaction {0} more times. Details: {1}", n, e.ToString())); 40 39 if (n <= 0) throw; 41 40 } 42 41 finally { 43 transaction.Dispose();42 //transaction.Dispose(); 44 43 } 45 44 } … … 49 48 int n = 10; 50 49 while (n > 0) { 51 TransactionScope transaction = CreateTransaction(serializable, longRunning);50 //TransactionScope transaction = CreateTransaction(serializable, longRunning); 52 51 try { 53 52 T result = call(); 54 transaction.Complete();53 //transaction.Complete(); 55 54 n = 0; 56 55 return result; … … 62 61 } 63 62 finally { 64 transaction.Dispose();63 //transaction.Dispose(); 65 64 } 66 65 }
Note: See TracChangeset
for help on using the changeset viewer.