protected void DownloadIndent(int id, string type) { Warning[] warnings; string[] streamids; string mimeType; string encoding; string filenameExtension; //here //set report //set report datasurce IndentReportService _IndentReportService = new IndentReportService(); List <Services.Models.IndentReportDataSet> dataSource = _IndentReportService.GetIndentDetailById(id); if (dataSource.Count > 0) { //foreach (var ds in dataSource) //{ // if (ds.PlantId == null) // { // ds.PlantName = "General"; // } //} rvSiteMapping.Visible = false; pnlNoData.Visible = false; byte[] bytes = null; if (type == "PR") { String reportFolder = System.Configuration.ConfigurationManager.AppSettings["SSRSReportsFolder"].ToString(); rvSiteMapping.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; Microsoft.Reporting.WebForms.ReportDataSource datasrc = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dataSource); datasrc.Name = "DataSet1"; //datasrc.DataSourceId= rvSiteMapping.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dataSource)); bytes = rvSiteMapping.LocalReport.Render( "PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); } else { String reportFolder = System.Configuration.ConfigurationManager.AppSettings["SSRSReportsFolder"].ToString(); ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; Microsoft.Reporting.WebForms.ReportDataSource datasrc = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dataSource); datasrc.Name = "DataSet1"; //datasrc.DataSourceId= ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dataSource)); bytes = ReportViewer1.LocalReport.Render( "PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings); } DownloadFile(bytes, string.Format("{0}.pdf", dataSource[0].IndentNo.Replace("/", "-"))); } }
protected void DownloadIndentAttachment(int Id) { IndentReportService service = new IndentReportService(); var attachment = service.GetAttachment(Id); var path = ConfigurationManager.AppSettings["IndentAttachmentPath"]; var fullFilePath = Path.Combine(path, attachment.SysFileName); DownloadFile(File.ReadAllBytes(fullFilePath), attachment.OriginalFileName); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { //int siteId = int.Parse(Request.QueryString["SiteId"]); int plantId = int.Parse(Request.QueryString["PlantId"]); //int lineId = int.Parse(Request.QueryString["LineId"]); // DateTime startDate = DateTime.Now.AddDays(-40); //DateTime endDate = DateTime.Now; string year = Request.QueryString["year"]; IndentReportService _IndentReportService = new IndentReportService(); //List<Services.Models.BreakDownMonthlySummaryDataSet> dataSource = _breakDownReportService.GetBreakdownDataGroupByType(1, plantId, 12, startDate, endDate); List <Services.Models.IndentReportDataSet> dataSource = _IndentReportService.GetIssuedIndentDetail(plantId, year); //new DateTime(dateTime.Year, dateTime.Month, 1) if (dataSource.Count > 0) { rvSiteMapping.Visible = true; pnlNoData.Visible = false; String reportFolder = System.Configuration.ConfigurationManager.AppSettings["SSRSReportsFolder"].ToString(); rvSiteMapping.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; Microsoft.Reporting.WebForms.ReportDataSource datasrc = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dataSource); datasrc.Name = "DataSet1"; //datasrc.DataSourceId= rvSiteMapping.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dataSource)); } else { rvSiteMapping.Visible = false; pnlNoData.Visible = true; Microsoft.Reporting.WebForms.ReportDataSource datasrc = new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dataSource); datasrc.Name = "DataSet1"; rvSiteMapping.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", dataSource)); } rvSiteMapping.LocalReport.Refresh(); } catch (Exception ex) { } } }