protected override void OnInit(EventArgs e) { _Util = new UserProfilesRelatedUtil(_SessionEx); base.OnInit(e); try { ScriptManager sm = System.Web.UI.ScriptManager.GetCurrent(Page); _IsPartial = X.IsAjaxRequest || (sm != null && sm.IsInAsyncPostBack); _SetInitialStates(_IsPartial); } catch (Exception ex) { if (_HandleException(new ExceptionFilter(ex), BasePage.Steps.Init)) { return; } throw ex; } }
/// <summary> /// 准备个性化会话工作对象 /// </summary> protected void _PrepareContext() { _SessionEx = new HttpSessionStateWrapper(Session, _CurrentTime); _SessionEx.Dirty += d => { var context = _DTContext <CommonContext>(true); switch (d) { case HttpSessionStateWrapper.Types.Role: var roles = ( from r in context.AS_Roles join u in context.AS_UserInRoles on r.RoleId equals u.RoleId select r.RoleName).ToArray(); _SessionEx.Set <string[]>(roles, HttpSessionStateWrapper.Keys.RoleIds); _SessionEx.SetDirty(HttpSessionStateWrapper.Types.Role, false); break; case HttpSessionStateWrapper.Types.Portlet: // 在全局 portlet 池中筛选出有权限访问的 portlet var portlets = new List <string>(); Global.Cache.Portlets.ForEach(p => { if (Global.Cache.AccessIds.ContainsKey(p.Id)) { var accessId = Global.Cache.AccessIds[p.Id]; if (AC(accessId.ToString())) { portlets.Add(p.Path); } } else { portlets.Add(p.Path); } }); _SessionEx.Set <string[]>(portlets.ToArray(), HttpSessionStateWrapper.Keys.Portlets); _SessionEx.SetDirty(HttpSessionStateWrapper.Types.Portlet, false); break; } }; try { _SessionEx.LastVisitTime = _CurrentTime; _SessionEx.LastVisitUrl = Request.Url.ToStringEx(); _SessionEx.LastVisitUrlReferrer = Request.UrlReferrer.ToStringEx(); _SessionEx.LastVisitUserAgent = Request.UserAgent; _SessionEx.LastVisitUserHostAddress = Request.UserHostAddress; _SessionEx.LastVisitUserHostName = Request.UserHostName; } catch { } // 同步当前线程 _Auth.SynThread(p => { _Logined = _SessionEx.Logined; if (_Logined) { return; } _Logined = !p.IsPublic && !p.IsGuest; _SessionEx.UserName = p.Identity.Name; _SessionEx.UniqueId = p.Id; if (_Logined && !_SessionEx.Logined) { _SynSession(); } }); _Util = new UserProfilesRelatedUtil(_SessionEx); _DTService.Initialize(_SessionEx, _CurrentTime, Global.Cache); }