public string GetCard(string pRequest) { var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var cardDepositBLL = new CardDepositBLL(loggingSessionInfo); var rd = new GetCardRD(); var rp = pRequest.DeserializeJSONTo <APIRequest <GetCardRP> >(); rp.Parameters.Validate(); var ds = cardDepositBLL.PagedSearch(rp.Parameters, loggingSessionInfo.ClientID); if (ds.Tables.Count == 2) { var cardInfoList = (from d in ds.Tables[0].AsEnumerable() select new BLL.Card() { CardID = d["CardDepositId"].ToString(), CardNo = d["CardNo"].ToString(), ChannelTitle = d["ChannelTitle"].ToString(), Amount = decimal.Parse(d["Amount"].ToString()), Bonus = decimal.Parse(d["Bonus"].ToString()), CardStatus = int.Parse(d["CardStatus"].ToString()), UseStatus = int.Parse(d["UseStatus"].ToString()) }); rd.CardList = cardInfoList.ToArray(); rd.TotalPage = int.Parse(ds.Tables[1].Rows[0][0].ToString()); rd.TotalCount = int.Parse(ds.Tables[1].Rows[0][1].ToString()); } var rsp = new SuccessResponse <IAPIResponseData>(rd); return(rsp.ToJSON()); }
private string ExportCard(string pRequest) { var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo; var cardDepositBLL = new CardDepositBLL(loggingSessionInfo); var rd = new GetCardRD(); var rp = pRequest.DeserializeJSONTo <APIRequest <GetCardRP> >(); rp.Parameters.Validate(); DataSet ds = new DataSet(); if (rp.Parameters.CardIDs != null && rp.Parameters.CardIDs.Length > 0) { ds = cardDepositBLL.GetCardByIDs(rp); } else if (!string.IsNullOrEmpty(rp.Parameters.BatchID)) { ds = cardDepositBLL.GetCardByBatchID(rp); } else { rp.Parameters.PageSize = 1000000; rp.Parameters.PageIndex = 0; ds = cardDepositBLL.PagedSearch(rp.Parameters, loggingSessionInfo.ClientID); } if (ds.Tables.Count > 0) { DataTable dt = new DataTable(); if (ds.Tables[0] != null) { ds.Tables[0].Columns.Add(new DataColumn() { ColumnName = "CardPasswordDecrypt", DataType = typeof(string) }); #region 解密密码 foreach (DataRow item in ds.Tables[0].Rows) { item["CardPasswordDecrypt"] = System.Text.Encoding.UTF8.GetString(cardDepositBLL.DecryptCardPassword((byte[])item["CardPassword"])); } #endregion Dictionary <string, string> exportFields = new Dictionary <string, string>(); exportFields.Add("ChannelTitle", "渠道"); exportFields.Add("CardNo", "卡号"); exportFields.Add("CardPasswordDecrypt", "密码"); exportFields.Add("Amount", "金额"); exportFields.Add("Bonus", "赠送金额"); #region 替换标题信息 DataColumn dc = new DataColumn(); dt = ds.Tables[0].DefaultView.ToTable(false, exportFields.Keys.ToArray()); foreach (DataColumn c in dt.Columns) { string title; exportFields.TryGetValue(c.ColumnName, out title); c.ColumnName = title; } #endregion } //数据获取 Workbook wb = DataTableExporter.WriteXLS(dt, 0); string savePath = HttpContext.Current.Server.MapPath(@"~/File/Excel"); if (!System.IO.Directory.Exists(savePath)) { System.IO.Directory.CreateDirectory(savePath); } savePath = savePath + "\\卡数据导出" + DateTime.Now.ToFileTime() + ".xls"; wb.Save(savePath);//保存Excel文件 new ExcelCommon().OutPutExcel(HttpContext.Current, savePath); HttpContext.Current.Response.End(); } var rsp = new SuccessResponse <IAPIResponseData>(rd); return(rsp.ToJSON()); }