public Task Invoke(HttpContext httpContext) { User user = httpContext.Session.Get <User>("user"); if (user != null) { OperationLog log = new OperationLog(); log.Method = httpContext.Request.Method; log.Ip = httpContext.GetUserIp(); log.Path = httpContext.Request.Path; if (httpContext.Request.Form != null) { Dictionary <string, string> form = httpContext.Request.Form.ToDictionary(x => x.Key, x => x.Value.ToString()); log.Input = JsonConvert.SerializeObject(form); } log.Username = user.Username; log.CreateAt = new DateTime(); IOperationLogService operationLogService = (IOperationLogService)httpContext.RequestServices.GetService(typeof(IOperationLogService)); operationLogService.Record(log); } return(_next(httpContext)); }