public GenerarPDFAdelantoResponseDTO GenerarPDF(int id) { GenerarPDFAdelantoResponseDTO response = new GenerarPDFAdelantoResponseDTO(); response.resultado = _IAdelantoRepository.GenerarPDF(id).ToList(); return(response); }
public IActionResult GenerarPDFAdelanto(int id) { Guid guid = Guid.NewGuid(); _log.RegistrarEvento($"{guid}{Environment.NewLine}{JsonConvert.SerializeObject(id)}"); //ES MOMENTANEO SE DEBE ELIMINAR GenerarPDFAdelantoResponseDTO response = _AdelantoService.GenerarPDF(id); try { string mimetype = ""; int extension = 1; var path = $"{_webHostEnvironment.ContentRootPath}\\Reportes\\rptAdelanto.rdlc"; LocalReport lr = new LocalReport(path); Dictionary <string, string> parameters = new Dictionary <string, string>(); lr.AddDataSource("dsAdelanto", Util.ToDataTable(response.resultado)); var result = lr.Execute(RenderType.Pdf, extension, parameters, mimetype); return(File(result.MainStream, "application/pdf")); } catch (ResultException ex) { response.Result = new Result() { Success = true, ErrCode = ex.Result.ErrCode, Message = ex.Result.Message }; } catch (Exception ex) { response.Result = new Result() { Success = false, Message = "Ocurrio un problema en el servicio, intentelo nuevamente." }; _log.RegistrarEvento(ex, guid.ToString()); } _log.RegistrarEvento($"{guid}{Environment.NewLine}{JsonConvert.SerializeObject(response)}"); return(Ok(response)); }