<%@ WebHandler Language="C#" Class="GwStatisV3" %>
|
|
using System;
|
using System.Web;
|
using Model;
|
using Dao;
|
using System.Collections.Generic;
|
using System.Linq;
|
|
public class GwStatisV3 : PageHandler<SysUser>
|
{
|
private GwStatisV3Dao _Dao = new GwStatisV3Dao();
|
private int _userId = -1;
|
private int _userType = -1;
|
private string _account = "";
|
|
public override JsonPageResult ProcessRequestInternal(PageContext<Model.SysUser> context)
|
{
|
string action = context.GetString("action");
|
_userId = context.SessionObject.UserID;
|
_userType = context.SessionObject.UserType;
|
_account = context.SessionObject.Account;
|
|
switch (action)
|
{
|
case "loadStatisV3":
|
return LoadStatisV3(context);
|
case "getRealtimeStatis5m":
|
return GetRealtimeStatis5m(context);
|
default:
|
throw new Exception("Invalid Action=" + action);
|
}
|
}
|
|
private JsonPageResult GetRealtimeStatis5m(PageContext<SysUser> context)
|
{
|
var oplist = _Dao.GetRealtimeStatis5mOut();
|
var aplist = _Dao.GetRealtimeStatis5mIn();
|
|
return new JsonPageResult(true, new { ApList = aplist, OpList = oplist } );
|
}
|
private string GetApName(List<GwAp>aplist, int apID)
|
{
|
if (aplist == null)
|
return string.Empty;
|
|
Model.GwAp x = aplist.Find(delegate(Model.GwAp ap) { return ap.ApID == apID; });
|
|
return x == null ? string.Empty : string.Format("{0}-{1}", x.ApID, x.ApName);
|
}
|
|
private string GetOpName(List<GwOp>oplist,int opID)
|
{
|
if (oplist == null)
|
return string.Empty;
|
|
Model.GwOp x = oplist.Find(delegate(Model.GwOp op) { return op.OpID == opID; });
|
|
return x == null ? string.Empty : string.Format("{0}-{1}", x.OpID, x.OpName);
|
}
|
|
private string GetClientName(List<GwClient> clientlist, string clientID)
|
{
|
if (clientlist == null)
|
return string.Empty;
|
|
Model.GwClient x = clientlist.Find(delegate(Model.GwClient client) { return client.ClientID == clientID; });
|
|
return x == null ? string.Format("{0}", clientID) : string.Format("{0}-{1}", x.ClientID, x.ClientName);
|
}
|
|
|
//加载统计报表
|
private JsonPageResult LoadStatisV3(PageContext<SysUser> context)
|
{
|
DateTime beginTime = context.GetDateTime("begintime");
|
DateTime endTime = context.GetDateTime("endtime");
|
string clientID = context.GetString("clientid");
|
string spID = context.GetString("spid");
|
string apID = context.GetString("apid");
|
string opID = context.GetString("opid");
|
string statistype = context.GetString("statistype");
|
StatisOption statisoption = (StatisOption)context.GetInt("statisoption");
|
|
List<GwOp> opList;
|
|
using (GwOpDao dao = new GwOpDao())
|
{
|
opList = dao.LoadInfoList();
|
}
|
|
List<GwClient> clientList;
|
|
using (GwClientDao dao = new GwClientDao())
|
{
|
clientList = dao.LoadInfoList("", "", "", "");
|
}
|
|
List<GwAp> apList;
|
|
using (GwApDao dao = new GwApDao())
|
{
|
int recordCount = 0;
|
|
apList = dao.LoadInfoList("", "", "", out recordCount, 99999, 1);
|
}
|
|
//根据系统用户获取有权限客户
|
string permissionsSQL = new GwClientDao().GetClientPermissions(_userId, _userType, null);
|
|
var list = _Dao.Query(beginTime, endTime, clientID, spID, apID, opID, statistype, permissionsSQL, (StatisOption)statisoption);
|
|
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
|
|
sb.Append(@"<tr class=""header"">");
|
sb.Append(@"<th >时间</th>");
|
if ((statisoption & StatisOption.APID) == StatisOption.APID)
|
{
|
sb.Append(@"<th >接入点</th>");
|
}
|
if ((statisoption & StatisOption.OPID) == StatisOption.OPID)
|
{
|
sb.Append(@"<th >通道</th>");
|
}
|
|
if ((statisoption & StatisOption.SpID) == StatisOption.SpID)
|
{
|
sb.Append(@"<th >账户</th>");
|
}
|
if ((statisoption & StatisOption.ClientID) == StatisOption.ClientID)
|
{
|
sb.Append(@"<th >客户</th>");
|
}
|
|
sb.Append(@"<th >AP接收总量</th>");
|
sb.Append(@"<th >AP客户提交失败</th>");
|
sb.Append(@"<th >AP未转发</th>");
|
sb.Append(@"<th >AP失败</th>");
|
sb.Append(@"<th >AP未知</th>");
|
sb.Append(@"<th >AP需返还量</th>");
|
|
sb.Append(@"<th >OP提交总量</th>");
|
sb.Append(@"<th >OP失败</th>");
|
sb.Append(@"<th >OP未知</th>");
|
sb.Append(@"<th >OP成功</th>");
|
sb.Append(@"<th >OP成功率</th>");
|
sb.Append(@"<th >OP报告率</th>");
|
|
|
sb.Append(@"</tr>");
|
|
int i = 0;
|
|
foreach (GwStatisV3Item item in list)
|
{
|
sb.AppendFormat("<tr>");
|
|
sb.AppendFormat("<td>{0}</td>", item.Title);
|
|
if ((statisoption & StatisOption.APID) == StatisOption.APID)
|
{
|
sb.AppendFormat("<td>{0}</td>", GetApName(apList,item.APID));
|
}
|
if ((statisoption & StatisOption.OPID) == StatisOption.OPID)
|
{
|
sb.AppendFormat("<td>{0}</td>", GetOpName(opList,item.OPID));
|
}
|
if ((statisoption & StatisOption.SpID) == StatisOption.SpID)
|
{
|
sb.AppendFormat("<td>{0}</td>", item.SpID);
|
}
|
if ((statisoption & StatisOption.ClientID) == StatisOption.ClientID)
|
{
|
sb.AppendFormat("<td>{0}</td>", GetClientName(clientList,item.ClientID));
|
}
|
|
int opTotal = item.OPStatus0 + item.OPStatus1 + item.OPStatus2 + item.OPStatus3 + item.OPStatus4 + item.OPStatus5;
|
int apTotal = item.APStatus0 + item.APStatus1 + item.APStatus2 + item.APStatus3 + item.APStatus4 + item.APStatus5;
|
|
sb.AppendFormat("<td>{0}</td><td>{1}</td><td>{2}</td>",
|
apTotal, item.APStatus1,item.APStatus0);
|
|
sb.AppendFormat(@"<td>{0}</td>", item.APStatus3 + item.APStatus5);
|
sb.AppendFormat(@"<td>{0}</td>", item.APStatus2);
|
sb.AppendFormat(@"<td>{0}</td>", item.APStatus3 + item.APStatus2 + item.APStatus5 + item.APStatus0);
|
|
sb.AppendFormat(@"<td>{0}</td>",opTotal);
|
|
sb.AppendFormat("<td>{0}</td><td>{1}</td><td>{2}</td>",
|
item.OPStatus5,
|
item.OPStatus2,
|
item.OPStatus4);
|
|
sb.AppendFormat(@"<td>{0}%</td>", Divide(item.OPStatus4 * 100, opTotal));
|
sb.AppendFormat(@"<td>{0}%</td>", 100 - Divide(item.OPStatus2 * 100, opTotal));
|
|
|
sb.AppendFormat("</tr>");
|
}
|
|
return new JsonPageResult(true, sb.ToString());
|
}
|
|
|
public decimal Divide(decimal v, decimal total)
|
{
|
if (total == 0)
|
{
|
return 0;
|
}
|
|
return Math.Round(v / total, 2);
|
}
|
|
|
|
|
}
|