wzp
2021-09-16 96eac0ce567dc3eef6900ce57dcb4c029fac2082
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
 
using Dao;
using Model;
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.Profile;
using System.Web.SessionState;
 
public partial class _GwSpUpdate : PageBase<SysUser>, IRequiresSessionState
{
    protected List<GwAp> ApList;
    protected List<GwOp> OpList;
 
    
 
    public GwSp GwSp { get; protected set; }
 
    public string SpID
    {
        get
        {
            return this.AppContext.GetString("spid");
        }
    }
 
    public string ActionTitle
    {
        get
        {
            return !string.IsNullOrEmpty(this.SpID) ? "编辑账户" : "创建新账户";
        }
    }
 
    public IEnumerable<GwDiverter> DiverterList { get; set; }
 
    protected void Page_Load(object sender, EventArgs e)
    {
        using (GwApDao gwApDao = new GwApDao())
            this.ApList = gwApDao.LoadInfoList();
        using (GwOpDao gwOpDao = new GwOpDao())
            this.OpList = gwOpDao.LoadInfoList();
        using (GwDiverterDao gwDiverterDao = new GwDiverterDao())
            this.DiverterList = (IEnumerable<GwDiverter>)gwDiverterDao.LoadList();
        using (GwSpDao gwSpDao = new GwSpDao())
        {
            if (!string.IsNullOrEmpty(this.SpID))
            {
                this.GwSp = gwSpDao.Get(this.SpID);
                int combinationMode = this.GwSp.CombinationMode;
            }
            else
            {
                this.GwSp = new GwSp();
                this.GwSp.Price = 40;
                this.GwSp.FeeLongLength = 67;
                this.GwSp.FeeShortLength = 70;
                this.GwSp.MaxConnCount = 1;
                this.GwSp.Threshold = 30;
                this.GwSp.MCPM = 10;
                this.GwSp.McExpression = "0;0;0;10;20;40;80;240;480";
                this.GwSp.Status = 1;
                this.GwSp.BlackMode = 1;
                this.GwSp.DiverterID = 0;
                this.GwSp.Password = "123456";
                this.GwSp.AccessCode = gwSpDao.GetNextAccessCode();
                this.GwSp.ClientIp = "0.0.0.0";
                this.GwSp.ForceSignFlag = 0;
                this.GwSp.ForceSign = "";
                this.GwSp.AccessCodeMode = 0;
                this.GwSp.ExtnoExtensionMode = 0;
                this.GwSp.CombinationMode = 0;
            }
        }
    }
 
    public string McCount(int i, string mcExpression)
    {
        string str = "";
        if (!string.IsNullOrEmpty(mcExpression))
            str = mcExpression.Split(new char[1]
      {
        ';'
      }, StringSplitOptions.RemoveEmptyEntries)[i];
        return str;
    }
 
    public string GetDiverterOptions(int diverterID)
    {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.AppendFormat("<option value='0'>不设置导流策略</option>");
        foreach (GwDiverter gwDiverter in this.DiverterList)
            stringBuilder.AppendFormat("<option value='{0}' {2}>{1}</option>", (object)gwDiverter.DiverterID, (object)gwDiverter.DiverterName, gwDiverter.DiverterID == diverterID ? (object)"selected" : (object)"");
        return stringBuilder.ToString();
    }
 
 
    /// <summary>
    /// 获取通道组
    /// </summary>
    /// <param name="groupID"></param>
    /// <returns></returns>
    public string GetOpGroupOptions(int groupID)
    {
        StringBuilder stringBuilder = new StringBuilder();
        using (GwOpGroupDao gwOpGroupDao = new GwOpGroupDao())
        {
            List<GwOpGroup> groupList = gwOpGroupDao.GetGroupList();
            stringBuilder.AppendFormat("<option value=\"0\">不设置</option>");
            foreach (GwOpGroup gwOpGroup in groupList)
                stringBuilder.AppendFormat("<option value='{0}' {2}>{1}</option>", (object)gwOpGroup.GroupID, (object)gwOpGroup.GroupName, gwOpGroup.GroupID == groupID ? (object)"selected" : (object)"");
        }
        return stringBuilder.ToString();
    }
 
 
 
 
    public string GetAPOptions(int apId)
    {
        string str = "";
        if (this.ApList.Count == 0)
            return "<option value='0'>暂无AP节点信息</option>";
        foreach (GwAp gwAp in this.ApList)
            str = apId != gwAp.ApID ? str + string.Format("<option value=\"{0}\" >{1}</option>", (object)gwAp.ApID, (object)gwAp.ApName) : str + string.Format("<option value=\"{0}\" selected>{1}</option>", (object)gwAp.ApID, (object)gwAp.ApName);
        return str;
    }
 
 
    //获取通道信息
    public string GetOpOptions(int opId)
    {
        StringBuilder stringBuilder = new StringBuilder();
        if (this.OpList.Count == 0)
            return "<option value=''>无通道信息</option>";
        stringBuilder.AppendFormat("<option value=\"{0}\" selected>{1}</option>", (object)0, (object)"NA");
        foreach (GwOp gwOp in this.OpList)
        {
            //停用的通道不再显示
            if (gwOp.OpStatus == 0)
            {
                continue;
            }
 
            if (opId == gwOp.OpID)
                stringBuilder.AppendFormat("<option value=\"{0}\" selected>{0}-{1}</option>", (object)gwOp.OpID, (object)gwOp.OpName);
            else
                stringBuilder.AppendFormat("<option value=\"{0}\">{0}-{1}</option>", (object)gwOp.OpID, (object)gwOp.OpName);
        }
        return stringBuilder.ToString();
    }
 
    public string GetStrategyOptions(int strategyID)
    {
        GwStrategyDao gwStrategyDao = new GwStrategyDao();
        string str = "";
        int recordcount = 0;
        List<GwStrategy> list = gwStrategyDao.LoadInfoList("", "", out recordcount, 9999, 1);
        if (recordcount == 0)
            return "<option value=''>暂无内容策略配置</option>";
        foreach (GwStrategy gwStrategy in list)
        {
            if (strategyID == gwStrategy.StrategyId)
                str = str + (object)"<option value=\"" +  (object)gwStrategy.StrategyId + "\" selected>" + gwStrategy.StrategyName + "</option>";
            else
                str = str + (object)"<option value=\"" +  (object)gwStrategy.StrategyId + "\">" + gwStrategy.StrategyName + "</option>";
        }
        return str;
    }
 
    public string GetClientOptions(string clientId)
    {
        using (GwClientDao gwClientDao = new GwClientDao())
        {
            string str = "";
            List<GwClient> list = gwClientDao.LoadInfoList("", "", "", "");
            if (list.Count == 0)
            {
                str += string.Format("<option value=\"\">尚未创建客户信息</option>");
            }
            else
            {
                foreach (GwClient gwClient in list)
                    str = !(clientId == gwClient.ClientID) ? str + string.Format("<option value=\"{0}\">{0}-{1}</option>", (object)gwClient.ClientID, (object)gwClient.ClientName) : str + string.Format("<option value=\"{0}\" selected>{0}-{1}</option>", (object)gwClient.ClientID, (object)gwClient.ClientName);
            }
            return str;
        }
    }
 
    public string GetGwspCtpattern(string spid)
    {
        using (GwSpDao gwSpDao = new GwSpDao())
        {
            SpCTPatternInfo pattern = gwSpDao.GetPattern(spid);
            string str = "";
            if (pattern != null)
                str = pattern.Pattern;
            return str;
        }
    }
 
 
    //获取报备的内容
    public int GetGwspEnabled(string spid)
    {
        using (GwSpDao gwSpDao = new GwSpDao())
        {
            SpCTPatternInfo pattern = gwSpDao.GetPattern(spid);
            int num = 0;
            if (pattern != null)
                num = pattern.Enabled;
            return num;
        }
    }
}