public void OnException(Aop.AspectContext aspectContext) { if (!isMatch(aspectContext.Method.Method)) { return; } excuteTraceInfo.IsError = true; excuteTraceInfo.ErrorMessage = aspectContext.Exception.Message; excuteTraceInfo.ErrorStackTrace = aspectContext.Exception.StackTrace; }
public void PostProceed(Aop.AspectContext aspectContext) { if (!isMatch(aspectContext.Method.Method)) { return; } excuteTraceInfo.CompleteDt = DateTime.Now; if (!excuteTraceInfo.IsError && aspectContext.ReturnValue != null) { excuteTraceInfo.ResultData = JsonConvert.SerializeObject(aspectContext.ReturnValue); } if (_methodExcuteTraceRepository != null) { _methodExcuteTraceRepository.SaveMethodExcuteTraceInfo(excuteTraceInfo); } }
public bool PreProceed(Aop.AspectContext aspectContext) { if (!isMatch(aspectContext.Method.Method)) { return(true); } excuteTraceInfo = new MethodExcuteTraceInfo(); excuteTraceInfo.CallDt = DateTime.Now; //excuteTraceInfo.ServiceName = invocation.MethodInvocationTarget?.DeclaringType.Name; excuteTraceInfo.InterfaceName = aspectContext.Method.Method.DeclaringType.Name; excuteTraceInfo.MethodName = aspectContext.Method.Method.Name; if (aspectContext.Method.Parameters != null && aspectContext.Method.Parameters.Any()) { excuteTraceInfo.ParameterInfo = JsonConvert.SerializeObject(aspectContext.Method.Parameters); } return(true); }
public void PostProceed(Aop.AspectContext aspectContext) { if (!isMatch(aspectContext.Method.Method)) { return; } var user = _authenticator.GetCurrentUser(); var auditContent = aspectContext.Method.Method.DeclaringType.FullName + "." + aspectContext.Method.Method.Name + "()"; var auditAttr = aspectContext.Method.Method.GetCustomAttribute <AuditAttribute>(); if (auditAttr != null) { auditContent = auditAttr.LogContentFormat; } auditContent = System.Text.RegularExpressions.Regex.Replace(auditContent, @"@\{(.*?)\}", match => { var paramter = match.Groups[1].Captures[0].Value; paramter = paramter.Trim(); var value = aspectContext.Method.Parameters?.FirstOrDefault(t => t.Name == paramter)?.Value; if (value == null) { return(""); } return(ServiceJsonConvert.SerializeObject(value)); }); _auditLogService.WriteAuditLogAsync(user, auditContent, new AuditAdditional { Ip = _userIpAccessor.GetIp() }).Wait(); }
public bool PreProceed(Aop.AspectContext aspectContext) { if (_authenticator == null) { throw new Exception("_authenticator is null"); } var user = _authenticator.GetCurrentUser(); foreach (var authitem in _authorizeItems) { //匹配接口方法和实现方法 if (authitem.IsMatch(aspectContext.Method.Method)) { if (!authitem.IsValid(user, aspectContext.Method.Method)) { throw new PermissionDeniedException(authitem.ErrorMessage); } } } return(true); }
public bool PreProceed(Aop.AspectContext aspectContext) { return(true); }
public void OnException(Aop.AspectContext aspectContext) { }
public void PostProceed(Aop.AspectContext aspectContext) { }