protected override void OnInit(EventArgs e) { base.OnInit(e); //Microsoft.Reporting.WebForms.ReportViewer reportViewer1 = //(Microsoft.Reporting.WebForms.ReportViewer)sender; Microsoft.Reporting.WebForms.ReportViewer reportViewer1 = this.ReportViewer1; string s = " 上記の業務委託について、ああああああと受注者(株)あいうえお建設は、各々の対等な立場における合意に基づいて、別添のうううううううううううによって委託契約を締結し、信義に従って誠実にこれを履行するものとする。"; s = ToJustifyText(s); List <Microsoft.Reporting.WebForms.ReportParameter> list = new List <Microsoft.Reporting.WebForms.ReportParameter>(); foreach (Microsoft.Reporting.WebForms.ReportParameterInfo rpi in reportViewer1.LocalReport.GetParameters()) { Microsoft.Reporting.WebForms.ReportParameter rp = new Microsoft.Reporting.WebForms.ReportParameter(rpi.Name, s); list.Add(rp); } foreach (string name in this.ReportViewer1.LocalReport.GetDataSourceNames()) { DataSet1.DataTable1DataTable dt = new DataSet1.DataTable1DataTable(); var row = dt.NewDataTable1Row(); row.DataColumn1 = s; dt.Rows.Add(row); row = dt.NewDataTable1Row(); row.DataColumn1 = ToJustifyText(s); dt.Rows.Add(row); reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(name, (System.Collections.IEnumerable)dt)); } reportViewer1.DataBind(); reportViewer1.LocalReport.SetParameters(list); }
public static byte[] GeneratePDF(string reportPath, System.Collections.Generic.Dictionary <string, object> reportDataSources, string outputFileName, List <Microsoft.Reporting.WebForms.ReportParameter> parameters, string contentType) { Microsoft.Reporting.WebForms.ReportViewer ReportViewer1 = new Microsoft.Reporting.WebForms.ReportViewer(); ReportViewer1.LocalReport.ReportPath = reportPath; ReportViewer1.LocalReport.EnableExternalImages = true; if (parameters != null && parameters.Count > 0) { ReportViewer1.LocalReport.SetParameters(parameters); } if (reportDataSources != null) { foreach (System.Collections.Generic.KeyValuePair <string, object> dataSource in reportDataSources) { ReportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource(dataSource.Key, dataSource.Value)); } } Microsoft.Reporting.WebForms.Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; byte[] bytes = ReportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings); return(bytes); }
public ReportViewer() { this.m_Viewer = new Microsoft.Reporting.WebForms.ReportViewer(); this.DataSources = new cDataSource(this.m_Viewer); this.EnableFormat("HTML4.0"); this.EnableFormat("IMAGE"); }
//[HttpPost] public ActionResult Report(LocalizarViewModel localizar) { var pacienteViewModel = Mapper.Map <IEnumerable <Paciente>, IEnumerable <PacienteViewModel> >(_pacienteApp.GetAll()); if (!String.IsNullOrEmpty(localizar.palavra)) { switch (localizar.localizarPor[0]) { case "Carteira": pacienteViewModel = pacienteViewModel.Where(s => s.CarteirinhaPaciente.Contains(localizar.palavra)); break; case "Nome": pacienteViewModel = pacienteViewModel.Where(s => s.NomePaciente.Contains(localizar.palavra)); break; } } var viewer = new Microsoft.Reporting.WebForms.ReportViewer(); viewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; viewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"..\ProjetoModeloDDD.Infra.Data\Reports\Pacientes.rdlc"; viewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("PacienteDataSet", pacienteViewModel)); viewer.SizeToReportContent = true; viewer.Width = System.Web.UI.WebControls.Unit.Percentage(10); viewer.Height = System.Web.UI.WebControls.Unit.Percentage(10); ViewBag.ReportViewer = viewer; return(View()); }
public static Byte[] InitialReport(string reportFile, Microsoft.Reporting.WebForms.ReportDataSource[] reportDataSource, Microsoft.Reporting.WebForms.ReportParameter[] ReportParameters) { Microsoft.Reporting.WebForms.ReportViewer ReportViewer1 = new Microsoft.Reporting.WebForms.ReportViewer(); //this.ReportViewer1.Reset(); ReportViewer1.LocalReport.DataSources.Clear(); foreach (var ds in reportDataSource) { ReportViewer1.LocalReport.DataSources.Add(ds); } ReportViewer1.LocalReport.ReportPath = System.Web.HttpContext.Current.Server.MapPath(reportFile); ReportViewer1.LocalReport.AddTrustedCodeModuleInCurrentAppDomain ("SportsCenterMvc.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"); if (ReportParameters != null) { ReportViewer1.LocalReport.SetParameters(ReportParameters); } Microsoft.Reporting.WebForms.Warning[] warnings = null; string[] streamids = null; String mimeType = null; String encoding = null; String extension = null; Byte[] bytes = null; string ExportReportFormat = ConfigurationManager.AppSettings["ExportReportFormat"]; bytes = ReportViewer1.LocalReport.Render(ExportReportFormat, "", out mimeType, out encoding, out extension, out streamids, out warnings); //this.ReportViewer1.LocalReport.Refresh(); return bytes; }
// Testing ReportViewer 2015 protected void Page_Load(object sender, System.EventArgs e) { // Basic_SQL.SQL.GetSqlServerTypesDll(@"d:\"); byte[] ba = Portal_Reports.Umzugsmitteilung.GetUmzugsmitteilung(new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.WordOpenXml), "C38CB749-1EEC-4686-9BBA-F627B9C4E8EC", "DE"); return; RenderReport(); return; this.m_Viewer = new Microsoft.Reporting.WebForms.ReportViewer(); EnableFormat("foo"); COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.WordOpenXml); // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Html); // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.HtmlFragment); //formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Image); formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.ExcelOpenXml); // this.m_Viewer.LocalReport.ReportPath = System.Web.Hosting.HostingEnvironment.MapPath("~/SimpleTest.rdl"); using (System.IO.Stream reportDefinition = COR_Reports.ReportRepository.GetEmbeddedReport("SimpleTest.rdl")) { this.m_Viewer.LocalReport.LoadReportDefinition(reportDefinition); } Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource(); rds.Name = "DATA_Columns"; //This refers to the dataset name in the RDLC file string strSQL = @"SELECT TOP 100 * FROM information_schema.columns"; // strSQL = strSQL.Replace("@_in_umzugsuid", "'" + in_ump_uid.Replace("'", "''") + "'"); // strSQL = strSQL.Replace("@_in_sprache", "'" + in_sprache.Replace("'", "''") + "'"); rds.Value = Basic_SQL.SQL.GetDataTable(strSQL); strSQL = null; this.m_Viewer.LocalReport.DataSources.Add(rds); Microsoft.Reporting.WebForms.Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; byte[] result = this.m_Viewer.LocalReport.Render(formatInfo.FormatName, formatInfo.DeviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings); string savePath = @"D:\"; if (!System.StringComparer.OrdinalIgnoreCase.Equals(System.Environment.UserDomainName, "COR")) { savePath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory); } savePath = System.IO.Path.Combine(savePath, "SimpleTest" + formatInfo.Extension); System.IO.File.WriteAllBytes(savePath, result); } // End Sub Page_Load
public static void BindControl(Microsoft.Reporting.WebForms.ReportViewer rv, DataSet data, string name, string virtualRldc) { rv.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource(); rds.Name = name + "_Table"; rds.Value = data.Tables[0]; Microsoft.Reporting.WebForms.LocalReport r = rv.LocalReport; r.ReportPath = virtualRldc; r.DataSources.Add(rds); }
// Testing ReportViewer 2015 protected void Page_Load(object sender, System.EventArgs e) { // Basic_SQL.SQL.GetSqlServerTypesDll(@"d:\"); byte[] ba = Portal_Reports.Umzugsmitteilung.GetUmzugsmitteilung(new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.WordOpenXml), "C38CB749-1EEC-4686-9BBA-F627B9C4E8EC", "DE"); return; RenderReport(); return; this.m_Viewer = new Microsoft.Reporting.WebForms.ReportViewer(); EnableFormat("foo"); COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.WordOpenXml); // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Html); // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.HtmlFragment); //formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Image); formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.ExcelOpenXml); // this.m_Viewer.LocalReport.ReportPath = System.Web.Hosting.HostingEnvironment.MapPath("~/SimpleTest.rdl"); using (System.IO.Stream reportDefinition = COR_Reports.ReportRepository.GetEmbeddedReport("SimpleTest.rdl")) { this.m_Viewer.LocalReport.LoadReportDefinition(reportDefinition); } Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource(); rds.Name = "DATA_Columns"; //This refers to the dataset name in the RDLC file string strSQL = @"SELECT TOP 100 * FROM information_schema.columns"; // strSQL = strSQL.Replace("@_in_umzugsuid", "'" + in_ump_uid.Replace("'", "''") + "'"); // strSQL = strSQL.Replace("@_in_sprache", "'" + in_sprache.Replace("'", "''") + "'"); rds.Value = Basic_SQL.SQL.GetDataTable(strSQL); strSQL = null; this.m_Viewer.LocalReport.DataSources.Add(rds); Microsoft.Reporting.WebForms.Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; byte[] result = this.m_Viewer.LocalReport.Render(formatInfo.FormatName, formatInfo.DeviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings); string savePath = @"D:\"; if (!System.StringComparer.OrdinalIgnoreCase.Equals(System.Environment.UserDomainName, "COR")) savePath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory); savePath = System.IO.Path.Combine(savePath, "SimpleTest" + formatInfo.Extension); System.IO.File.WriteAllBytes(savePath, result); }
protected void BindDataSource(MsReportViewer reportViewer, IReport report) { if (report.ReportProcessingLocation is ILocalReportProcessingLocation) { reportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; BindLocalReport(reportViewer.LocalReport, report); } else { reportViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote; BindServerReport(reportViewer.ServerReport, report); } }
protected void ExportReport(string reportName, ArrayList parameters) { Microsoft.Reporting.WebForms.ReportViewer rview = new Microsoft.Reporting.WebForms.ReportViewer(); rview.ServerReport.ReportServerUrl = new Uri(System.Web.Configuration.WebConfigurationManager.AppSettings["ReportServer"]); rview.ServerReport.ReportPath = reportName; System.Collections.Generic.List<Microsoft.Reporting.WebForms.ReportParameter> paramList = new System.Collections.Generic.List<Microsoft.Reporting.WebForms.ReportParameter>(); if (parameters.Count > 0) { foreach (ArrayList al in parameters) { paramList.Add(new Microsoft.Reporting.WebForms.ReportParameter(al[0].ToString(), al[1].ToString())); } rview.ServerReport.SetParameters(paramList); } string mimeType, encoding, extension, deviceInfo; string[] streamids; Microsoft.Reporting.WebForms.Warning[] warnings; string format = "PDF"; deviceInfo = "<DeviceInfo>" + "<SimplePageHeaders>True</SimplePageHeaders>" + "</DeviceInfo>"; byte[] bytes = rview.ServerReport.Render(format, deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings); Response.Clear(); if (format == "PDF") { Response.ContentType = "application/pdf"; Response.AddHeader("Content-disposition", "filename=output.pdf"); } else { Response.ContentType = "application/excel"; Response.AddHeader("Content-disposition", "filename=output.xls"); } Response.OutputStream.Write(bytes, 0, bytes.Length); Response.OutputStream.Flush(); Response.OutputStream.Close(); Response.Flush(); Response.Close(); }
} // End Sub Page_Load protected static void RenderReport() { Microsoft.Reporting.WebForms.ReportViewer m_Viewer = new Microsoft.Reporting.WebForms.ReportViewer(); // EnableFormat("foo"); COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.WordOpenXml); // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Html); // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.HtmlFragment); //formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Image); // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.ExcelOpenXml); using (System.IO.Stream reportDefinition = COR_Reports.ReportRepository.GetEmbeddedReport("TestReport.rdl")) { m_Viewer.LocalReport.LoadReportDefinition(reportDefinition); } Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource(); rds.Name = "DataSet1"; //This refers to the dataset name in the RDLC file string strSQL = @"SELECT TOP 10 * FROM T_Benutzer"; // strSQL = strSQL.Replace("@_in_umzugsuid", "'" + in_ump_uid.Replace("'", "''") + "'"); // strSQL = strSQL.Replace("@_in_sprache", "'" + in_sprache.Replace("'", "''") + "'"); rds.Value = Basic_SQL.SQL.GetDataTable(strSQL); strSQL = null; m_Viewer.LocalReport.DataSources.Add(rds); Microsoft.Reporting.WebForms.Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; byte[] result = m_Viewer.LocalReport.Render(formatInfo.FormatName, formatInfo.DeviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings); string savePath = @"D:\"; if (!System.StringComparer.OrdinalIgnoreCase.Equals(System.Environment.UserDomainName, "COR")) { savePath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory); } savePath = System.IO.Path.Combine(savePath, "SimpleTest" + formatInfo.Extension); System.IO.File.WriteAllBytes(savePath, result); }
private void CreatePDFDocument(string strReportPath, Microsoft.Reporting.WebForms.ReportViewer AIMSReport, string strDestinationFilePath) { Microsoft.Reporting.WebForms.Warning[] warnings = null; string[] streamids = null; string mimeType = null; string encoding = null; string extension = null; string deviceInfo = null; byte[] bytes; Microsoft.Reporting.WebForms.LocalReport lr = new Microsoft.Reporting.WebForms.LocalReport(); lr.ReportPath = strReportPath; deviceInfo = "<DeviceInfo><SimplePageHeaders>True</SimplePageHeaders></DeviceInfo>"; bytes = AIMSReport.LocalReport.Render("PDF", deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings); WriteToFile(strDestinationFilePath, bytes); }
// GET: Relatorio public ActionResult Index() { var dataSet = Models.DataSet1.ObterExemplo(); var viewer = new Microsoft.Reporting.WebForms.ReportViewer(); viewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; viewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"Report\Report1.rdlc"; viewer.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", (System.Data.DataTable)dataSet.Movies)); viewer.SizeToReportContent = true; viewer.Width = System.Web.UI.WebControls.Unit.Percentage(100); viewer.Height = System.Web.UI.WebControls.Unit.Percentage(100); ViewBag.ReportViewer = viewer; return(View()); }
protected static void RenderReport() { Microsoft.Reporting.WebForms.ReportViewer m_Viewer = new Microsoft.Reporting.WebForms.ReportViewer(); // EnableFormat("foo"); COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.WordOpenXml); // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Html); // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.HtmlFragment); //formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Image); // formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.ExcelOpenXml); using (System.IO.Stream reportDefinition = COR_Reports.ReportRepository.GetEmbeddedReport("TestReport.rdl")) { m_Viewer.LocalReport.LoadReportDefinition(reportDefinition); } Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource(); rds.Name = "DataSet1"; //This refers to the dataset name in the RDLC file string strSQL = @"SELECT TOP 10 * FROM T_Benutzer"; // strSQL = strSQL.Replace("@_in_umzugsuid", "'" + in_ump_uid.Replace("'", "''") + "'"); // strSQL = strSQL.Replace("@_in_sprache", "'" + in_sprache.Replace("'", "''") + "'"); rds.Value = Basic_SQL.SQL.GetDataTable(strSQL); strSQL = null; m_Viewer.LocalReport.DataSources.Add(rds); Microsoft.Reporting.WebForms.Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; byte[] result = m_Viewer.LocalReport.Render(formatInfo.FormatName, formatInfo.DeviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings); string savePath = @"D:\"; if (!System.StringComparer.OrdinalIgnoreCase.Equals(System.Environment.UserDomainName, "COR")) savePath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory); savePath = System.IO.Path.Combine(savePath, "SimpleTest" + formatInfo.Extension); System.IO.File.WriteAllBytes(savePath, result); }
public static void ReadUsingReportViewer(string FILE_NAME) { Microsoft.Reporting.WebForms.ReportViewer ReportViewer1 = new Microsoft.Reporting.WebForms.ReportViewer(); // ReportViewer1.LocalReport.ReportPath = "GM_Gebaeudestammdaten_Wincasa.rdl"; ReportViewer1.LocalReport.ReportPath = FILE_NAME; // Console.WriteLine(ReportViewer1.LocalReport.ReportEmbeddedResource); Microsoft.Reporting.WebForms.ReportParameterInfoCollection x = ReportViewer1.LocalReport.GetParameters(); foreach (Microsoft.Reporting.WebForms.ReportParameterInfo pi in x) { Console.WriteLine(pi.Name); } // Next pi Microsoft.Reporting.WebForms.ReportDataSourceCollection dsc = ReportViewer1.LocalReport.DataSources; foreach (Microsoft.Reporting.WebForms.ReportDataSource rds in dsc) { Console.WriteLine(rds.Name); Console.WriteLine(rds.Value); } // Next rds } // End Sub ReadUsingReportViewer
} // End Function RenderControlToHtml private static void EnableFormat(Microsoft.Reporting.WebForms.ReportViewer viewer, string formatName) { const System.Reflection.BindingFlags Flags = System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance; System.Type tt = viewer.LocalReport.GetType(); System.Reflection.FieldInfo m_previewService = tt.GetField("m_previewService", Flags); if (m_previewService == null) { m_previewService = tt.GetField("m_processingHost", Flags); } // Works only for v2005 if (m_previewService != null) { System.Reflection.MethodInfo ListRenderingExtensions = m_previewService.FieldType.GetMethod ( "ListRenderingExtensions", Flags ); object previewServiceInstance = m_previewService.GetValue(viewer.LocalReport); System.Collections.IList extensions = ListRenderingExtensions.Invoke(previewServiceInstance, null) as System.Collections.IList; System.Reflection.PropertyInfo name = null; if (extensions.Count > 0) { name = extensions[0].GetType().GetProperty("Name", Flags); } if (name == null) { return; } foreach (object extension in extensions) { string thisFormat = name.GetValue(extension, null).ToString(); //{ // System.Reflection.FieldInfo m_isVisible = extension.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); // System.Reflection.FieldInfo m_isExposedExternally = extension.GetType().GetField("m_isExposedExternally", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); // object valVisible = m_isVisible.GetValue(extension); // object valExposed = m_isExposedExternally.GetValue(extension); // System.Console.WriteLine(valVisible); // System.Console.WriteLine(valExposed); //} //if (string.Compare(thisFormat, formatName, true) == 0) if (true) { System.Reflection.FieldInfo m_isVisible = extension.GetType().GetField("m_isVisible", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); System.Reflection.FieldInfo m_isExposedExternally = extension.GetType().GetField("m_isExposedExternally", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); m_isVisible.SetValue(extension, true); m_isExposedExternally.SetValue(extension, true); //break; } // End if (string.Compare(thisFormat, formatName, true) == 0) } // Next extension } // End if (m_previewService != null) } // End Sub EnableFormat
} // End Sub EnableFormat protected void Page_Load(object sender, System.EventArgs e) { if (this.Page.IsPostBack) { return; } Microsoft.Reporting.WebForms.ReportDataSource rds = new Microsoft.Reporting.WebForms.ReportDataSource(); rds.Name = "DataSet1"; //This refers to the dataset name in the RDLC file string strSQL = @"SELECT * FROM T_Benutzer"; // strSQL = strSQL.Replace("@_in_umzugsuid", "'" + in_ump_uid.Replace("'", "''") + "'"); // strSQL = strSQL.Replace("@_in_sprache", "'" + in_sprache.Replace("'", "''") + "'"); rds.Value = Basic_SQL.SQL.GetDataTable(strSQL); strSQL = null; Microsoft.Reporting.WebForms.ReportViewer rs = new Microsoft.Reporting.WebForms.ReportViewer(); //EnableFormat(rs, "HTML4.0"); EnableFormat(rs, "IMAGE"); using (System.IO.Stream reportDefinition = COR_Reports.ReportRepository.GetEmbeddedReport("PaginationTest.rdl")) { rs.LocalReport.LoadReportDefinition(reportDefinition); } // End Using reportDefinition rs.LocalReport.DataSources.Add(rds); Microsoft.Reporting.WebForms.Warning[] warnings; string[] streamids; string mimeType; string encoding; string extension; //COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.HtmlFragment); //COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.MHTML); COR_Reports.ReportFormatInfo formatInfo = new COR_Reports.ReportFormatInfo(COR_Reports.ExportFormat.Image); string deviceInfo = "<DeviceInfo>" + " <OutputFormat>EMF</OutputFormat>" + " <PageWidth>8.5in</PageWidth>" + " <PageHeight>11in</PageHeight>" + " <MarginTop>0.25in</MarginTop>" + " <MarginLeft>0.25in</MarginLeft>" + " <MarginRight>0.25in</MarginRight>" + " <MarginBottom>0.25in</MarginBottom>" + "</DeviceInfo>"; byte[] result = rs.LocalReport.Render(formatInfo.FormatName, formatInfo.DeviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings); System.Console.WriteLine(result); //Page page = new Page(); TestRender page = new TestRender(); //System.Web.UI.ScriptManager scriptManager = new ScriptManager(); //System.Web.UI.HtmlControls.HtmlForm form = new System.Web.UI.HtmlControls.HtmlForm(); //form.Controls.Add(scriptManager); //rs.AsyncRendering = false; //form.Controls.Add(rs); //page.Controls.Add(form); //page.RenderControl //// page.DataBind(); //exception here //// RenderControlToHtml2(page); string s = RenderControlToHtml(page); System.Console.WriteLine(s); } // End Sub Page_Load
public cDataSource(Microsoft.Reporting.WebForms.ReportViewer vwr) { this.mm_Viewer = vwr; }
public ReportViewer() { this.m_Viewer = new Microsoft.Reporting.WebForms.ReportViewer(); this.DataSources = new cDataSource(this.m_Viewer); this.EnableFormat("HTML4.0"); this.EnableFormat("IMAGE"); }
public static void BindControl(Microsoft.Reporting.WebForms.ReportViewer rv, DataSet data, string name) { string virtualRldc = WebApplication1.RdlcEngine.BuildRDLC(data, name); BindControl(rv, data, name, virtualRldc); }
protected override void CreateChildControls() { rv = new Microsoft.Reporting.WebForms.ReportViewer(); SPWeb rootWeb = SPContext.Current.Site.RootWeb; if (UseDefaults) { ReportingServicesURL = EPMLiveCore.CoreFunctions.getWebAppSetting(SPContext.Current.Site.WebApplication.Id, "ReportingServicesURL"); try { Integrated = bool.Parse(EPMLiveCore.CoreFunctions.getWebAppSetting(SPContext.Current.Site.WebApplication.Id, "ReportsUseIntegrated")); } catch { } } else { ReportingServicesURL = PropSRSUrl; Integrated = IsIntegratedMode; } if (string.IsNullOrEmpty(PropReportPath)) { error = "Report Path has not been set. Please configure the Report Path."; } else if (ReportingServicesURL == null || ReportingServicesURL == "") { error = "ReportingServicesURL has not been set."; } else if (Integrated && !(rootWeb.GetFile(rootWeb.Url + "/Report Library" + PropReportPath + ".rdl").Exists)) { error = "Please configure the correct Report Path."; } else { try { rv.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote; rv.ServerReport.ReportServerUrl = new Uri(ReportingServicesURL); if (Integrated) { rv.ServerReport.ReportPath = rootWeb.Url + "/Report Library" + PropReportPath + ".rdl"; } else { rv.ServerReport.ReportPath = PropReportPath; } rv.ShowToolBar = true; rv.SizeToReportContent = true; rv.EnableTheming = true; rv.CssClass = "ms-toolbar"; rv.EnableTheming = true; rv.Width = new Unit(59, UnitType.Percentage); rv.ControlStyle.Width = new Unit(79, UnitType.Percentage); Microsoft.Reporting.WebForms.ReportParameterInfoCollection rpic = rv.ServerReport.GetParameters(); List <Microsoft.Reporting.WebForms.ReportParameter> arrParams = new List <Microsoft.Reporting.WebForms.ReportParameter>(); foreach (Microsoft.Reporting.WebForms.ReportParameterInfo rpi in rpic) { if (rpi.Prompt == "") { switch (rpi.Name) { case "URL": Microsoft.Reporting.WebForms.ReportParameter rp = new Microsoft.Reporting.WebForms.ReportParameter(rpi.Name, HttpUtility.UrlEncode(SPContext.Current.Web.ServerRelativeUrl)); arrParams.Add(rp); break; case "SiteId": Microsoft.Reporting.WebForms.ReportParameter rp1 = new Microsoft.Reporting.WebForms.ReportParameter(rpi.Name, SPContext.Current.Site.ID.ToString()); arrParams.Add(rp1); break; case "WebId": Microsoft.Reporting.WebForms.ReportParameter rp2 = new Microsoft.Reporting.WebForms.ReportParameter(rpi.Name, SPContext.Current.Web.ID.ToString()); arrParams.Add(rp2); break; case "UserId": Microsoft.Reporting.WebForms.ReportParameter rp3 = new Microsoft.Reporting.WebForms.ReportParameter(rpi.Name, SPContext.Current.Web.CurrentUser.ID.ToString()); arrParams.Add(rp3); break; case "Username": Microsoft.Reporting.WebForms.ReportParameter rp4 = new Microsoft.Reporting.WebForms.ReportParameter(rpi.Name, HttpContext.Current.User.Identity.Name); arrParams.Add(rp4); break; } } } if (arrParams.Count > 0) { rv.ServerReport.SetParameters(arrParams); } } catch (Exception ex) { error = ex.Message; } } Controls.Add(rv); }
public cDataSource(Microsoft.Reporting.WebForms.ReportViewer vwr) { this.mm_Viewer = vwr; }
public bool SendToFax(int ScriptReason, int PharmacyId) { #region Sending Fax // Declare objects DataSet DataSetTemp = null; string FaxUniqueId = ""; try { DataSetClientScriptActivities = new Streamline.UserBusinessServices.DataSets.DataSetClientScripts(); #region Get RDLC Contents string _ReportPath = ""; string mimeType; string encoding; string fileNameExtension; string[] streams; byte[] renderedBytes; DataSet _DataSetRdl = new DataSet(); Streamline.UserBusinessServices.ClientMedication objectClientMedications = null; objectClientMedications = new ClientMedication(); reportViewer1 = new Microsoft.Reporting.WebForms.ReportViewer(); _DataSetRdl = objectClientMedications.GetClientMedicationRDLDataSet(Convert.ToInt32(HiddenFieldLatestClientMedicationScriptId.Value)); _ReportPath = Server.MapPath("RDLC\\MedicationReport.rdlc"); ProcessRdlReport("DataSetMedication_ssp_SCGetClientMedicationScriptDatatry", _DataSetRdl, _ReportPath); string reportType = "PDF"; IList <Stream> m_streams; m_streams = new List <Stream>(); Microsoft.Reporting.WebForms.Warning[] warnings; string deviceInfo = "<DeviceInfo><OutputFormat>PDF</OutputFormat><StartPage>0</StartPage></DeviceInfo>"; renderedBytes = reportViewer1.LocalReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); // Create PDF from rendered Bytes to send as an attachment //Stream fs = new FileStream(Server.MapPath("RDLC\\MedicationScript.pdf"), FileMode.Create); Stream fs = new FileStream(Server.MapPath("RDLC") + "\\" + Context.User.Identity.Name + "\\MedicationScript.pdf", FileMode.Create); fs.Write(renderedBytes, 0, renderedBytes.Length); fs.Close(); #endregion //Send to Fax server try { Streamline.Faxing.StreamlineFax _streamlineFax = new Streamline.Faxing.StreamlineFax(); //FaxUniqueId = _streamlineFax.SendFax(PharmacyId, ((Streamline.BaseLayer.StreamlinePrinciple)Context.User).Client.ClientId, (Server.MapPath("RDLC") + "\\" + Context.User.Identity.Name + "\\MedicationScript.pdf"), "Prescription Medication Script") ? "True" : ""; FaxUniqueId = _streamlineFax.SendFax(PharmacyId, ((Streamline.BaseLayer.StreamlinePrinciple)Context.User).Client.ClientId, (Server.MapPath("RDLC") + "\\" + Context.User.Identity.Name + "\\MedicationScript.pdf"), "Prescription Medication Script"); } catch (System.Runtime.InteropServices.COMException ex) { if (ex.Data["CustomExceptionInformation"] == null) { ex.Data["CustomExceptionInformation"] = "Source function SendToFax() of Print Order Dialog"; } else { ex.Data["CustomExceptionInformation"] = ""; } if (ex.Data["DatasetInfo"] == null) { ex.Data["DatasetInfo"] = null; } Streamline.BaseLayer.LogManager.LogException(ex, LogManager.LoggingCategory.General, LogManager.LoggingLevel.Error, this); } #region InsertRowsIntoClientScriptActivities ////Insert Rows into ClientScriptActivities DataRow drClientMedicationScriptsActivity = DataSetClientScriptActivities.Tables["ClientMedicationScriptActivities"].NewRow(); drClientMedicationScriptsActivity["ClientMedicationScriptId"] = Convert.ToInt32(HiddenFieldLatestClientMedicationScriptId.Value); drClientMedicationScriptsActivity["Method"] = 'F'; drClientMedicationScriptsActivity["PharmacyId"] = PharmacyId; drClientMedicationScriptsActivity["Reason"] = ScriptReason; drClientMedicationScriptsActivity["FaxStatusDate"] = DateTime.Now; drClientMedicationScriptsActivity["FaxStatus"] = "QUEUED"; drClientMedicationScriptsActivity["FaxExternalIdentifier"] = FaxUniqueId; drClientMedicationScriptsActivity["RowIdentifier"] = System.Guid.NewGuid(); drClientMedicationScriptsActivity["CreatedBy"] = ((Streamline.BaseLayer.StreamlineIdentity)Context.User.Identity).UserCode; drClientMedicationScriptsActivity["CreatedDate"] = DateTime.Now; drClientMedicationScriptsActivity["ModifiedBy"] = ((Streamline.BaseLayer.StreamlineIdentity)Context.User.Identity).UserCode; drClientMedicationScriptsActivity["ModifiedDate"] = DateTime.Now; DataSetClientScriptActivities.Tables["ClientMedicationScriptActivities"].Rows.Add(drClientMedicationScriptsActivity); using ( ClientMedication _clientMedication = objectClientMedications != null ? objectClientMedications : new ClientMedication()) { _clientMedication.SetRenderedImageData(DataSetClientScriptActivities, drClientMedicationScriptsActivity, ((Streamline.BaseLayer.StreamlineIdentity)Context.User.Identity) .UserCode, renderedBytes); } DataSetTemp = objectClientMedications.UpdateClientScriptActivities(DataSetClientScriptActivities); #endregion if (DataSetTemp.Tables["ClientMedicationScriptActivities"].Rows.Count > 0) { return(true); } else { return(false); } } catch (System.Runtime.InteropServices.COMException ex) { string strEx = ex.Message.ToString(); throw (ex); } finally { DataSetTemp = null; } #endregion }
public void SendFax(string strRepType, Microsoft.Reporting.WebForms.ReportViewer AIMSReportViewer, string strFaxFolder, string strFaxNumber, string strHospital, string strUserID, string strPcpID, string strPcpName, int intPtLogRecord, string strPatientName, string strComment, string strGeneralHeading, string strNotification, string strDOB, string password, string strSub, string strTo, string additonalComments) { string strReportPath; string strFileName; string strFilePath; string strCompleteFilePath; string sourceFile; string timeoffax = DateTime.Now.ToString().Substring(10, 7).Replace(":", "") + DateTime.Now.Millisecond; strFaxNumber = strFaxNumber.Substring(0, 3) + strFaxNumber.Substring(4, 3) + strFaxNumber.Substring(8, 4); strReportPath = "\\AdDisNotice\\" + strRepType + strHospital + ".rdlc"; strFileName = strRepType + strHospital + strUserID + "_" + intPtLogRecord.ToString() + "_" + timeoffax + ".pdf"; strFilePath = strFaxFolder + strRepType + "\\"; strCompleteFilePath = strFilePath + strFileName; sourceFile = strFilePath; CreatePDFDocument(strCompleteFilePath, AIMSReportViewer, strCompleteFilePath); if (strFilePath.Substring(1, 1) == ":") { strFilePath = MACHINE_PATH + strFilePath.Substring(2); } bool isFax = false; bool isEmail = false; if (strNotification == "") { isFax = true; } else { string[] arrNotification = strNotification.Split(new char[] { ';' }); if (arrNotification.Contains("Fax")) { isFax = true; } if (arrNotification.Contains("Email")) { isEmail = true; } } if (strDOB == "N/A") { strDOB = ""; } PCPCommunication comm = new PCPCommunication(); comm.AdditionalComments = additonalComments; comm.Comments = strComment; comm.CommStatus = "Created"; //Try to convert DOB to DateTime, revert to default if fails try { comm.DOB = DateTime.Parse(strDOB); } catch { comm.DOB = DateTime.Parse("1/1/1900"); } comm.DocumentName = strFileName; comm.DocumentPath = strFilePath; comm.DocumentType = strRepType; //comm.EmailID = comm.FaxCover = FAX_COVER; comm.FaxNo = strFaxNumber; comm.GenComHeading = strGeneralHeading; comm.Hospital = strHospital; //comm.Pages = comm.PatientName = strPatientName; comm.PLRecord = intPtLogRecord; comm.ToUserID = strPcpID; comm.UserID = strUserID; if (isFax) { comm.CommType = "Fax"; UpdateCommTable(comm); } if (isEmail) { comm.CommType = "Email"; if (strTo != "") { if (password == "") { password = "******"; } } string[] ret = CreateEncryptedPDF(sourceFile, strFileName, password); string outputFile = ret[0]; int pages = Convert.ToInt32(ret[1]); string strMsg = DateTime.Now.ToString(); UpdateCommTable(comm); try { if (HubSecurity.Debug() == true) { strTo = "*****@*****.**"; } SendMail("*****@*****.**", strTo, strSub, strMsg, outputFile, "fax", "aimsfx2345", null); UpdateStatus(comm, "Mail Forwarded"); strMsg = "<html><body><b>" + strSub + "</b> has been sent to <br/><br/><table><tr><td> <b>PCP</b>: </td><td>" + strPcpName + "</td></tr>" + "<tr><td><b>Mail Id: </b></td><td>" + strTo + "</td></tr>" + "<tr><td><b>Time: </b></td><td>" + DateTime.Now.ToString() + "</td></tr></table><br/><br/> Please access AIMS Hub to view details.</body></html>"; string strToCC = AimsHub.Security.HubSecurity.getLoggedInUserID() + "@aims.us.com"; SendMail("*****@*****.**", strToCC, strSub, strMsg, null, "fax", "aimsfx2345", null); } catch { UpdateStatus(comm, "Send Failed"); } File.Delete(outputFile); } }