/// <summary> /// Action执行后 /// </summary> /// <param name="context"></param> /// <returns></returns> private async Task OnActionExecutedAsync(ActionExecutingContext context) { var publisher = context.HttpContext.RequestServices.GetService <IApiEventPublisher>(); if (publisher == null) { return; } var request = context.HttpContext.Request; var apiEvent = new ApiEvent { Uri = new Uri(request.Path + request.QueryString, UriKind.Relative), UserId = this.GetUserId(context.HttpContext.User), CreateTime = DateTime.Now }; var api = context.GetApiDescription(); var contentParameter = api.ParameterDescriptions .Where(item => item.Source.Id.EqualsIgnoreCase("BODY") || item.Source.Id.EqualsIgnoreCase("FORM")) .FirstOrDefault(); if (contentParameter != null && context.ActionArguments.TryGetValue(contentParameter.Name, out var content) == true) { apiEvent.Content = content; } await publisher.PulishAsync(api.RelativePath, apiEvent); }