예제 #1
0
        public ActionResult GetReportDataProc(List <I.MES.Models.WhereCondition> whereList, string page)
        {
            try
            {
                ReportOP op = new ReportOP();
                //总记录数
                int intRowTotal = 0;
                //获取当前页码
                int intPage = string.IsNullOrWhiteSpace(page) ? 1 : int.Parse(page);

                DataSet   ds            = op.GetAllReportDataProc(whereList);
                DataTable dt            = Processing(ds);
                var       strReportJson = ToJson(dt);
                //JsonHelper.ToJson(ds.Tables[1]);
                return(Json(new ReturnResult
                {
                    Result = 1,
                    Message = ds.Tables[0].Rows.Count.ToString(),
                    Data = strReportJson
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnResult
                {
                    Result = 0,
                    Message = ex.Message,
                    Data = ""
                }));
            }
        }
예제 #2
0
 public ActionResult GetPageDataProc(List <I.MES.Models.WhereCondition> whereList, string page)
 {
     try
     {
         ReportOP op = new ReportOP();
         //总记录数
         int intRowTotal = 0;
         //获取当前页码
         int intPage = string.IsNullOrWhiteSpace(page) ? 1 : int.Parse(page);
         whereList.Add(new MES.Models.WhereCondition
         {
             Key        = "page",
             ColumnName = "page",
             Operator   = "",
             Value      = page
         });
         whereList.Add(new MES.Models.WhereCondition
         {
             Key        = "pagesize",
             ColumnName = "pagesize",
             Operator   = "",
             Value      = ConstInfo.PAGE_SIZE.ToString()
         });
         DataSet ds = op.GetAllReportDataProc(whereList);
         if (ds.Tables[0].Rows.Count == 0)
         {
             DataRow row = ds.Tables[0].NewRow();
             ds.Tables[0].Rows.Add(row);
         }
         var strReportJson = ToJson(ds.Tables[1]);
         //JsonHelper.ToJson(ds.Tables[1]);
         return(Json(new ReturnResult
         {
             Result = 1,
             Message = ds.Tables[0].Rows[0][0].ToString(),
             Data = strReportJson
         }));
     }
     catch (Exception ex)
     {
         return(Json(new ReturnResult
         {
             Result = 0,
             Message = ex.Message,
             Data = ""
         }));
     }
 }
예제 #3
0
        public void ExportProcOut()
        {
            string ret = "";

            try
            {
                ReportOP op       = new ReportOP();
                DataSet  dsExport = null;
                string   strJson  = Server.UrlDecode(Request["w"]);
                List <I.MES.Models.WhereCondition> whereList;
                if (!string.IsNullOrWhiteSpace(strJson))
                {
                    whereList = strJson.ToEntities <List <I.MES.Models.WhereCondition> >();

                    dsExport = op.GetAllReportDataProc(whereList);
                }

                Workbook workbook = AsposeExcelTools.DataTableToExcel2(dsExport);
                if (workbook != null)
                {
                    this.DeleteDownLoadTempFile();

                    //直接导出
                    string filename = "/DownLoad/" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
                    workbook.Save(Server.MapPath(filename), SaveFormat.Xlsx);
                    ret = filename;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            //Response.Buffer = false;
            Response.AppendHeader("Content-Disposition", "attachment;filename=" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx");
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.ContentType     = "application/vnd.ms-excel";
            Response.Write(ret);
            Response.Flush();
            Response.End();
        }