0

Tengo una Web Api donde genero un reporte, lo puedo hacer perfectamente de manera local, porque tomo los archivos .RDLC desde una ruta de mi PC, quisiera poder hacerlo igual en la WebApi, pero tomar los archivos .RDLC desde la ruta del proyecto, o alguna otra ruta que no sea de la pc, porque tengo que consumir los bytes que genera el método, desde una aplicación Android Xamarin, intente cambiar

LocalReport.Path por ServerReport.Path, pero no logro hacerlo funcionar

 DataSet ds = bdBase.bdDataset(conexion, sQuery);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    reportViewer1.ShowCredentialPrompts = false;
                    reportViewer1.ProcessingMode = ProcessingMode.Local;
                     HttpContext.Current.Server.MapPath("~/Reportes/");
                    switch (llaveemp.ToUpper())
                    {
                        case "04146959-9CD5-4419-A35E-88793D1AF8B4":
                            // FLVales
                            //HttpContext.Current.Server.MapPath("~/Reportes/promoRecAbonoFLV.rdlc");
                            reportViewer1.LocalReport.ReportPath="~/Reportes/promoRecAbonoFLV.rdlc";
                            //reportViewer1.LocalReport.ReportPath = @"C:\Saz\Saz\CrediReports\promoRecAbonoFLV.rdlc";

                            break;
                        case "AA8491CA-5E2E-4F3E-B9B2-FB8D3AB69EBD":
                            // Credimoda
                            //reportViewer1.LocalReport.ReportPath = @"C:\Saz\Saz\CrediReports\promoRecAbonoFred.rdlc";
                            /*HttpContext.Current.Server.MapPath*/
                            reportViewer1.LocalReport.ReportPath= "~/Reportes/promoRecAbonoFred.rdlc";
                            break;
                        default:
                            //reportViewer1.LocalReport.ReportPath = @"C:\Saz\Saz\CrediReports\promoRecAbono.rdlc";
                            //HttpContext.Current.Server.MapPath("~/Reportes/promoRecAbono.rdlc");
                            //string path = "~/Reportes/promoRecAbono.rdlc";
                            reportViewer1.LocalReport.ReportPath = "~/Reportes/promoRecAbono.rdlc"; 
                            break;
                    }
                }
                reportViewer1.LocalReport.SetParameters(parametros);
                reportViewer1.ShowParameterPrompts = false;
                reportViewer1.LocalReport.DataSources.Clear();
                reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", ds.Tables[0]));



                Warning[] warnings;
                String[] streamids;
                String mimeType;
                String encoding;
                String filenameExtension;

                // Render the report to a byte array
                Byte[] bytes;
                if (reportViewer1.ProcessingMode == ProcessingMode.Local)

                    bytes = reportViewer1.LocalReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);

                else

                    bytes = reportViewer1.ServerReport.Render("PDF", null, out mimeType, out encoding, out filenameExtension, out streamids, out warnings);
                var pdfbytes = JsonConvert.SerializeObject(bytes);
                return pdfbytes;
2
  • De donde viene exactamente el archivo .rdlc? Desde el disposivo movil o esta situado en otro servidor?
    – Einer
    el 9 oct. 2017 a las 18:25
  • El archivo .rdlc lo tengo en una carpeta de mi WebApi, y esa webapi está montada en el servidor de Azure @Einer, reportViewer1.LocalReport.ReportPath= HttpContext.Current.Server.MapPath("~/Reportes/promoRecAbonoFLV.rdlc"); quise hacer ésto, pero sigue sin funcionar, si toma bien el archivo, y me crea el pdf, pero sólo funciona en el localhost. el 9 oct. 2017 a las 18:35

1 respuesta 1

0

Parece ser que no se puede usar reportviewer junto con Azure, a menos que seas usuario premium, por eso funciona de manera local (localhost) y cuando se publica en el servidor de azure, manda error.

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.