public string Retive_Rep_Data(Report_param <T> condition, string strReportPath, DataSet ds) { var result = string.Empty; var oReport = new cReport(); var rptSource = new ReportDocument(); try { string strReportDirectoryTempPhysicalPath = HttpContext.Current.Server.MapPath(this.ReportDirectoryTemp); Helper.DeleteUnusedFile(strReportDirectoryTempPhysicalPath, ReportAliveTime); string strFilename; string displayCompany = strCompanyName; if (condition.IsLockMajor == "Y") { displayCompany = condition.Person_major_name + " - " + strCompanyName; } strFilename = "report_" + DateTime.Now.ToString("yyyyMMddHHmmssfff"); string strPath = strReportPath; rptSource.Load(HttpContext.Current.Server.MapPath(strPath)); rptSource.SetDataSource(ds.Tables[0]); rptSource.SetParameterValue("UserName", condition.Report_user_print); rptSource.SetParameterValue("CompanyName", displayCompany); rptSource.SetParameterValue("CriteriaDesc", condition.Report_criteria_desc); if (condition.Report_is_pdf) { rptSource.ExportToDisk(ExportFormatType.PortableDocFormat, HttpContext.Current.Server.MapPath("~/temp/") + strFilename + ".pdf"); } if (condition.Report_is_excel) { rptSource.ExportToDisk(ExportFormatType.Excel, HttpContext.Current.Server.MapPath("~/temp/") + strFilename + ".xls"); } result = strFilename; } catch (Exception ex) { throw ex; } finally { oReport.Dispose(); rptSource.Dispose(); } return(result); }
public string Retive_Rep_012(Report_param <T> condition) { var result = string.Empty; var oReport = new cReport(); try { var ds = oReport.SP_REP_012(condition.Report_criteria); string strPath = "~/reports/Rep_012.rpt"; result = Retive_Rep_Data(condition, strPath, ds); } catch (Exception ex) { throw ex; } finally { oReport.Dispose(); } return(result); }