Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/25/10 19:57:44 (14 years ago)
Author:
kgrading
Message:

improved the DAL further, changed minor details for the presentation (#830)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server/3.2/ServiceCallInterception.cs

    r3203 r3220  
    99
    1010namespace HeuristicLab.Hive.Server {
    11   class ServiceCallInterception: IMethodInterceptor {
    12     #region IMethodInterceptor Members
     11  internal class ServiceCallInterception : IMethodInterceptor {
     12
     13    private bool useTransactions = false;
    1314
    1415    public object Invoke(IMethodInvocation invocation) {
    15       Console.WriteLine(DateTime.Now + " - " + Thread.CurrentThread.ManagedThreadId + " - Entering Method " + invocation.Method.Name);
     16      Console.WriteLine(DateTime.Now + " - " + Thread.CurrentThread.ManagedThreadId + " - Entering Method " +
     17                        invocation.Method.Name);
    1618
    17       Object obj;
    18      
    19       using (TransactionScope scope = new TransactionScope()) {
     19      if(ContextFactory.Context != null) {
     20        Console.WriteLine("Error - Not null context found - why wasn't this disposed?");
     21        ContextFactory.Context = null;
     22      }
     23
     24      Object obj = null;
     25
     26      if (invocation.Method.Name.Equals("SendStreamedJob") || invocation.Method.Name.Equals("StoreFinishedJobResultStreamed")) {       
     27        ContextFactory.Context.Connection.Open();
     28        if(useTransactions)
     29          ContextFactory.Context.Transaction = ContextFactory.Context.Connection.BeginTransaction();
    2030        try {
    2131          obj = invocation.Proceed();
    22           scope.Complete();
    23         } finally {
     32          Console.WriteLine("leaving context open for Streaming");
     33        }
     34        catch (Exception e) {         
     35          Console.WriteLine(e);
    2436          ContextFactory.Context.Dispose();
    25           Console.WriteLine("setting old context null");
    2637          ContextFactory.Context = null;
    27           Console.WriteLine("Disposing old Context");     
     38        }       
     39      } else {
     40        if(useTransactions) {
     41          using (TransactionScope scope = new TransactionScope()) {
     42            try {
     43              obj = invocation.Proceed();
     44              scope.Complete();
     45            }
     46            catch (Exception e) {
     47              Console.WriteLine("Exception Occured");
     48              Console.WriteLine(e);
     49            }
     50            finally {
     51              ContextFactory.Context.Dispose();
     52              Console.WriteLine("setting old context null");
     53              ContextFactory.Context = null;
     54              Console.WriteLine("Disposing old Context");
     55            }
     56          }
     57        } else {
     58          try {
     59            obj = invocation.Proceed();           
     60          }
     61          catch (Exception e) {
     62            Console.WriteLine("Exception Occured");
     63            Console.WriteLine(e);
     64          }
     65          finally {
     66            ContextFactory.Context.Dispose();
     67            Console.WriteLine("setting old context null");
     68            ContextFactory.Context = null;
     69            Console.WriteLine("Disposing old Context");
     70          } 
    2871        }
    29       }     
    30       Console.WriteLine(DateTime.Now + " - " + Thread.CurrentThread.ManagedThreadId + " - Leaving Method " + invocation.Method.Name);           
     72      }
     73      Console.WriteLine(DateTime.Now + " - " + Thread.CurrentThread.ManagedThreadId + " - Leaving Method " +
     74                          invocation.Method.Name);
     75
    3176      return obj;
    3277    }
    33 
    34     #endregion
    3578  }
    3679}
     80     
     81 
Note: See TracChangeset for help on using the changeset viewer.