From 91912ad24d477ff24be56f0a22438303a8eae552 Mon Sep 17 00:00:00 2001 From: wzp <2880584989@qq.com> Date: 星期四, 16 九月 2021 16:12:52 +0800 Subject: [PATCH] Merge branch 'Release' of ssh://8.129.227.30:29418/SMGW_NewWeb into Release --- web/web/ExportDocument.aspx.cs | 336 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 336 insertions(+), 0 deletions(-) diff --git a/web/web/ExportDocument.aspx.cs b/web/web/ExportDocument.aspx.cs new file mode 100644 index 0000000..0d28a08 --- /dev/null +++ b/web/web/ExportDocument.aspx.cs @@ -0,0 +1,336 @@ +锘縰sing Dao; +using Model; +using System; +using System.Collections.Generic; +using System.Data; +using System.Web; +using System.Web.Profile; +using System.Web.SessionState; +using System.Reflection; + +public partial class ExportDocument : PageBase<SysUser>, IRequiresSessionState +{ + + + protected void Page_Load(object sender, EventArgs e) + { + switch (this.AppContext.GetString("action")) + { + case "exPortGwSp": + this.ExPortGwSp(); + break; + case "exPortGwSm": + this.ExportGwSmData(); + break; + case "exportGwStatisV3"://瀵煎嚭缁熻鎶ヨ〃 + this.ExprortGwStatisV3(); + break; + } + } + + #region 缁熻鎶ヨ〃瀵煎嚭 + /// <summary> + /// 缁熻鎶ヨ〃瀵煎嚭 + /// </summary> + private void ExprortGwStatisV3() + { + string apMid = this.AppContext.GetString("ApMID"); + string opid = this.AppContext.GetString("OPID"); + string spid = this.AppContext.GetString("SpID"); + string clientId = this.AppContext.GetString("ClientID"); + string beginTime = this.AppContext.GetString("BeginTime"); + if (string.IsNullOrEmpty(beginTime)) + beginTime = DateTime.Now.AddHours(-1.0).Day == DateTime.Now.Day ? DateTime.Now.AddHours(-1.0).ToString("HH:mm:ss") : "00:00:00"; + string endTime = this.AppContext.GetString("EndTime"); + string statistype = this.AppContext.GetString("Statistype"); + StatisOption statisoption = (StatisOption)this.AppContext.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); + } + + GwStatisV3Dao _Dao = new GwStatisV3Dao(); + var list = _Dao.Query(Convert.ToDateTime(beginTime), Convert.ToDateTime(endTime), clientId, spid, apMid, opid, statistype, (StatisOption)statisoption); + + List<Model.GwStatisV3> statisList = new List<Model.GwStatisV3>(); + foreach (GwStatisV3Item item in list) + { + Model.GwStatisV3 ss = new Model.GwStatisV3(); + + if ((statisoption & StatisOption.APID) == StatisOption.APID) + { + ss.ApName = GetApName(apList, item.APID); + } + if ((statisoption & StatisOption.OPID) == StatisOption.OPID) + { + ss.OpName = GetOpName(opList, item.OPID); + } + if ((statisoption & StatisOption.SpID) == StatisOption.SpID) + { + ss.SpId = item.SpID; + } + if ((statisoption & StatisOption.ClientID) == StatisOption.ClientID) + { + ss.ClientId = 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; + + ss.ApReciveTotal = apTotal.ToString(); + ss.OpSubTotal = opTotal.ToString(); + + ss.ApSubFailed = item.APStatus1.ToString(); + ss.ApNotForwarded = item.APStatus0.ToString(); + + ss.ApFailed = (item.APStatus3 + item.APStatus5).ToString(); + ss.ApUnkown = item.APStatus3.ToString(); + ss.ApNeedReturn = (item.APStatus3 + item.APStatus2 + item.APStatus5 + item.APStatus0).ToString(); + + ss.OpFailed = item.OPStatus5.ToString(); + ss.OpUnkown = item.OPStatus2.ToString(); + ss.OpSuccess = item.OPStatus4.ToString(); + + ss.OpSuccessRate = Divide(item.OPStatus4 * 100, opTotal).ToString()+"%"; + + ss.OpReportRate = (100 - Divide(item.OPStatus2 * 100, opTotal)).ToString() + "%"; + ss.Date = item.Title; + + statisList.Add(ss); + } + + if (statisList.Count > 0) + { + DataTable dt = ToDataTable<Model.GwStatisV3>(statisList); + WebTool webtool = new WebTool(); + Dictionary<string, string> dicTitle = new Dictionary<string, string>(); + dicTitle["鏃ユ湡"] = "Date"; + dicTitle["鎺ュ叆鐐�"] = "ApName"; + dicTitle["閫氶亾"] = "OpName"; + dicTitle["璐﹀彿"] = "SpId"; + dicTitle["瀹㈡埛"] = "ClientId"; + dicTitle["AP鎺ユ敹鎬婚噺"] = "ApReciveTotal"; + dicTitle["AP鎻愪氦澶辫触"] = "ApSubFailed"; + dicTitle["AP鏈浆鍙�"] = "ApNotForwarded"; + dicTitle["AP澶辫触"] = "ApFailed"; + dicTitle["AP鏈煡"] = "ApUnkown"; + dicTitle["AP闇�杩旇繕"] = "ApNeedReturn"; + dicTitle["OP鎻愪氦鎬婚噺"] = "OpSubTotal"; + dicTitle["OP澶辫触"] = "OpFailed"; + dicTitle["OP鏈煡"] = "OpUnkown"; + dicTitle["OP鎴愬姛"] = "OpSuccess"; + dicTitle["OP鎴愬姛鐜�"] = "OpSuccessRate"; + dicTitle["OP鐘舵�佺巼"] = "OpReportRate"; + webtool.Export(dt,dicTitle,"缁熻鎶ヨ〃",this.Context.Response); + } + + } + + + public decimal Divide(decimal v, decimal total) + { + if (total == 0) + { + return 0; + } + + return Math.Round(v / total, 2); + } + + 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); + } + + + + //================================================= + /// <summary> + /// Convert a List{T} to a DataTable. + /// </summary> + private DataTable ToDataTable<T>(List<T> items) + { + var tb = new DataTable(typeof(T).Name); + + PropertyInfo[] props = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance); + + foreach (PropertyInfo prop in props) + { + Type t = GetCoreType(prop.PropertyType); + tb.Columns.Add(prop.Name, t); + } + + foreach (T item in items) + { + var values = new object[props.Length]; + + for (int i = 0; i < props.Length; i++) + { + values[i] = props[i].GetValue(item, null); + } + + tb.Rows.Add(values); + } + + return tb; + } + + /// <summary> + /// Determine of specified type is nullable + /// </summary> + public static bool IsNullable(Type t) + { + return !t.IsValueType || (t.IsGenericType && t.GetGenericTypeDefinition() == typeof(Nullable<>)); + } + + /// <summary> + /// Return underlying type if type is Nullable otherwise return the type + /// </summary> + public static Type GetCoreType(Type t) + { + if (t != null && IsNullable(t)) + { + if (!t.IsValueType) + { + return t; + } + else + { + return Nullable.GetUnderlyingType(t); + } + } + else + { + return t; + } + } + + //=============================end=================================== + #endregion + + + private void ExPortGwSp() + { + string string1 = this.AppContext.GetString("SpID"); + string string2 = this.AppContext.GetString("ApID"); + string string3 = this.AppContext.GetString("ClientID"); + using (GwSpDao gwSpDao = new GwSpDao()) + { + DataTable dataTable = gwSpDao.LoadSpDataTable(string1, string2, string3); + WebTool webTool = new WebTool(); + Dictionary<string, string> dictionary = new Dictionary<string, string>(); + dictionary["瀹㈡埛缂栫爜"] = "CLIENT_ID"; + dictionary["璐﹀彿"] = "SP_ID"; + dictionary["浣欓"] = "BALANCE"; + dictionary["鍗曚环"] = "PRICE"; + dictionary["浠樻鏂瑰紡"] = "CHARGE_TYPE"; + dictionary["閴存潈鍦板潃"] = "CLIENT_IP"; + dictionary["闂ㄩ檺"] = "THRESHOLD"; + dictionary["瀵嗙爜"] = "PASSWORD"; + webTool.Export(dataTable, dictionary, "SP_" + (object)DateTime.Now.Ticks, this.Context.Response); + } + } + + private void ExportGwSmData() + { + string apMid = this.AppContext.GetString("ApMID"); + string sDate = this.AppContext.GetString("QueryDate"); + if (string.IsNullOrEmpty(sDate)) + sDate = DateTime.Today.ToString("yyyy-MM-dd"); + string content = this.AppContext.GetString("Content"); + string opstat = this.AppContext.GetString("OpStat"); + string opName = this.AppContext.GetString("OPName"); + string mobile = this.AppContext.GetString("DestnationID"); + string spid = this.AppContext.GetString("SpID"); + string clientId = this.AppContext.GetString("ClientID"); + string beginTime = this.AppContext.GetString("BeginTime"); + if (string.IsNullOrEmpty(beginTime)) + beginTime = DateTime.Now.AddHours(-1.0).Day == DateTime.Now.Day ? DateTime.Now.AddHours(-1.0).ToString("HH:mm:ss") : "00:00:00"; + string endTime = this.AppContext.GetString("EndTime"); + if (string.IsNullOrEmpty(endTime)) + endTime = DateTime.Now.Date.AddSeconds(-1.0).ToString("HH:mm:ss"); + int @int = this.AppContext.GetInt("TStatus", -1); + using (GwSmDao gwSmDao = new GwSmDao()) + { + int recordcount = 0; + if (gwSmDao.LoadInfoListcount(apMid, opName, clientId, spid, mobile, sDate, beginTime, endTime, content, opstat, @int, out recordcount).Count > 1000000) + { + this.Response.Write("<script type='text/javascript'>alert('瀵煎嚭鏁版嵁涓嶈兘澶т簬100涓囨潯锛�');location.href='GwSm.aspx';</script>"); + this.Response.End(); + } + DataTable dataTable = gwSmDao.LoadSpDataTable(apMid, opName, clientId, spid, mobile, sDate, beginTime, endTime, content, @int, opstat); + + WebTool webTool = new WebTool(); + Dictionary<string, string> dictionary = new Dictionary<string, string>(); + dictionary["AP娑堟伅ID"] = "AP_MID"; + dictionary["浠g悊鍟�"] = "CLIENT_ID"; + dictionary["璐﹀彿"] = "SP_ID"; + dictionary["鎺ュ叆鐐笽D"] = "AP_ID"; + dictionary["閫氶亾鍚�"] = "OP_NAME"; + dictionary["鐮佸彿"] = "ACCESS_CODE"; + dictionary["鎺ユ敹鍙风爜"] = "MOBILE"; + dictionary["PKN "] = "PK_NUMBER"; + dictionary["PKT "] = "PK_NUMBER"; + dictionary["AP璁¤垂"] = "AP_FEE_COUNT"; + dictionary["OP璁¤垂 "] = "OP_FEE_COUNT"; + dictionary["UDH"] = "TPUDHI"; + dictionary["浼樺厛绾�"] = "PRIORITY"; + dictionary["FMT"] = "MSG_FORMAT"; + dictionary["闀垮害"] = "MSG_LENGTH"; + dictionary["AP缁撴灉 "] = "AP_RESULT"; + dictionary["OP娑堟伅ID "] = "OP_MID"; + dictionary["OP缁撴灉 "] = "OP_RESULT"; + dictionary["瀹㈡埛鎻愪氦鏃堕棿"] = "AP_SUBMIT_TIME"; + dictionary["瀵瑰杞彂鏃堕棿"] = "OP_SUBMIT_TIME"; + dictionary["鐘舵�佹姤鍛婂洖鎵ф椂闂�"] = "OP_DELIVER_TIME"; + dictionary["鍐呭"] = "MSG_CONTENT"; + dictionary["鐘舵��"] = "STAT"; + dictionary["鑰楁椂"] = "OUT_TIME"; + webTool.Export(dataTable, dictionary, "鏃ュ織_" + sDate, this.Context.Response); + } + } +} -- Gitblit v1.9.1