public void OnActionExecuting(ActionExecutingContext context) { var controllerAction = context.ActionDescriptor as ControllerActionDescriptor; if (controllerAction.ControllerTypeInfo.HasAttribute <DisableAuditingAttribute>() == false || !controllerAction.MethodInfo.HasAttribute <DisableAuditingAttribute>() == false) { IServiceProvider provider = context.HttpContext.RequestServices; DictionaryScoped dict = provider.GetService <DictionaryScoped>(); AuditChange auditChange = new AuditChange(); auditChange.FunctionName = $"{context.Controller.GetType().ToDescription()}-{controllerAction.MethodInfo.ToDescription()}"; auditChange.Action = context.HttpContext.Request.Path; auditChange.Ip = context.HttpContext.GetClientIP(); auditChange.BrowserInformation = context.HttpContext.Request.Headers["User-Agent"].ToString(); auditChange.StartTime = DateTime.Now; dict.AuditChange = auditChange; } }
public override void OnActionExecuting(ActionExecutingContext context) { IServiceProvider provider = context.HttpContext.RequestServices; var controllerAction = context.ActionDescriptor as ControllerActionDescriptor; var isAuditEnabled = provider.GetAppSettings().AuditEnabled; if (isAuditEnabled) { DictionaryScoped dict = provider.GetService <DictionaryScoped>(); AuditChange auditChange = new AuditChange(); auditChange.FunctionName = $"{context.Controller.GetType().ToDescription()}-{controllerAction.MethodInfo.ToDescription()}"; auditChange.Action = context.HttpContext.Request.Path; auditChange.Ip = context.HttpContext.GetClientIP(); auditChange.BrowserInformation = context.HttpContext.Request.Headers["User-Agent"].ToString(); auditChange.StartTime = DateTime.Now; dict.AuditChange = auditChange; } }
public void OnActionExecuted(ActionExecutedContext context) { if (context.Result is ObjectResult result) { if (result.Value is AjaxResult ajax) { var type = ajax.Type; IServiceProvider provider = context.HttpContext.RequestServices; DictionaryScoped dict = provider.GetService <DictionaryScoped>(); if (!ajax.Success) { dict.AuditChange.Message = ajax.Message; } dict.AuditChange.ResultType = type; } } }
public AuditEntityEventHandler(DictionaryScoped dictionaryScoped) { _dictionaryScoped = dictionaryScoped; }
public AuditEventHandler(IServiceProvider serviceProvider, DictionaryScoped dictionaryAccessor) { _serviceProvider = serviceProvider; _dictionaryAccessor = dictionaryAccessor; }