コード例 #1
0
        /// <summary>
        /// 日志记录方法调用前处理.
        /// </summary>
        /// <param name="methodInvoke">代理方法</param>
        /// <param name="refObject">代理对象</param>
        public IMessage PreProcess(IMessage methodInvoke, MarshalByRefObject refObject)
        {
            IMethodCallMessage call = methodInvoke as IMethodCallMessage;

            XYHLogOperator.WriteLog(new LogMessage()
            {
                MethodName     = call.MethodName,
                MethodParam    = JsonConvert.SerializeObject(call.Args),
                LogProjectName = call.TypeName,
                Level          = LogLevel.Debug
            });
            return(null);
        }
コード例 #2
0
        /// <summary>
        /// 日志记录方法异常处理.
        /// </summary>
        /// <param name="ex">异常</param>
        /// <param name="methodInvoke">代理方法</param>
        /// <param name="refObject">代理对象</param>
        public IMessage ExceptionProcess(Exception ex, IMessage methodInvoke, MarshalByRefObject refObject, DateTime executeStartTime, DateTime executeEndTime)
        {
            IMethodCallMessage call = methodInvoke as IMethodCallMessage;

            XYHLogOperator.WriteLog(new LogMessage()
            {
                MethodName       = call.MethodName,
                MethodParam      = JsonConvert.SerializeObject(call.Args),
                LogProjectName   = call.TypeName,
                Level            = LogLevel.Error,
                Exception        = ex.InnerException,
                ExecuteEndTime   = executeEndTime,
                ExecuteStartTime = executeStartTime
            });
            return(null);
        }
コード例 #3
0
        /// <summary>
        /// 日志记录方法调用后处理.
        /// </summary>
        /// <param name="methodInvoke">代理方法</param>
        /// <param name="returnInvoke">代理返回</param>
        /// <param name="refObject">代理对象</param>
        public IMessage PostProcess(IMessage methodInvoke, IMessage returnInvoke, MarshalByRefObject refObject, DateTime executeStartTime, DateTime executeEndTime)
        {
            IMethodCallMessage call   = methodInvoke as IMethodCallMessage;
            ReturnMessage      result = returnInvoke as ReturnMessage;

            XYHLogOperator.WriteLog(new LogMessage()
            {
                MethodName       = call.MethodName,
                MethodParam      = JsonConvert.SerializeObject(call.Args),
                MethodResult     = JsonConvert.SerializeObject(result.Properties["__Return"]),
                LogProjectName   = call.TypeName,
                ExecuteEndTime   = executeEndTime,
                ExecuteStartTime = executeStartTime,
                Level            = LogLevel.Debug
            });

            return(returnInvoke);
        }