Esempio n. 1
0
        /// <summary>
        /// 调峰历史
        /// </summary>
        public void SearchTF_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("tiaofeng");

            int       pageIndex = Convert.ToInt32(Request["pageIndex"]);
            int       pageSize  = Convert.ToInt32(Request["pageSize"]);
            Hashtable result    = BASE_TIAOFENGDal.SearchTF_HisReport(pageIndex, pageSize, "b.BASEID,TempTime", "desc", strwhere, year);
            string    json      = PluSoft.Utils.JSON.Encode(result);

            Response.Write(json);
        }
Esempio n. 2
0
        //导出调峰历史
        public void ReportTF_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("tiaofeng");
            DataTable dtresult = BASE_TIAOFENGDal.SearchTF_HisReport(strwhere, year);

            try
            {
                List <TF_runLog> YaLiLog = ModelConvertHelper <TF_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);
            }
        }