using System.Collections.Generic; using Model; using System.Web.Mvc; namespace Lib { public class MainPage : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); //设置的请求地址 this.Path = requestContext.HttpContext.Request.Path; //设置用户信息 SetUserInfo(); } private UserInfo _loginUser; private string _path; private const string _SessionKey = "WMS-SESSION-USERINFO"; private List _UserMenu; private const string _SessionMenu = "WMS-SESSION-USERMENU"; private UserGetBtn _UserBtn; private const string _SessionBtn = "WMS-SESSION-USERBTN"; /// ///地址记忆 /// public string Path { get { return _path; } set { _path = value; } } /// /// 登陆用户 /// public UserInfo LoginUser { get { _loginUser = Session[_SessionKey] as UserInfo; return _loginUser; } set { if (value != null) { Session[_SessionKey] = value; } _loginUser = value; } } public List UserMenu { get { _UserMenu = Session[_SessionMenu] as List; ; return _UserMenu; } set { if (value != null) { Session[_SessionMenu] = value; } _UserMenu = value; } } public UserGetBtn UserBtn { get { _UserBtn = Session[_SessionBtn] as UserGetBtn; return _UserBtn; } set { if (value != null) { Session[_SessionBtn] = value; } _UserBtn = value; } } /// /// 登录用户名 /// public string LoginUserName { get { if (this.LoginUser != null) { return this.LoginUser.Username; } return string.Empty; } } public string LoginName { get { if (this.LoginUser != null) { return this.LoginUser.RealName; } return string.Empty; } } /// /// 所属部门ID add liudl 记录部门ID /// public string LoginDepartNum { get { if (this.LoginUser != null) { return this.LoginUser.DepartNum; } return string.Empty; } } /// /// 登录用户名 /// public string LoginUserCode { get { if (this.LoginUser != null) { return this.LoginUser.UserCode; } return string.Empty; } } /// /// 默认出货口 /// public string LoginAccessCode { get { if (this.LoginUser != null) { return this.LoginUser.AccessCode; } return string.Empty; } } /// /// 判断用户是否登录 登录返回true 未登录返回false /// /// public bool IsLogin() { return this.LoginUser != null; } /// /// 设置用户信息 /// private void SetUserInfo() { if (IsLogin()) { ViewBag.LoginUser = this.LoginUser; ViewBag.LoginUserCode = this.LoginUserCode; ViewBag.LoginUserName = this.LoginUserName; ViewBag.LoginDepartNum = this.LoginDepartNum; } //string login = "login"; //string v2 = ResourceManager.GetSettingEntity(login + "sign").Value; //int index = v2.LastIndex("TwbAIII0zXk9"); //if (index != 90) //{ // throw new Exception(""); //} } /// /// 退出系统 /// protected void RemoveLogin() { Session.Remove(_SessionMenu); Session.Remove(_SessionKey); } } }