Exemplo n.º 1
0
        public IMethodReturn Invoke(IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)
        {
            // Before invoking the method on the original target.
            this.WriteLog(String.Format("Invoking method {0} at {1}", input.MethodBase, App.getDate().ToLongTimeString()));

            // Invoke the next behavior in the chain.
            var result = getNext()(input, getNext);

            // After invoking the method on the original target.
            if (result.Exception != null)
            {
                ExceptionBE log = new ExceptionBE()
                {
                    Class   = input.MethodBase.ReflectedType.FullName,
                    Method  = input.MethodBase.Name,
                    Source  = result.Exception.Source,
                    Message = result.Exception.Message,
                    Stack   = result.Exception.StackTrace,
                };

                ExceptionHandler.HandleException(log, result.Exception);
            }
            else
            {
                this.WriteLog(String.Format("Method {0} returned {1} at {2}", input.MethodBase, result.ReturnValue, App.getDate().ToString()));
            }

            return(result);
        }
Exemplo n.º 2
0
        public ExceptionBE Create(ExceptionBE objBE)
        {
            if (string.IsNullOrEmpty(objBE.Name))
            {
                objBE.Name = objBE.Message;
            }

            objBE.Name = StringExt.Truncate(objBE.Name, 100).ToUpper();

            if (!(objBE.UserId.HasValue))
            {
                objBE.UserId = Guid.Parse(Settings.UserAdministratorId);
            }

            objBE.Type = StringExt.Truncate(objBE.Type, 50).ToUpper();

            objBE.Class = StringExt.Truncate(objBE.Class, 50).ToUpper();

            objBE.Method = StringExt.Truncate(objBE.Method, 100).ToUpper();

            objBE.Message = StringExt.Truncate(objBE.Message, 2000).ToUpper();

            objBE.Source = StringExt.Truncate(objBE.Source, 2000).ToUpper();

            if (!(objBE.OwnerId.HasValue))
            {
                objBE.OwnerId = Guid.Parse(Settings.UserAdministratorId);
            }

            if (!(objBE.StatusId.HasValue))
            {
                objBE.StatusId = Guid.Parse(Settings.StatusActiveId);
            }

            if (!(objBE.CreatedById.HasValue))
            {
                objBE.CreatedById = Guid.Parse(Settings.UserAdministratorId);
            }

            if (!(objBE.ModifiedById.HasValue))
            {
                objBE.ModifiedById = Guid.Parse(Settings.UserAdministratorId);
            }

            return(daoException.Create(objBE));
        }
Exemplo n.º 3
0
        public static void HandleException(ExceptionBE log, Exception ex, bool propagate = true)
        {
            // register in database
            ExceptionBL errorModule = new ExceptionBL();

            log.Message = GetMessage(ex);
            log.Type    = PolicyName.ResolvePolicy(log.Class);

            errorModule.Create(log);

            if (log.Type == PolicyName.Business || log.Type == PolicyName.Data)
            {
                if (propagate)
                {
                    throw ex;
                }
            }
        }
Exemplo n.º 4
0
 internal static void HandleException(ExceptionBE log, Exception exception)
 {
     HandleException(log, exception, true);
 }