示例#1
0
        public static bool ShouldSaveAudit(MethodInfo methodInfo, IAuditingConfiguration configuration, IZbpSession abpSession, bool defaultValue = false)
        {
            if (configuration == null || !configuration.IsEnabled)
            {
                return false;
            }

            if (!configuration.IsEnabledForAnonymousUsers && (abpSession == null || !abpSession.UserId.HasValue))
            {
                return false;
            }

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

            if (!methodInfo.IsPublic)
            {
                return false;
            }

            if (methodInfo.IsDefined(typeof(AuditedAttribute)))
            {
                return true;
            }

            if (methodInfo.IsDefined(typeof(DisableAuditingAttribute)))
            {
                return false;
            }

            var classType = methodInfo.DeclaringType;
            if (classType != null)
            {
                if (classType.IsDefined(typeof(AuditedAttribute)))
                {
                    return true;
                }

                if (classType.IsDefined(typeof(DisableAuditingAttribute)))
                {
                    return false;
                }

                if (configuration.Selectors.Any(selector => selector.Predicate(classType)))
                {
                    return true;
                }
            }

            return defaultValue;
        }
示例#2
0
 /// <summary>
 /// Constructor.
 /// </summary>
 protected UnitOfWorkBase(IUnitOfWorkDefaultOptions defaultOptions)
 {
     _filters = defaultOptions.Filters.ToList();
     ZbpSession = NullZbpSession.Instance;
 }