Example #1
0
        protected virtual bool ShouldIntercept(
            IAbpMethodInvocation invocation,
            out AuditLogInfo auditLog,
            out AuditLogActionInfo auditLogAction)
        {
            auditLog       = null;
            auditLogAction = null;

            if (AbpCrossCuttingConcerns.IsApplied(invocation.TargetObject, AbpCrossCuttingConcerns.Auditing))
            {
                return(false);
            }

            var auditLogScope = _auditingManager.Current;

            if (auditLogScope == null)
            {
                return(false);
            }

            if (!_auditingHelper.ShouldSaveAudit(invocation.Method))
            {
                return(false);
            }

            auditLog       = auditLogScope.Log;
            auditLogAction = _auditingHelper.CreateAuditLogAction(
                auditLog,
                invocation.TargetObject.GetType(),
                invocation.Method,
                invocation.Arguments
                );

            return(true);
        }
Example #2
0
        public virtual AuditLogActionInfo CreateAuditLogAction(Type type, MethodInfo method, IDictionary <string, object> arguments)
        {
            var actionInfo = new AuditLogActionInfo
            {
                ServiceName = type != null
                    ? type.FullName
                    : "",
                MethodName    = method.Name,
                Parameters    = SerializeConvertArguments(arguments),
                ExecutionTime = Clock.Now
            };

            //TODO Execute contributors

            return(actionInfo);
        }
Example #3
0
        protected virtual bool ShouldIntercept(
            IAbpMethodInvocation invocation,
            out AuditLogInfo auditLog,
            out AuditLogActionInfo auditLogAction)
        {
            auditLog       = null;
            auditLogAction = null;

            if (AbpCrossCuttingConcerns.IsApplied(invocation.TargetObject, AbpCrossCuttingConcerns.Auditing))
            {
                return(false);
            }

            using (var scope = _serviceScopeFactory.CreateScope())
            {
                var auditingManager = scope.ServiceProvider.GetRequiredService <IAuditingManager>();
                var auditLogScope   = auditingManager.Current;
                if (auditLogScope == null)
                {
                    return(false);
                }

                var auditingHelper = scope.ServiceProvider.GetRequiredService <IAuditingHelper>();
                if (!auditingHelper.ShouldSaveAudit(invocation.Method))
                {
                    return(false);
                }

                auditLog       = auditLogScope.Log;
                auditLogAction = auditingHelper.CreateAuditLogAction(
                    auditLog,
                    invocation.TargetObject.GetType(),
                    invocation.Method,
                    invocation.Arguments
                    );

                return(true);
            }
        }
        protected virtual bool ShouldIntercept(MethodInterceptionArgs args, out AuditLogInfo auditLog,
                                               out AuditLogActionInfo auditLogAction)
        {
            auditLog       = new AuditLogInfo();
            auditLogAction = new AuditLogActionInfo();

            var auditLogScope = _auditingManager.Current;

            if (auditLogScope == null)
            {
                return(false);
            }

            auditLog       = auditLogScope.Log;
            auditLogAction = _auditingHelper.CreateAuditLogAction(
                auditLog,
                args.Method.DeclaringType?.GetType(),
                args.Method as MethodInfo,
                args.Arguments.ToArray()
                );

            return(true);
        }