wzp
2022-11-24 a5b2428bc6ebac0210e4c552f61e7c5e1f1c9134
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
 
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;
    protected List<GwProduct> GwProductList;
 
    private int _userId = -1;
    private string _userType = "";
    private string _account = "";
 
 
    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)
    {
        _userId = this.AppContext.SessionObject.UserID;
        _userType = this.AppContext.SessionObject.UserType;
        _account = this.AppContext.SessionObject.Account;
 
        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;
 
                this.GwSp.SubPackageNum = 4000;
                this.GwSp.SingleSubmitMinRestrict = 0;
                this.GwSp.IsDispalyPrice = 0;
                this.GwSp.DeductionMode = 1;
                this.GwSp.IsSendAudit = 0;
                this.GwSp.BelowNumAudit = 0;
                this.GwSp.AboveNumAudit = 0;
                this.GwSp.IsCumulativeAudit = 0;
                this.GwSp.CumulativeAuditNum = 0;
                this.GwSp.CumulativeAuditTime = 0;
                this.GwSp.IsSyncChildSendAudit = 0;
            }
        }
 
        //获取启用的产品分类
        using (GwProductDao gwProductDao = new GwProductDao())
        {
            GwProduct bean = new GwProduct();
            bean.Classes = 1;
            bean.IsDefault = -1;
            bean.IsEnable = -1;
            this.GwProductList = gwProductDao.getAllList(bean);
        }
 
    }
 
    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 permissionsSQL = gwClientDao.GetClientPermissions(_userId, _userType, null);
            string str = "";
            List<GwClient> list = gwClientDao.LoadInfoList("", "", "", "", permissionsSQL);
            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}\">{1}</option>", (object)gwClient.ClientID, (object)gwClient.ClientID) : str + string.Format("<option value=\"{0}\" selected>{1}</option>", (object)gwClient.ClientID, (object)gwClient.ClientID);
            }
            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;
        }
    }
 
 
    //获取产品信息
    public string GetProductOptions(string productId)
    {
        if (productId==null)
            return "<option value='0'>无</option>";
        StringBuilder stringBuilder = new StringBuilder();
        if (this.GwProductList.Count == 0)
            return "<option value='0'>无</option>";
        stringBuilder.AppendFormat("<option value=\"{0}\" >{1}</option>", (object)"", (object)"无");
        foreach (GwProduct bean in this.GwProductList)
        {
            //停用的产品分类不再显示
            if (bean.IsEnable == 0)
            {
                continue;
            }
            //类别为产品不再显示
            if (bean.Classes == 0)
            {
                continue;
            }
 
            if (productId.Equals(bean.Id))
                stringBuilder.AppendFormat("<option value=\"{0}\" selected>{1}</option>", (object)bean.Id, (object)bean.Name);
            else
                stringBuilder.AppendFormat("<option value=\"{0}\">{1}</option>", (object)bean.Id, (object)bean.Name);
        }
        return stringBuilder.ToString();
    }
 
}