public override void OnResultExecuted(ResultExecutedContext context) { var myContext = context.HttpContext.RequestServices.GetService(typeof(MyContext)) as MyContext; var controllerName = context.RouteData.Values["controller"].ToString(); var actionName = context.RouteData.Values["action"].ToString(); var uri = context.HttpContext.Request.GetAbsoluteUri(); var log = new Sys_UserActionLog() { Action = actionName, Controller = controllerName, ActionTime = DateTime.Now, ActionUserId = AuthContextService.CurrentUser.Guid, ActionUserName = AuthContextService.CurrentUser.LoginName + "-" + AuthContextService.CurrentUser.DisplayName, ApiUrl = uri, Description = Title, Id = NumberNo.SequentialGuid(), IsDeleted = (int)CommonEnum.IsDeleted.No, IP = AuthContextService.CurrentUser.IpAddress }; myContext.Sys_UserActionLog.Add(log); myContext.SaveChanges(); base.OnResultExecuted(context); }
private void Log(Guid userid, string userName) { var log = new Sys_UserActionLog() { Action = "Auth", Controller = "Oauth", ActionTime = DateTime.Now, ActionUserId = userid, ActionUserName = userName, ApiUrl = Request.GetAbsoluteUri(), Description = "登录", Id = NumberNo.SequentialGuid(), IsDeleted = (int)CommonEnum.IsDeleted.No, IP = HttpContext.GetClientUserIp() }; _sysUserActionLogRepo.Insert(log); _unitOfWork.Save(); }