/// <summary> /// Genera el reporte PDF indicado. /// </summary> /// <param name="idPv">El Id de la póliza en coaseguro.</param> /// <param name="rutaPlantilla">La ruta absoluta a la plantilla del reporte.</param> /// <param name="tipo">El tipo de reporte que se quiere generar.</param> /// <returns>Los bytes del reporte generado en PDF.</returns> private static byte[] GenerarReporte(int idPv, string rutaPlantilla, TipoReporteCoaseguro tipo) { var outputDir = Path.Combine(rutaLatex, Guid.NewGuid().ToString()); var latexIO = ObtenerLectorEscritor(idPv, tipo); var plantilla = latexIO.LeerPlantilla(rutaPlantilla); latexIO.GenerarReporte(plantilla, outputDir); var pdf = latexIO.LeerReporte(outputDir); Directory.Delete(outputDir, true); return(pdf); }
/// <summary> /// Regresa una nueva instancia de <see cref="LatexLectorEscritor"/> dependiendo /// del tipo requerido. /// </summary> /// <param name="idPv">El Id de la póliza en coaseguro.</param> /// <param name="tipo">El tipo de reporte que se quiere generar.</param> /// <returns>Una nueva instancia de <see cref="LatexLectorEscritor"/>.</returns> private static LatexLectorEscritor ObtenerLectorEscritor(int idPv, TipoReporteCoaseguro tipo) { using (var dao = new CoaseguroDao()) { var encabezado = dao.ObtenerEncabezado(idPv); switch (tipo) { case TipoReporteCoaseguro.CedulaParticipacion: var datosCedula = dao.ObtenerCedulaParticipacion(idPv); return(new CedulaLectorEscritor(datosCedula, encabezado, rutaEjecutable, inputDir)); case TipoReporteCoaseguro.AnexoCondicionesParticulares: var datosAnexo = dao.ObtenerAnexoCondicionesParticulares(idPv); return(new AnexoLectorEscritor(datosAnexo, encabezado, rutaEjecutable, inputDir)); case TipoReporteCoaseguro.Ambos: default: var cedula = dao.ObtenerCedulaParticipacion(idPv); var anexo = dao.ObtenerAnexoCondicionesParticulares(idPv); return(new CedulaAnexoLectorEscritor(cedula, anexo, encabezado, rutaEjecutable, inputDir)); } } }