yzh
2022-05-10 a027508b5818236d0a46bc7036394c63978a68b0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
 
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);
    }
}