|
using Common;
|
using System;
|
using System.Web;
|
|
public class PageContext<T> : HandlerContext where T : ISessionObject
|
{
|
public bool IsValid
|
{
|
get
|
{
|
return (object) this.SessionObject != null;
|
}
|
}
|
|
public T SessionObject
|
{
|
get
|
{
|
return (T) this.Context.Session["SO"];
|
}
|
set
|
{
|
this.Context.Session["SO"] = (object) value;
|
}
|
}
|
|
public string OperatorID
|
{
|
get
|
{
|
return this.SessionObject.Account;
|
}
|
}
|
|
public PageContext(HttpContext context)
|
: base(context)
|
{
|
}
|
|
public void Reset()
|
{
|
this.SessionObject = default (T);
|
this.Session.Abandon();
|
}
|
|
public void CheckRight(string functionID, FailedOperation failedOperation)
|
{
|
if (!this.IsValid)
|
throw new InvalidOperationException("会话超时,请重新登录!");
|
if (!this.HasRight(functionID))
|
throw new InvalidOperationException("您当前无权限访问此功能,请与管理员确认!");
|
}
|
|
public bool HasRight(string functionID)
|
{
|
if (!this.IsValid)
|
return false;
|
return this.SessionObject.HasRight(functionID);
|
}
|
|
public bool ContainsTargetID(string functionID, string targetID)
|
{
|
if (!this.IsValid)
|
return false;
|
return this.SessionObject.ContainsTargetID(functionID, targetID);
|
}
|
|
public string[] GetSubMenuArray(string functionID)
|
{
|
return this.SessionObject.GetSubMenuArray(functionID);
|
}
|
}
|