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, IRequiresSessionState { private List OpList; private List ClientList; private List ApList; private int _userId = -1; private int _userType = -1; private string _account = ""; string permissionsSQL = null; 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); _userId = this.AppContext.SessionObject.UserID; _userType = this.AppContext.SessionObject.UserType; _account = this.AppContext.SessionObject.Account; permissionsSQL = new GwClientDao().GetClientPermissions(_userId, _userType, null); using (GwOpDao gwOpDao = new GwOpDao()) this.OpList = gwOpDao.LoadInfoList(); using (GwClientDao gwClientDao = new GwClientDao()) { this.ClientList = gwClientDao.LoadInfoList("", "", "", "", permissionsSQL); } 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)(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)(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)(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(""); } else { stringBuilder.Append(""); foreach (GwAp gwAp in this.ApList) stringBuilder.AppendFormat("", (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(""); } else { stringBuilder.Append(""); foreach (GwOp gwOp in this.OpList) { if (this.AppContext.ContainsTargetID("502", gwOp.OpID.ToString())) stringBuilder.AppendFormat("", (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(""); } else { stringBuilder.Append(""); foreach (GwClient gwClient in this.ClientList) { if (this.AppContext.HasRight("502")) stringBuilder.AppendFormat("", (object)gwClient.ClientID, (object)gwClient.Company, gwClient.ClientID == this.SelectedClientID ? (object)"selected" : (object)""); } } return stringBuilder.ToString(); } protected string GenerateSpIDOptions() { StringBuilder stringBuilder = new StringBuilder(); using (GwSpDao gwSpDao = new GwSpDao()) { List list = gwSpDao.LoadInfoList("", "", "", permissionsSQL); if (list.Count == 0) { stringBuilder.Append(""); } else { stringBuilder.Append(""); foreach (GwSp gwSp in list) { if (this.AppContext.HasRight("502")) stringBuilder.AppendFormat("", (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 list1 = new List(); if (string.IsNullOrEmpty(this.SelectedOPID)) { string[] subMenuArray = this.AppContext.GetSubMenuArray("502"); if (subMenuArray.Length > 0) { list1.AddRange((IEnumerable)subMenuArray); } else { foreach (GwOp gwOp in this.OpList) list1.Add(gwOp.OpID.ToString()); } } else list1.Add(this.SelectedOPID); using (GwStatisDao gwStatisDao = new GwStatisDao()) { List 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(""); stringBuilder.Append("时间"); if ((this.SelectedOptions & StatisOption.APID) == StatisOption.APID) stringBuilder.Append("接入点"); if ((this.SelectedOptions & StatisOption.OPID) == StatisOption.OPID) stringBuilder.Append("通道"); if ((this.SelectedOptions & StatisOption.SpID) == StatisOption.SpID) stringBuilder.Append("账户"); if ((this.SelectedOptions & StatisOption.ClientID) == StatisOption.ClientID) stringBuilder.Append("客户"); stringBuilder.Append("AP总量"); stringBuilder.Append("AP失败"); stringBuilder.Append("AP拒绝"); stringBuilder.Append("OP外发"); stringBuilder.Append("OP成功"); stringBuilder.Append("OP失败"); stringBuilder.Append("OP未知"); stringBuilder.Append("OP成功率"); stringBuilder.Append("OP报告率"); stringBuilder.Append(""); int num = 0; foreach (GwStatisItem gwStatisItem in list2) { stringBuilder.AppendFormat(""); stringBuilder.AppendFormat("{0}", (object)gwStatisItem.Title); if ((this.SelectedOptions & StatisOption.APID) == StatisOption.APID) stringBuilder.AppendFormat("{0}", (object)this.GetApName(gwStatisItem.APID)); if ((this.SelectedOptions & StatisOption.OPID) == StatisOption.OPID) stringBuilder.AppendFormat("{0}", (object)this.GetOpName(gwStatisItem.OPID)); if ((this.SelectedOptions & StatisOption.SpID) == StatisOption.SpID) stringBuilder.AppendFormat("{0}", (object)gwStatisItem.SpID); if ((this.SelectedOptions & StatisOption.ClientID) == StatisOption.ClientID) stringBuilder.AppendFormat("{0}", (object)this.GetClientName(gwStatisItem.ClientID)); stringBuilder.AppendFormat("{0}{1}{2}", (object)gwStatisItem.CntTOTAL, (object)gwStatisItem.CntAPFAILED, (object)gwStatisItem.CntREJECTED); stringBuilder.AppendFormat("{0}{1}{2}{3}", (object)gwStatisItem.CntSUBMITED, (object)gwStatisItem.CntDELIVRD, (object)gwStatisItem.CntOPFAILED, (object)gwStatisItem.CntUnknown); stringBuilder.AppendFormat("{0}%", (object)this.Divide((Decimal)(gwStatisItem.CntDELIVRD * 100), (Decimal)gwStatisItem.CntSUBMITED)); stringBuilder.AppendFormat("{0}%", (object)(new Decimal(100) - this.Divide((Decimal)(gwStatisItem.CntUnknown * 100), (Decimal)gwStatisItem.CntSUBMITED))); stringBuilder.AppendFormat(""); } 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); } }