protected override void OnActionExecuting(ActionExecutingContext filterContext) { string sessionId = filterContext.HttpContext.Session.SessionID; var info = UserManage.GetCurrentUserInfo(); if (info == null) { XT_TEMP_PORARY_USER userInfo = new XT_TEMP_PORARY_USER() { ID = GuidTools.NewGuid(), USER_NAME = "游客", CREATE_BY = "sys", CREATE_TIME = DateTime.Now, MODIFY_BY = "sys", MODIFY_TIME = DateTime.Now, USER_ID = "" }; UserManage.SaveToSession(userInfo); GetService <SysTempPoraryUserService>().Insert(userInfo); this.UserInfo = userInfo; } if (info is XT_USER) { UserInfo = info as XT_USER; } action = Request.Params["action"]; string url = Request.Url.AbsoluteUri; //if(CheckUserUrlAndActionPermission(url,)) base.OnActionExecuting(filterContext); }
/// <summary> /// 添加数据 /// </summary> /// <param name="obj"></param> /// <returns></returns> public object Insert(T obj, bool returnObj = false) { int rowNum = -1; try { obj.ID = GuidTools.NewGuid(); obj.CREATE_TIME = DateTime.Now; obj.MODIFY_TIME = DateTime.Now; rowNum = db.Insert(obj); if (returnObj) { return(obj); } } catch (Exception e) { throw new Exception("数据添加失败" + e.Message); } finally { db.Dispose(); } return(rowNum); }
/// <summary> /// 保存用户信息到服务器中 /// </summary> /// <param name="user"></param> public static void SaveToSession(XT_USER user) { XT_LOGIN_INFO info = new XT_LOGIN_INFO() { USER_ID = user.ID, ID = GuidTools.NewGuid(), LOGIN_ADRESS_IP = HttpContext.Current.Request.UserHostAddress, LOGIN_ADDRESS_MAC = "", CREATE_BY = "_system", CREATE_TIME = DateTime.Now, MODIFY_BY = "_system", MODIFY_TIME = DateTime.Now }; SaveToSession(info); }
public override void OnException(ExceptionContext filterContext) { Exception e = filterContext.Exception; ConnectionStringSettings settings = AppConfigManage.GetSysLogConnection(); SysLogService service = ServiceManage.GetService <SysLogService>(); XT_SYS_LOG log = new XT_SYS_LOG() { ADDRESS_URL = HttpContext.Current.Request.Url.AbsolutePath, CREATE_BY = "sys", MODIFY_BY = "sys", CREATE_TIME = DateTime.Now, MODIFY_TIME = DateTime.Now, EX_MESSAGE = e.Message, ID = GuidTools.NewGuid(), USER_ID = UserManage.GetCurrentUserInfo().ID }; service.Insert(log); NameValueCollection collection = HttpContext.Current.Request.Params; StringBuilder builder = new StringBuilder(); SysLogParamter paramterService = ServiceManage.GetService <SysLogParamter>(); foreach (string name in collection.Keys) { XT_REQUEST_PARAMETER paramters = new XT_REQUEST_PARAMETER() { ID = GuidTools.NewGuid(), CREATE_BY = log.CREATE_BY, CREATE_TIME = log.CREATE_TIME, LOG_ID = log.ID, MODIFY_BY = log.MODIFY_BY, MODIFY_TIME = log.MODIFY_TIME, PARAMETER_NAME = name, PARAMETER_VALUE = collection[name] }; paramterService.Insert(paramters); } HttpContext.Current.Server.ClearError(); }