天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

166 lines
4.0 KiB

using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Xml;
using QMAPP.Entity.Sys;
using QMFrameWork.WebUI.Menu;
namespace QMAPP.Common.Web.Controllers
{
/// <summary>
/// 登录账户控制
/// </summary>
public class AccountController
{
#region 变量
//登录用户
private const string ACCOUNT_KEY = "ACCOUNT_KEY";
//Session Key
private const string PROACCOUNT_KEY = "PROACCOUNT_KEY";
//Session Key
private const string LOGACCOUNT_KEY = "LOGACCOUNT_KEY";
//本地化
private const string LOCAL_KEY = "LOCAL_KEY";
//校验码
private const string CHECKCODE_KEY = "CHECKCODE_KEY";
//信息
private const string MESSAGE_KEY = "MESSAGE_KEY";
//异常
private const string MESSAGE_EX = "MESSAGE_EX";
//权限
private const string LIMIT_KEY = "LIMIT_KEY";
//客户
private const string CUSTOMER_KEY = "CUSTOMER_KEY";
//菜单
private const string MENU_KEY = "MENU_KEY";
#endregion
#region 权限
/// <summary>
/// 设置用户权限
/// </summary>
/// <param name="pdt"></param>
public static void SetLimit(Hashtable actionList)
{
HttpContext.Current.Session[LIMIT_KEY] = actionList;
}
/// <summary>
/// 取得用户权限
/// </summary>
/// <returns>用户权限</returns>
public static Hashtable GetLimit()
{
return (Hashtable)HttpContext.Current.Session[LIMIT_KEY];
}
#endregion
#region 菜单
/// <summary>
/// 设置XML菜单
/// </summary>
/// <param name="pdt"></param>
public static void SetXmlMenu(XmlNodeList xmlmenu)
{
HttpContext.Current.Session[MENU_KEY] = xmlmenu;
}
/// <summary>
/// 取得XML菜单
/// </summary>
/// <returns>菜单xml</returns>
public static XmlNodeList GetXmlMenu()
{
return (XmlNodeList)HttpContext.Current.Session[MENU_KEY];
}
#endregion
#region 登录管理
/// <summary>
/// 设置登录信息
/// </summary>
/// <param name="info">信息</param>
public static void SetLoginInfo(LoginInfo info)
{
HttpContext.Current.Session[ACCOUNT_KEY] = info;
}
/// <summary>
/// 登出
/// </summary>
public static void Logout()
{
HttpContext.Current.Session.Abandon();
}
/// <summary>
/// 判断当前用户Session是否过期
/// </summary>
/// <returns></returns>
public static bool IsLogin()
{
#region
return (HttpContext.Current.Session[ACCOUNT_KEY] != null);
#endregion
}
/// <summary>
/// 取当登录信息
/// </summary>
/// <returns>用户实体</returns>
public static LoginInfo GetLoginInfo()
{
#region
return GetLoginInfo("");
#endregion
}
/// <summary>
/// 取当前用户实体
/// </summary>
/// <param name="pUrl">异常生发时处理页</param>
/// <returns>用户实体</returns>
public static LoginInfo GetLoginInfo(string pUrl)
{
#region
LoginInfo myAccount = (LoginInfo)HttpContext.Current.Session[ACCOUNT_KEY];
if (myAccount == null)
{
if (string.IsNullOrEmpty(pUrl) == false)
{
HttpContext.Current.Response.Redirect(pUrl, true);
}
return null;
}
else
{
return myAccount;
}
#endregion
}
#endregion
}
}