/// <summary> /// 流量历史 /// </summary> public void SearchLL_HisReport() { string strwhere = ""; string _Name = Request["Name"]; string Start = Request["StartDate"]; //开始日期 string End = Request["EndDate"]; //结束日期 string _ID = Request["ID"]; int year = Convert.ToDateTime(Start).Year; if (_ID != "" && _ID != null) { strwhere = strwhere + " and a.id='" + _ID + "'"; } if (_Name != "" && _Name != null) { strwhere = strwhere + " and (a.FName like '%" + _Name + "%' or a.FDTUCode like '%" + _Name + "%')"; } strwhere = strwhere + " and b.TempTime between '" + Start + "' and '" + End + "'"; strwhere = strwhere + getPowerConst("flow"); int pageIndex = Convert.ToInt32(Request["pageIndex"]); int pageSize = Convert.ToInt32(Request["pageSize"]); Hashtable result = BASE_LIULIANGDal.SearchLL_HisReport(pageIndex, pageSize, "b.BASEID,TempTime", "desc", strwhere, year); string json = PluSoft.Utils.JSON.Encode(result); Response.Write(json); }
//导出流量历史 public void ReportLL_His() { string strwhere = ""; string _Name = Request["Name"]; string Start = Request["StartDate"]; //开始日期 string End = Request["EndDate"]; //结束日期 string _ID = Request["ID"]; int year = Convert.ToDateTime(Start).Year; if (_ID != "" && _ID != null) { strwhere = strwhere + " and a.id='" + _ID + "'"; } if (_Name != "" && _Name != null) { strwhere = strwhere + " and (a.FName like '%" + _Name + "%' or a.FDTUCode like '%" + _Name + "%')"; } strwhere = strwhere + " and b.TempTime between '" + Start + "' and '" + End + "'"; strwhere = strwhere + getPowerConst("flow"); DataTable dtresult = BASE_LIULIANGDal.SearchLL_HisReport(strwhere, year); try { List <LL_runLog> YaLiLog = ModelConvertHelper <LL_runLog> .ConvertToModel(dtresult).ToList(); var excelExport = _excelExport.CreateWorkbook(); excelExport.AddSheet(YaLiLog, ""); string path = System.Web.HttpContext.Current.Server.MapPath("~/DownLoad"); if (Directory.Exists(path)) { Directory.Delete(path, true); } if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string pdfname = "/流量日志" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".xlsx"; string pathFile = excelExport.SaveFile(path + pdfname); Hashtable result = new Hashtable(); result["msg"] = "ok"; result["Url"] = "/DownLoad" + pdfname; string json = PluSoft.Utils.JSON.Encode(result); Response.Write(json); } catch (Exception) { Hashtable result = new Hashtable(); result["msg"] = "error"; string json = PluSoft.Utils.JSON.Encode(result); Response.Write(json); } }