public int Add(int manager_id, string actionType, string controllerName, string remark, string user_ip) { DAO.BLL.B_Manager b_manager = new DAO.BLL.B_Manager(); DAO.BLL.B_Navigation b_nav = new DAO.BLL.B_Navigation(); Domain.Manager_log model = new Domain.Manager_log(); model.user_id = manager_id; var m_manager = b_manager.Get(manager_id); model.user_name = m_manager.user_name; model.action_type = actionType; List <SearchTemplate> st = new List <SearchTemplate>() { new SearchTemplate() { key = "controllerName", value = controllerName, searchType = Common.EnumBase.SearchType.Eq } }; model.navigation = b_nav.GetList(st, null)[0]; model.remark = remark; model.user_ip = user_ip; model.add_time = DateTime.Now; var res = Save(model); return(res); }
public override void OnResultExecuting(ResultExecutingContext filterContext) { //如果记录结束时间,就可能疏漏掉一些被重置的请求 try { var MonLog = filterContext.Controller.ViewData[Key] as MonitorLog; MonLog.ExecuteEndTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.ffff", DateTimeFormatInfo.InvariantInfo)); Logger.Info(MonLog.GetLoginfo()); } catch { } var actionName = filterContext.RouteData.Values["action"].ToString().ToLower(); var controllerName = filterContext.RouteData.Values["controller"].ToString().ToLower(); //如果相同,则是用户第一次打开view的请求,此时并没有数据,页面加载完后,会主动通过GetList请求数据,我们只用把第二次记录下来即可 if (actionName != "index" && !string.IsNullOrEmpty(controllerName)) { var thisIp = Utils.getIp(); try { DAO.BLL.B_Manager_log b_log = new DAO.BLL.B_Manager_log(); DAO.BLL.B_Manager b_manager = new DAO.BLL.B_Manager(); DAO.BLL.B_Navigation b_nav = new DAO.BLL.B_Navigation(); Domain.Manager_log model = new Domain.Manager_log(); model.user_id = Convert.ToInt32(filterContext.HttpContext.User.Identity.Name); var m_manager = b_manager.Get(Convert.ToInt32(filterContext.HttpContext.User.Identity.Name)); model.user_name = m_manager.user_name; model.action_type = ActionType(actionName); List <SearchTemplate> st = new List <SearchTemplate>() { new SearchTemplate() { key = "controllerName", value = controllerName, searchType = Common.EnumBase.SearchType.Eq } }; model.navigation = b_nav.GetList(st, null)[0]; MonitorLog MonLog = new MonitorLog(); model.remark = MonLog.GetCollections(filterContext.HttpContext.Request.Form); model.user_ip = thisIp; model.add_time = DateTime.Now; b_log.Save(model); } catch { } } }
public int Save(Domain.Manager_log model) { return(Convert.ToInt32(dal.Save(model))); }