| | |
| | | |
| | | |
| | | using Common; |
| | | using System; |
| | | using System.Web; |
| | | |
| | | public class PageContext<T> : HandlerContext where T : ISessionObject |
| | | { |
| | | public bool IsValid |
| | | { |
| | | get |
| | | public bool IsValid |
| | | { |
| | | return (object) this.SessionObject != null; |
| | | get |
| | | { |
| | | return (object)this.SessionObject != null; |
| | | } |
| | | } |
| | | } |
| | | |
| | | public T SessionObject |
| | | { |
| | | get |
| | | public T SessionObject |
| | | { |
| | | return (T) this.Context.Session["SO"]; |
| | | get |
| | | { |
| | | return (T)this.Context.Session["SO"]; |
| | | } |
| | | set |
| | | { |
| | | this.Context.Session["SO"] = (object)value; |
| | | } |
| | | } |
| | | set |
| | | |
| | | public string OperatorID |
| | | { |
| | | this.Context.Session["SO"] = (object) value; |
| | | get |
| | | { |
| | | return this.SessionObject.Account; |
| | | } |
| | | } |
| | | } |
| | | |
| | | public string OperatorID |
| | | { |
| | | get |
| | | public PageContext(HttpContext context) |
| | | : base(context) |
| | | { |
| | | return this.SessionObject.Account; |
| | | } |
| | | } |
| | | |
| | | public PageContext(HttpContext context) |
| | | : base(context) |
| | | { |
| | | } |
| | | public void Reset() |
| | | { |
| | | this.SessionObject = default(T); |
| | | this.Session.Abandon(); |
| | | } |
| | | |
| | | 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 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 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 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); |
| | | } |
| | | public string[] GetSubMenuArray(string functionID) |
| | | { |
| | | return this.SessionObject.GetSubMenuArray(functionID); |
| | | } |
| | | } |