Beispiel #1
0
 public override void OnInvoke(MethodInterceptionArgs args)
 {
     LoggingHelper.Writelog("Starting transaction");
     using (var scope = new TransactionScope())
     {
         var retries   = 3;
         var succeeded = false;
         while (!succeeded)
         {
             try
             {
                 args.Proceed();//包含了被调用方法传递过来的参数了
                 scope.Complete();
                 succeeded = true;
             }
             catch
             {
                 if (retries >= 0)
                 {
                     retries--;
                 }
                 else
                 {
                     LoggingHelper.Writelog("Transaction Error");
                     throw;
                 }
             }
         }
     }
     LoggingHelper.Writelog("Transaction complete");
 }
Beispiel #2
0
 public override void OnException(MethodExecutionArgs args)
 {
     if (Exceptions.Handle(args.Exception))
     {
         args.FlowBehavior = FlowBehavior.Continue;
     }
     args.FlowBehavior = FlowBehavior.ThrowException;
     LoggingHelper.Writelog("exception:" + args.Exception);
 }
Beispiel #3
0
        public override void OnEntry(MethodExecutionArgs eventArgs)
        {
            string defaultLog = string.Format("{0} : Entry at {1}", eventArgs.Method.Name, DateTime.Now);

            LoggingHelper.Writelog(defaultLog);
            foreach (var argument in eventArgs.Arguments)
            {
                if (argument.GetType() == typeof(int))
                {
                }
            }
        }
Beispiel #4
0
        public override void OnSuccess(MethodExecutionArgs eventArgs)
        {
            string defaultLog = string.Format("{0} : Success at {1}", eventArgs.Method.Name, DateTime.Now);

            LoggingHelper.Writelog(defaultLog);
        }