Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/01/10 13:58:24 (14 years ago)
Author:
kgrading
Message:

Removed References to HiveLogging and updated the default logging mechanism (#991)

File:
1 edited

Legend:

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

    r3220 r3578  
    77using HeuristicLab.Hive.Server.LINQDataAccess;
    88using System.Transactions;
     9using HeuristicLab.Hive.Contracts;
     10using HeuristicLab.Tracing;
    911
    1012namespace HeuristicLab.Hive.Server {
    1113  internal class ServiceCallInterception : IMethodInterceptor {
    1214
    13     private bool useTransactions = false;
     15    private const bool UseTransactions = true;
    1416
    1517    public object Invoke(IMethodInvocation invocation) {
    16       Console.WriteLine(DateTime.Now + " - " + Thread.CurrentThread.ManagedThreadId + " - Entering Method " +
    17                         invocation.Method.Name);
     18      Logger.Info("Entering Method: " + invocation.Method.Name);
    1819
    1920      if(ContextFactory.Context != null) {
    20         Console.WriteLine("Error - Not null context found - why wasn't this disposed?");
     21        Logger.Info("Not null context found - why wasn't this disposed?");
     22        try {
     23          Logger.Info("Trying to dispose");
     24          ContextFactory.Context.Dispose();
     25        } catch (Exception e) {
     26          Logger.Error(e);
     27        }
    2128        ContextFactory.Context = null;
    2229      }
     
    2633      if (invocation.Method.Name.Equals("SendStreamedJob") || invocation.Method.Name.Equals("StoreFinishedJobResultStreamed")) {       
    2734        ContextFactory.Context.Connection.Open();
    28         if(useTransactions)
    29           ContextFactory.Context.Transaction = ContextFactory.Context.Connection.BeginTransaction();
     35        if(UseTransactions) {
     36          Logger.Debug("Opening Transaction");
     37          ContextFactory.Context.Transaction = ContextFactory.Context.Connection.BeginTransaction(ApplicationConstants.ISOLATION_LEVEL);
     38        } else {
     39          Logger.Debug("Not using a Transaction");
     40        }
    3041        try {
    3142          obj = invocation.Proceed();
    32           Console.WriteLine("leaving context open for Streaming");
     43          Logger.Info("leaving context open for streaming");
    3344        }
    34         catch (Exception e) {         
    35           Console.WriteLine(e);
     45        catch (Exception e) {
     46          Logger.Error("Exception occured during method invocation", e);             
    3647          ContextFactory.Context.Dispose();
    3748          ContextFactory.Context = null;
    3849        }       
    3950      } else {
    40         if(useTransactions) {
    41           using (TransactionScope scope = new TransactionScope()) {
     51        if(UseTransactions) {
     52          using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = ApplicationConstants.ISOLATION_LEVEL_SCOPE })) {
    4253            try {
     54              Logger.Debug("Current Transaction Isolation level is: " + Transaction.Current.IsolationLevel);
    4355              obj = invocation.Proceed();
    4456              scope.Complete();
    4557            }
    4658            catch (Exception e) {
    47               Console.WriteLine("Exception Occured");
    48               Console.WriteLine(e);
     59              Logger.Error("Exception occured during method invocation", e);             
    4960            }
    5061            finally {
    5162              ContextFactory.Context.Dispose();
    52               Console.WriteLine("setting old context null");
     63              Logger.Debug("Disposed Context");
    5364              ContextFactory.Context = null;
    54               Console.WriteLine("Disposing old Context");
     65              Logger.Debug("Set Context Null");
    5566            }
    5667          }
     
    6071          }
    6172          catch (Exception e) {
    62             Console.WriteLine("Exception Occured");
    63             Console.WriteLine(e);
     73            Logger.Error("Exception occured during method invocation", e);                         
    6474          }
    6575          finally {
    6676            ContextFactory.Context.Dispose();
    67             Console.WriteLine("setting old context null");
     77            Logger.Debug("Disposed Context");
    6878            ContextFactory.Context = null;
    69             Console.WriteLine("Disposing old Context");
     79            Logger.Debug("Set Context Null");
    7080          } 
    7181        }
    7282      }
    73       Console.WriteLine(DateTime.Now + " - " + Thread.CurrentThread.ManagedThreadId + " - Leaving Method " +
    74                           invocation.Method.Name);
     83      Logger.Info("Leaving Method: " + invocation.Method.Name);
    7584
    7685      return obj;
Note: See TracChangeset for help on using the changeset viewer.