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
{
///
/// 登录账户控制
///
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 权限
///
/// 设置用户权限
///
///
public static void SetLimit(Hashtable actionList)
{
HttpContext.Current.Session[LIMIT_KEY] = actionList;
}
///
/// 取得用户权限
///
/// 用户权限
public static Hashtable GetLimit()
{
return (Hashtable)HttpContext.Current.Session[LIMIT_KEY];
}
#endregion
#region 菜单
///
/// 设置XML菜单
///
///
public static void SetXmlMenu(XmlNodeList xmlmenu)
{
HttpContext.Current.Session[MENU_KEY] = xmlmenu;
}
///
/// 取得XML菜单
///
/// 菜单xml
public static XmlNodeList GetXmlMenu()
{
return (XmlNodeList)HttpContext.Current.Session[MENU_KEY];
}
#endregion
#region 登录管理
///
/// 设置登录信息
///
/// 信息
public static void SetLoginInfo(LoginInfo info)
{
HttpContext.Current.Session[ACCOUNT_KEY] = info;
}
///
/// 登出
///
public static void Logout()
{
HttpContext.Current.Session.Abandon();
}
///
/// 判断当前用户Session是否过期
///
///
public static bool IsLogin()
{
#region
return (HttpContext.Current.Session[ACCOUNT_KEY] != null);
#endregion
}
///
/// 取当登录信息
///
/// 用户实体
public static LoginInfo GetLoginInfo()
{
#region
return GetLoginInfo("");
#endregion
}
///
/// 取当前用户实体
///
/// 异常生发时处理页
/// 用户实体
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
}
}