private void RenderReportModels(ReportData reportData, string PersonID, string classid) { long ClassID = Convert.ToInt64(classid); //long personID = PersonID; // Reset report properties. ReportViewerRSFReports.Height = Unit.Parse("100%"); ReportViewerRSFReports.Width = Unit.Parse("100%"); ReportViewerRSFReports.CssClass = "table"; var rptPath = Server.MapPath(@"../../../Report/" + reportData.ReportName + ".rdlc"); this.ReportViewerRSFReports.LocalReport.ReportPath = rptPath; long cID = Convert.ToInt64(HttpContext.Current.Session["CompanyID"]); DataTable dt = _PersonBAL.GetCertificateReports(PersonID, Convert.ToInt64(classid), cID, "en-us", Convert.ToInt64(HttpContext.Current.Session["NameIdentifierInt64"]), 1); ReportViewerRSFReports.ProcessingMode = ProcessingMode.Local; ReportViewerRSFReports.LocalReport.DataSources.Clear(); //ReportViewerRSFReports.LocalReport.EnableExternalImages = true; //List<OrganizationModel> logoPath = _PersonBAL.GetOrganizationLogo(Convert.ToInt64(HttpContext.Current.Session["CompanyID"])); //ReportParameter paramLogo = new ReportParameter(); //paramLogo.Name = "Path"; //string imagePath = new Uri(Server.MapPath(@"~/" + logoPath.FirstOrDefault().Logo)).AbsoluteUri; //paramLogo.Values.Add(imagePath); //ReportViewerRSFReports.LocalReport.SetParameters(paramLogo); ReportViewerRSFReports.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dt)); ReportViewerRSFReports.LocalReport.Refresh(); }
//[HttpPost] public FileResult Print_Read() { string _classID = System.Web.HttpContext.Current.Session["ClassId"].ToString(); string _personID = System.Web.HttpContext.Current.Session["PersonId"].ToString(); string IsDigital = System.Web.HttpContext.Current.Session["IsDigital"].ToString(); string certificateID = System.Web.HttpContext.Current.Session["certificateID"].ToString(); if (_classID.Equals("-1") || _personID.Equals("-1") || IsDigital.Equals("-1") || certificateID.Equals("-1")) { Session["ClassId"] = -1; Session["PersonId"] = -1; Session["IsDigital"] = -1; Session["certificateID"] = -1; return(null); } else { int IsDigitalINT = Convert.ToInt32(IsDigital); long certificateIDLong = Convert.ToInt64(certificateID); if (IsDigitalINT == 1) { ReportViewer ReportViewerRSFReports = new ReportViewer(); ReportViewerRSFReports.Height = Unit.Parse("100%"); ReportViewerRSFReports.Width = Unit.Parse("100%"); ReportViewerRSFReports.CssClass = "table"; var rptPath = Server.MapPath(@"../Report/Tran_CertificatePrinting.rdlc"); ReportViewerRSFReports.LocalReport.ReportPath = rptPath; long cID = Convert.ToInt64(CurrentUser.CompanyID); DataTable dt = _CourseBAL.GetCertificateReports(_personID, Convert.ToInt64(_classID), cID, "en-us", Convert.ToInt64(CurrentUser.NameIdentifierInt64), certificateIDLong); ReportViewerRSFReports.ProcessingMode = ProcessingMode.Local; ReportViewerRSFReports.LocalReport.DataSources.Clear(); ReportViewerRSFReports.LocalReport.DataSources.Add(new ReportDataSource("DataSet2", dt)); ReportViewerRSFReports.LocalReport.Refresh(); byte[] mybytes = ReportViewerRSFReports.LocalReport.Render(format: "PDF", deviceInfo: ""); //for exporting to PDF //Response.Clear(); //Response.Buffer = true; //Response.Charset = ""; //Response.Cache.SetCacheability(HttpCacheability.NoCache); //Response.ContentType = "application/pdf"; //Response.AppendHeader("Content-Disposition", "attachment; filename=RDLC.pdf"); //Response.BinaryWrite(mybytes); //string pdfPath = @"~\TempReports\Certificate.pdf"; // Path to export Report. //System.IO.FileStream pdfFile = new System.IO.FileStream(pdfPath, System.IO.FileMode.Create); //pdfFile.Write(mybytes, 0, mybytes.Length); //pdfFile.Close(); //Response.Flush(); //Response.End(); Session["ClassId"] = -1; Session["PersonId"] = -1; Session["IsDigital"] = -1; Session["certificateID"] = -1; return(File(mybytes, System.Net.Mime.MediaTypeNames.Application.Octet, "Certificate.pdf")); //return new JsonResult() //{ // Data = mybytes, // MaxJsonLength = Int32.MaxValue //}; } else { ReportViewer ReportViewerRSFReports = new ReportViewer(); ReportViewerRSFReports.Height = Unit.Parse("100%"); ReportViewerRSFReports.Width = Unit.Parse("100%"); ReportViewerRSFReports.CssClass = "table"; var rptPath = Server.MapPath(@"../Report/Tran_CertificateSimplePrint.rdlc"); ReportViewerRSFReports.LocalReport.ReportPath = rptPath; long cID = Convert.ToInt64(CurrentUser.CompanyID); DataTable dt = _CourseBAL.GetCertificateReports(_personID, Convert.ToInt64(_classID), cID, "en-us", Convert.ToInt64(CurrentUser.NameIdentifierInt64), certificateIDLong); ReportViewerRSFReports.ProcessingMode = ProcessingMode.Local; ReportViewerRSFReports.LocalReport.DataSources.Clear(); ReportViewerRSFReports.LocalReport.DataSources.Add(new ReportDataSource("DataSet2", dt)); ReportViewerRSFReports.LocalReport.Refresh(); Byte[] mybytes = ReportViewerRSFReports.LocalReport.Render(format: "PDF", deviceInfo: ""); //for exporting to PDF //Response.Clear(); //Response.Buffer = true; //Response.Charset = ""; //Response.Cache.SetCacheability(HttpCacheability.NoCache); //Response.ContentType = "application/pdf"; //Response.AppendHeader("Content-Disposition", "attachment; filename=RDLC.pdf"); //Response.BinaryWrite(mybytes); //Response.Flush(); //Response.End(); //return Response; //return new JsonResult() //{ // Data = mybytes, // MaxJsonLength = Int32.MaxValue //}; Session["ClassId"] = -1; Session["PersonId"] = -1; Session["IsDigital"] = -1; Session["certificateID"] = -1; return(File(mybytes, System.Net.Mime.MediaTypeNames.Application.Octet, "Certificate.pdf")); } } // return Json(mybytes, JsonRequestBehavior.AllowGet,max); //byte[] fileBytes = System.IO.File.ReadAllBytes(@"C:\Users\SynergicProfessional\Desktop\VenueMatrixReport.pdf"); //string fileName = "VenueMatrixReport.pdf"; //return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName); }