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<ResMenu> _UserMenu;
|
private const string _SessionMenu = "WMS-SESSION-USERMENU";
|
|
private UserGetBtn _UserBtn;
|
private const string _SessionBtn = "WMS-SESSION-USERBTN";
|
|
|
///<summary>
|
///地址记忆
|
///</summary>
|
public string Path
|
{
|
get
|
{
|
return _path;
|
}
|
set
|
{
|
_path = value;
|
}
|
}
|
/// <summary>
|
/// 登陆用户
|
/// </summary>
|
public UserInfo LoginUser
|
{
|
get
|
{
|
_loginUser = Session[_SessionKey] as UserInfo;
|
return _loginUser;
|
}
|
set
|
{
|
if (value != null)
|
{
|
Session[_SessionKey] = value;
|
}
|
_loginUser = value;
|
}
|
}
|
|
public List<ResMenu> UserMenu
|
{
|
get
|
{
|
_UserMenu = Session[_SessionMenu] as List<ResMenu>; ;
|
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;
|
}
|
}
|
|
/// <summary>
|
/// 登录用户名
|
/// </summary>
|
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;
|
}
|
}
|
|
/// <summary>
|
/// 所属部门ID add liudl 记录部门ID
|
/// </summary>
|
public string LoginDepartNum
|
{
|
get
|
{
|
if (this.LoginUser != null)
|
{
|
return this.LoginUser.DepartNum;
|
}
|
return string.Empty;
|
}
|
}
|
|
/// <summary>
|
/// 登录用户名
|
/// </summary>
|
public string LoginUserCode
|
{
|
get
|
{
|
if (this.LoginUser != null)
|
{
|
return this.LoginUser.UserCode;
|
}
|
return string.Empty;
|
}
|
}
|
|
/// <summary>
|
/// 默认出货口
|
/// </summary>
|
public string LoginAccessCode
|
{
|
get
|
{
|
if (this.LoginUser != null)
|
{
|
return this.LoginUser.AccessCode;
|
}
|
return string.Empty;
|
}
|
}
|
|
/// <summary>
|
/// 判断用户是否登录 登录返回true 未登录返回false
|
/// </summary>
|
/// <returns></returns>
|
public bool IsLogin()
|
{
|
return this.LoginUser != null;
|
}
|
/// <summary>
|
/// 设置用户信息
|
/// </summary>
|
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("");
|
//}
|
}
|
|
/// <summary>
|
/// 退出系统
|
/// </summary>
|
protected void RemoveLogin()
|
{
|
Session.Remove(_SessionMenu);
|
Session.Remove(_SessionKey);
|
}
|
}
|
|
}
|