public LogController(ILogService logService, ILogActionService logActionService, IUserService userService, IUserRoleService userRoleService, IRoleService roleService, [Dependency("CRMNAUnitOfWork")] IUnitOfWork unitOfWork) { this._unitOfWork = unitOfWork; this._logService = logService; this._logActiveService = logActionService; this._userService = userService; this._userRoleService = userRoleService; this._roleService = roleService; }
public override void OnActionExecuting(ActionExecutingContext filterContext) { logActionService = new LogActionService(); LogViewModel logModel = new LogViewModel(); int? targetId = null; string method = ""; string ip = ""; string fullname = ""; string userCode = ""; string targetName = ""; QuestionTempViewModel newQuestionModel = new QuestionTempViewModel(); var user = (UserViewModel)HttpContext.Current.Session["user"]; int?userId = null; if (user != null) { userId = user.Id; } fullname = filterContext.HttpContext.User.Get(u => u.FullName); userCode = filterContext.HttpContext.User.Get(u => u.Code); //ip = System.Web.HttpContext.Current.Request.UserHostAddress; string strHostName = ""; strHostName = Dns.GetHostName(); IPHostEntry ipEntry = Dns.GetHostEntry(strHostName); IPAddress[] addr = ipEntry.AddressList; if (addr.Count() == 2) { ip = addr[1].ToString(); } else { ip = addr[3].ToString(); } if (IdParamName != null && filterContext.ActionParameters.ContainsKey(IdParamName)) { targetId = filterContext.ActionParameters[IdParamName] as Int32?; targetName = "Question"; } if (TargetId != null && filterContext.ActionParameters.ContainsKey(TargetId)) { targetId = filterContext.ActionParameters[TargetId] as Int32?; targetName = "Import"; } ILogActionService logger = new LogActionService(); if (Action != null) { logModel.UserId = userId; logModel.TargetId = targetId; logModel.TargetName = targetName != null?targetName.ToString() : ""; logModel.LogDate = DateTime.Now; logModel.Message = Message != null?Message.ToString() : ""; logModel.Controller = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName; logModel.Action = filterContext.ActionDescriptor.ActionName; logModel.Fullname = fullname; logModel.UserCode = userCode; logModel.Method = Method != null?Method.ToString() : ""; logModel.Ip = ip; logger.LogAction(logModel); } }
public EntityLogManager(string entityType, ILogActionService service) { _entityType = entityType; _service = service; }
public LogActionController() { logActionService = new LogActionService(); }