Ejemplo n.º 1
0
        public IActionResult ReporteImg(string NombreReporte, IList <RepParametro> parametros)
        {
            FastReport.Utils.Config.WebMode = true;
            var rep      = new WebReport();
            var savePath = System.IO.Path.Combine(Startup.entorno.WebRootPath, "Reportes");
            var path     = $"{savePath}\\{NombreReporte}.frx";//guarda el frm del reporte creado de fast repor

            rep.Report.Load(path);

            var str = Resources.JsonStringProvider.GetJson(CultureInfo.CurrentCulture.Name); //idioma

            rep.Report.Dictionary.Connections[0].ConnectionString = StringProvider.StringGE;
            rep.Report.Dictionary.Connections[1].ConnectionString = StringProvider.StringEmpresas;// primera conexion
            rep.Report.Dictionary.Connections[2].ConnectionString = str;


            foreach (var item in parametros)
            {
                rep.Report.SetParameterValue(item.Nombre, item.Valor);// envia por parametro el idempresa a fast report
            }


            if (rep.Report.Prepare())
            {
                FastReport.Export.Image.ImageExport imgExport = new FastReport.Export.Image.ImageExport();
                //imgExport.ShowProgress = false;
                imgExport.ImageFormat   = FastReport.Export.Image.ImageExportFormat.Jpeg;
                imgExport.SeparateFiles = false;
                imgExport.Resolution    = 300;


                MemoryStream strm = new MemoryStream();
                rep.Report.Export(imgExport, strm);
                rep.Report.Dispose();
                imgExport.Dispose();
                strm.Position = 0;

                return(File(strm, "image/jpeg", $"{NombreReporte}.pdf"));
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
 public void Dispose()
 {
     _exp.Clear();
     _exp.Dispose();
 }