/// <summary> /// 重新基类在Action执行之前的事情 /// </summary> /// <param name="filterContext">重写方法的参数</param> protected override void OnActionExecuting(ActionExecutingContext filterContext) { // TODO: 想办法获取用户的User id(或者用户id) ViewBag.OpenId = ""; string WeChatUserID = GetOpenId(filterContext); LogManager.GetLogger(this.GetType()).Debug("GetwechatUserID() : " + WeChatUserID); if (!string.IsNullOrEmpty(WeChatUserID)) { ViewBag.wechatUserID = WeChatUserID; int.TryParse(ViewBag.wechatUserID, out AppId); // check if water mark file exists string watermarkFilename = Server.MapPath("/Content/marks/" + WeChatUserID + ".png"); if (!System.IO.File.Exists(watermarkFilename)) { try { System.Drawing.Image img = ImageUtility.CreateWaterMarkImage(WeChatUserID); img.Save(watermarkFilename, System.Drawing.Imaging.ImageFormat.Png); } catch (Exception e) { LogManager.GetLogger(this.GetType()).Error(e); } } } base.OnActionExecuting(filterContext); }
/// <summary> /// 重新基类在Action执行之前的事情 /// </summary> /// <param name="filterContext">重写方法的参数</param> protected override void OnActionExecuting(ActionExecutingContext filterContext) { _performance.referer = filterContext.HttpContext.Request.Url != null ? filterContext.HttpContext.Request.Url.OriginalString : string.Empty; _performance.requestStart = DateTime.Now.Ticks / 1000000; // 想办法获取用户的lilly id(或者用户id) ViewBag.LillyId = ""; #if DEBUG string lillyId = "C225246"; #else string lillyId = GetLillyId(filterContext); #endif LogManager.GetLogger(this.GetType()).Debug("GetLillyId() : " + lillyId); if (!string.IsNullOrEmpty(lillyId)) { ViewBag.LillyId = lillyId; // 如果取到了,还要到我们的数据库里走一遭 //var existingUser = _weChatAppUserService.Entities.Where(a => a.WeChatUserID == lillyId).FirstOrDefault(); // check if water mark file exists try { string watermarkFilename = Server.MapPath("/marks/" + lillyId + ".png"); if (!System.IO.File.Exists(watermarkFilename)) { System.Drawing.Image img = ImageUtility.CreateWaterMarkImage(lillyId); img.Save(watermarkFilename, System.Drawing.Imaging.ImageFormat.Png); } } catch (Exception ex) { LogManager.GetLogger(this.GetType()).Debug("marks : Can't write."); } //记录日志,类型为0,用于做pagereport统计 string content = string.Empty; int appid = -1; if (!string.IsNullOrEmpty(Request.Url.Query)) { for (int i = 0; i <= Request.Url.Query.Split('&').Length - 1; i++) { if (Request.Url.Query.Split('&')[i].ToUpper().Contains("APPID")) { content = Request.Url.Query.Split('&')[i]; break; } } if (content.ToUpper().Contains("APPID")) { appid = int.Parse(content.Split('=')[1]); } } ExecuteBehavior(appid, 0, ""); } base.OnActionExecuting(filterContext); }
/// <summary> /// 重新基类在Action执行之前的事情 /// </summary> /// <param name="filterContext">重写方法的参数</param> protected override void OnActionExecuting(ActionExecutingContext filterContext) { // 想办法获取用户的lilly id(或者用户id) ViewBag.LillyId = ""; string lillyId = GetLillyId(filterContext); LogManager.GetLogger(this.GetType()).Debug("GetLillyId() : " + lillyId); if (!string.IsNullOrEmpty(lillyId)) { ViewBag.LillyId = lillyId; // 如果取到了,还要到我们的数据库里走一遭 //var existingUser = _weChatAppUserService.Entities.Where(a => a.WeChatUserID == lillyId).FirstOrDefault(); // check if water mark file exists string watermarkFilename = Server.MapPath("/marks/" + lillyId + ".png"); if (!System.IO.File.Exists(watermarkFilename)) { System.Drawing.Image img = ImageUtility.CreateWaterMarkImage(lillyId); img.Save(watermarkFilename, System.Drawing.Imaging.ImageFormat.Png); } } //////// if (string.IsNullOrEmpty(Request["_AppID"])) { Session["AppID"] = Request["_AppID"]; } //////// var objAppID = Session["AppID"]; //////// AppId = 0; //////// if (objAppID != null) //////// { //////// AppId = int.Parse(objAppID.ToString()); //////// } //////// ViewBag.AppList = CommonService.lstWeChatConfig; //////// ViewBag.CurAppID = AppId; //////// ////得到用户登录的信息 //////// objLoginInfo = Session["UserInfo"] as SysUser; //////// ////判断用户是否为空 应该使用 AuthorizeAttribute,临时解决一下 ////////if (objLoginInfo == null && (filterContext.ActionDescriptor.ActionName.ToLower() != "login" || //////// filterContext.ActionDescriptor.ControllerDescriptor.ControllerName.ToLower()!="account")) //////// { //////// //windows登录 //////// if (objLoginInfo == null && (Request.IsAuthenticated && (User.Identity is WindowsIdentity))) //////// { //////// var windowsIdentity = (WindowsIdentity)User.Identity; //////// //获取用户 //////// var strUser = SysCommon.GetUserName(windowsIdentity); //////// //数据库获取设置信息 //////// BaseService<SysUser> objServ = new BaseService<SysUser>(); //////// var obj = objServ.Entities.Where(a => a.LillyId == strUser).FirstOrDefault(); //////// if (obj != null) //////// { //////// objLoginInfo = obj; //////// Session["UserInfo"] = objLoginInfo; //////// //登录日志 //////// BaseService<Logs> objServLogs = new BaseService<Logs>(); //////// objServLogs.Insert(new Logs() //////// { //////// LogCate = "AdminLogin", //////// LogContent = "登录成功", //////// CreatedUserID = objLoginInfo.Id.ToString(), //////// CreatedUserName = objLoginInfo.LillyId //////// }); //////// } //////// } //////// // //////// // if (filterContext. //////// if (filterContext.RequestContext.HttpContext.Request.IsAjaxRequest()) //////// { //////// AjaxResult<int> result = new AjaxResult<int>(); //////// result.Message = new JsonMessage((int)HttpStatusCode.Unauthorized, "Please login"); //////// filterContext.Result = Json(result, JsonRequestBehavior.AllowGet); //////// } //////// else //////// { //////// //Redirect() //////// filterContext.Result = Redirect("~/Account/Login"); //////// } //////// // return; //////// } ////////if (objLoginInfo != null) ////////{ //////// _BaseService.LoginUserID = objLoginInfo.Id; //////// _BaseService.LoginUserName = objLoginInfo.LillyId; //////// SetLanguage("EN"); ////////} ////////// System.Threading.Thread.Sleep(5000); //////// //Logger log = Logger.GetLogger(filterContext.ActionDescriptor.ControllerDescriptor.ControllerType.FullName, CurrentUserInfo.USERREALNAME); //////// //log.Debug(WEBUI.Common.LogHelper.GetActionInfo(filterContext)); //////// //lstMenus=Session["UserMenus"] as List<BASE_SYSMENU>; base.OnActionExecuting(filterContext); }