wangsheng
2022-03-22 ee15dec5d91adbd1bdf15b26915b79751c17e481
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
 
using Common;
using Dao;
using Model;
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.HtmlControls;
 
public partial class GwStatis : PageBase<SysUser>, IRequiresSessionState
{
  
    private List<GwOp> OpList;
    private List<GwClient> ClientList;
    private List<GwAp> ApList;
 
   
 
    public StatisOption SelectedOptions { get; set; }
 
    public DateTime BeginTime { get; set; }
 
    public DateTime EndTime { get; set; }
 
    public string StatisType { get; set; }
 
    public string SelectedClientID { get; set; }
 
    public string SelectedSpID { get; set; }
 
    public string SelectedAPID { get; set; }
 
    public string SelectedOPID { get; set; }
 
    protected void Page_Load(object sender, EventArgs e)
    {
        this.CheckRight("502", FailedOperation.ErrorMsgOnly);
        using (GwOpDao gwOpDao = new GwOpDao())
            this.OpList = gwOpDao.LoadInfoList();
        using (GwClientDao gwClientDao = new GwClientDao())
            this.ClientList = gwClientDao.LoadInfoList("", "", "", "");
        using (GwApDao gwApDao = new GwApDao())
            this.ApList = gwApDao.LoadInfoList();
        if (this.IsPostBack)
        {
            this.QueryAndFillTable();
        }
        else
        {
            this.SelectedOptions = StatisOption.None;
            this.BeginTime = DateTime.Now.AddDays(-7.0).Date;
            this.EndTime = DateTime.Now.AddDays(1.0).Date;
            this.SelectedClientID = string.Empty;
            this.SelectedSpID = string.Empty;
        }
    }
 
    private string GetApName(int apID)
    {
        if (this.ApList == null)
            return string.Empty;
        GwAp gwAp = this.ApList.Find((Predicate<GwAp>)(ap => ap.ApID == apID));
        if (gwAp != null)
            return string.Format("{0}-{1}", (object)gwAp.ApID, (object)gwAp.ApName);
        return string.Empty;
    }
 
    private string GetOpName(int opID)
    {
        if (this.OpList == null)
            return string.Empty;
        GwOp gwOp = this.OpList.Find((Predicate<GwOp>)(op => op.OpID == opID));
        if (gwOp != null)
            return string.Format("{0}-{1}", (object)gwOp.OpID, (object)gwOp.OpName);
        return string.Empty;
    }
 
    private string GetClientName(string clientID)
    {
        if (this.ClientList == null)
            return string.Empty;
        GwClient gwClient = this.ClientList.Find((Predicate<GwClient>)(client => client.ClientID == clientID));
        if (gwClient != null)
            return string.Format("{0}-{1}", (object)gwClient.ClientID, (object)gwClient.ClientName);
        return string.Format("{0}", (object)clientID);
    }
 
    protected string GenerateAPIDOptions()
    {
        StringBuilder stringBuilder = new StringBuilder();
        if (this.ApList.Count == 0)
        {
            stringBuilder.Append("<option value=\"\">暂无接入点信息</option>");
        }
        else
        {
            stringBuilder.Append("<option value=\"\">所有接入点信息</option>");
            foreach (GwAp gwAp in this.ApList)
                stringBuilder.AppendFormat("<option value=\"{0}\" {2}>{0}-{1}</option>", (object)gwAp.ApID, (object)gwAp.ApName, gwAp.ApID.ToString() == this.SelectedAPID ? (object)"selected" : (object)"");
        }
        return stringBuilder.ToString();
    }
 
    protected string GenerateOPIDOptions()
    {
        StringBuilder stringBuilder = new StringBuilder();
        if (this.OpList.Count == 0)
        {
            stringBuilder.Append("<option value=\"\">暂无通道信息</option>");
        }
        else
        {
            stringBuilder.Append("<option value=\"\">所有通道信息</option>");
            foreach (GwOp gwOp in this.OpList)
            {
                if (this.AppContext.ContainsTargetID("502", gwOp.OpID.ToString()))
                    stringBuilder.AppendFormat("<option value=\"{0}\" {2}>{0}-{1}</option>", (object)gwOp.OpID, (object)gwOp.OpName, gwOp.OpID.ToString() == this.SelectedOPID ? (object)"selected" : (object)"");
            }
        }
        return stringBuilder.ToString();
    }
 
    protected string GenerateClientIDOptions()
    {
        StringBuilder stringBuilder = new StringBuilder();
        if (this.ClientList.Count == 0)
        {
            stringBuilder.Append("<option value=\"\">暂无客户信息</option>");
        }
        else
        {
            stringBuilder.Append("<option value=\"\">所有客户</option>");
            foreach (GwClient gwClient in this.ClientList)
            {
                if (this.AppContext.HasRight("502"))
                    stringBuilder.AppendFormat("<option value=\"{0}\" {2}>{0}-{1}</option>", (object)gwClient.ClientID, (object)gwClient.ClientName, gwClient.ClientID == this.SelectedClientID ? (object)"selected" : (object)"");
            }
        }
        return stringBuilder.ToString();
    }
 
    protected string GenerateSpIDOptions()
    {
        StringBuilder stringBuilder = new StringBuilder();
        using (GwSpDao gwSpDao = new GwSpDao())
        {
            List<GwSp> list = gwSpDao.LoadInfoList("", "", "");
            if (list.Count == 0)
            {
                stringBuilder.Append("<option value=\"\">暂无客户信息</option>");
            }
            else
            {
                stringBuilder.Append("<option value=\"\">所有帐号</option>");
                foreach (GwSp gwSp in list)
                {
                    if (this.AppContext.HasRight("502"))
                        stringBuilder.AppendFormat("<option value=\"{0}\" {3}>{1}-{2}</option>", (object)gwSp.SpID, (object)gwSp.ClientID, (object)gwSp.SpID, gwSp.SpID == this.SelectedSpID ? (object)"selected" : (object)"");
                }
            }
            return stringBuilder.ToString();
        }
    }
 
    private void QueryAndFillTable()
    {
        DateTime dateTime1 = DateTime.Parse(DateTime.Now.AddDays(-1.0).ToString("yyyy-MM-dd"));
        DateTime dateTime2 = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
        if (!string.IsNullOrEmpty(this.Request["begintime"].ToString()))
            dateTime1 = DateTime.Parse(this.Request["begintime"]);
        if (!string.IsNullOrEmpty(this.Request["endtime"].ToString()))
            dateTime2 = DateTime.Parse(this.Request["endtime"]);
        this.BeginTime = dateTime1;
        this.EndTime = dateTime2;
        this.SelectedSpID = this.Request["SpID"];
        this.SelectedClientID = this.Request["ClientID"];
        this.StatisType = this.Request["StatisType"];
        this.SelectedOPID = this.Request["OPID"];
        this.SelectedAPID = this.Request["APID"];
        foreach (string str in (this.Request["StatisOption"] == null ? string.Empty : this.Request["StatisOption"]).Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
            this.SelectedOptions = this.SelectedOptions | (StatisOption)Convert.ToInt32(str);
        List<string> list1 = new List<string>();
        if (string.IsNullOrEmpty(this.SelectedOPID))
        {
            string[] subMenuArray = this.AppContext.GetSubMenuArray("502");
            if (subMenuArray.Length > 0)
            {
                list1.AddRange((IEnumerable<string>)subMenuArray);
            }
            else
            {
                foreach (GwOp gwOp in this.OpList)
                    list1.Add(gwOp.OpID.ToString());
            }
        }
        else
            list1.Add(this.SelectedOPID);
        using (GwStatisDao gwStatisDao = new GwStatisDao())
        {
            List<GwStatisItem> list2 = gwStatisDao.Query(this.BeginTime, this.EndTime, this.SelectedClientID, this.SelectedSpID, this.SelectedAPID, list1.ToArray(), this.StatisType, this.SelectedOptions);
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.Append("<tr class=\"header\">");
            stringBuilder.Append("<th nowrap=\"nowrap\">时间</th>");
            if ((this.SelectedOptions & StatisOption.APID) == StatisOption.APID)
                stringBuilder.Append("<th nowrap=\"nowrap\">接入点</th>");
            if ((this.SelectedOptions & StatisOption.OPID) == StatisOption.OPID)
                stringBuilder.Append("<th nowrap=\"nowrap\">通道</th>");
            if ((this.SelectedOptions & StatisOption.SpID) == StatisOption.SpID)
                stringBuilder.Append("<th nowrap=\"nowrap\">账户</th>");
            if ((this.SelectedOptions & StatisOption.ClientID) == StatisOption.ClientID)
                stringBuilder.Append("<th nowrap=\"nowrap\">客户</th>");
            stringBuilder.Append("<th nowrap=\"nowrap\">AP总量</th>");
            stringBuilder.Append("<th nowrap=\"nowrap\">AP失败</th>");
            stringBuilder.Append("<th nowrap=\"nowrap\">AP拒绝</th>");
            stringBuilder.Append("<th nowrap=\"nowrap\">OP外发</th>");
            stringBuilder.Append("<th nowrap=\"nowrap\">OP成功</th>");
            stringBuilder.Append("<th nowrap=\"nowrap\">OP失败</th>");
            stringBuilder.Append("<th nowrap=\"nowrap\">OP未知</th>");
            stringBuilder.Append("<th nowrap=\"nowrap\">OP成功率</th>");
            stringBuilder.Append("<th nowrap=\"nowrap\">OP报告率</th>");
            stringBuilder.Append("</tr>");
            int num = 0;
            foreach (GwStatisItem gwStatisItem in list2)
            {
                stringBuilder.AppendFormat("<tr class=\"row-" + (object)(++num % 2) + "\">");
                stringBuilder.AppendFormat("<td>{0}</td>", (object)gwStatisItem.Title);
                if ((this.SelectedOptions & StatisOption.APID) == StatisOption.APID)
                    stringBuilder.AppendFormat("<td>{0}</td>", (object)this.GetApName(gwStatisItem.APID));
                if ((this.SelectedOptions & StatisOption.OPID) == StatisOption.OPID)
                    stringBuilder.AppendFormat("<td>{0}</td>", (object)this.GetOpName(gwStatisItem.OPID));
                if ((this.SelectedOptions & StatisOption.SpID) == StatisOption.SpID)
                    stringBuilder.AppendFormat("<td>{0}</td>", (object)gwStatisItem.SpID);
                if ((this.SelectedOptions & StatisOption.ClientID) == StatisOption.ClientID)
                    stringBuilder.AppendFormat("<td>{0}</td>", (object)this.GetClientName(gwStatisItem.ClientID));
                stringBuilder.AppendFormat("<td>{0}</td><td>{1}</td><td>{2}</td>", (object)gwStatisItem.CntTOTAL, (object)gwStatisItem.CntAPFAILED, (object)gwStatisItem.CntREJECTED);
                stringBuilder.AppendFormat("<td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td>", (object)gwStatisItem.CntSUBMITED, (object)gwStatisItem.CntDELIVRD, (object)gwStatisItem.CntOPFAILED, (object)gwStatisItem.CntUnknown);
                stringBuilder.AppendFormat("<td>{0}%</td>", (object)this.Divide((Decimal)(gwStatisItem.CntDELIVRD * 100), (Decimal)gwStatisItem.CntSUBMITED));
                stringBuilder.AppendFormat("<td>{0}%</td>", (object)(new Decimal(100) - this.Divide((Decimal)(gwStatisItem.CntUnknown * 100), (Decimal)gwStatisItem.CntSUBMITED)));
                stringBuilder.AppendFormat("</tr>");
            }
            this.ViewState["list"] = (object)stringBuilder.ToString();
        }
    }
 
    public Decimal Divide(Decimal v, Decimal total)
    {
        if (total == new Decimal(0))
            return new Decimal(0);
        return Math.Round(v / total, 2);
    }
}