Ejemplo n.º 1
0
        //TODO Alvaro refactorizar
        private List <ReportParameter> DeterminarParametros(ReportesPendientesDto _reportesPendientesDto)
        {
            List <ReportParameter> parametros = new List <ReportParameter>();

            if (_reportesPendientesDto.NombreProceso.Equals(TiposReporte.ProductoPorFamiliaPDF.Value.ToUpper()))
            {
                int    mesInt = int.Parse(ParametrosSeparados[4]);
                string mes    = new DateTime(2022, mesInt, 2).ToString("MMMM", CultureInfo.CreateSpecificCulture("es"));
                mes = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(mes);
                parametros.Add(new ReportParameter("Mes", mes));
            }
            else if (_reportesPendientesDto.NombreProceso.Equals(TiposReporte.ProductoPorFamiliaExcel.Value.ToUpper()))
            {
                int    mesInt  = int.Parse(ParametrosSeparados[4]);
                int    anioInt = int.Parse(ParametrosSeparados[3]);
                string mes     = new DateTime(2022, mesInt, 2).ToString("MMMM", CultureInfo.CreateSpecificCulture("es"));
                mes = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(mes);
                string fecha = mes + " del " + anioInt.ToString();
                parametros.Add(new ReportParameter("Fecha", fecha));
            }
            else if (_reportesPendientesDto.NombreProceso.Equals(TiposReporte.ProductoPorSala.Value.ToUpper()))
            {
                int    mesInt = int.Parse(ParametrosSeparados[4]);
                string mes    = new DateTime(2022, mesInt, 2).ToString("MMMM", CultureInfo.CreateSpecificCulture("es"));
                mes = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(mes);
                parametros.Add(new ReportParameter("Mes", mes));
            }
            else if (_reportesPendientesDto.NombreProceso.Equals(TiposReporte.InfoGlobal.Value.ToUpper()))
            {
                string fechaCompleta = DateTimeHelper.GetFullDateAsString();
                parametros.Add(new ReportParameter("Fecha", fechaCompleta));
            }
            return(parametros.Count == 0 ? null : parametros);
        }
Ejemplo n.º 2
0
        private void GenerarReporteAsync(ReportesPendientesDto _reportesPendientesDto, ReporteConfigDto _config)
        {
            String _nombreArchivo = String.Empty;

            //Se anexa a loa parámetros el id de proceso y luego se obtiene un array de todos los parámetros.
            String _params = _reportesPendientesDto.StringProcedimiento + "," + _reportesPendientesDto.ProcesoId;

            ParametrosSeparados = _params.Split(',');

            Boolean _ok  = false;
            object  _dto = null;

            try
            {
                _reportesPendientesDto.NombreProceso = _reportesPendientesDto.NombreProceso.ToUpper();
                _repositoryLocalScheme = new RepositoryLocalScheme();

                //3)Se llama al procedimiento correspondiente al reporte asociado al proceso.

                //Madres beneficiarios
                if (_reportesPendientesDto.NombreProceso.Equals(TiposReporte.MadresBeneficiarios.Value.ToUpper()))
                {
                    _dto = GenerarReporteMadresBeneficiarios <MadresBeneficiariosDto>(_config);
                }
                //Socio ambiental
                else if (_reportesPendientesDto.NombreProceso.Equals(TiposReporte.SocioAmbiental.Value.ToUpper()))
                {
                    _dto = GenerarReporteSocioAmbiental <SocioAmbientalDto>(_config);
                }

                //Info Global
                else if (_reportesPendientesDto.NombreProceso.Equals(TiposReporte.InfoGlobal.Value.ToUpper()))
                {
                    _dto = GenerarReporteInfoGloabal <InfoGlobalDto>(_config);
                }

                //GrupoFamiliar
                else if (_reportesPendientesDto.NombreProceso.Equals(TiposReporte.GrupoFamiliar.Value.ToUpper()))
                {
                    _dto = GenerarReporteGrupoFamiliar <GrupoFamiliarDto>(_config);
                }

                //Personal por sala
                else if (_reportesPendientesDto.NombreProceso.Equals(TiposReporte.PersonalPorSala.Value.ToUpper()))
                {
                    _dto = GenerarReportePersonalPorSala <PersonalPorSalaDto>(_config);
                }

                //Producto por Sala
                else if (_reportesPendientesDto.NombreProceso.Equals(TiposReporte.ProductoPorSala.Value.ToUpper()))
                {
                    _dto = GenerarReporteProductorPorSala <ProductosPorSalaDto>(_config);
                }

                //Productor por familia PDF
                else if (_reportesPendientesDto.NombreProceso.Equals(TiposReporte.ProductoPorFamiliaPDF.Value.ToUpper()))
                {
                    _dto = GenerarReporteProductorPorFamiliaPDF <ProductoXFamiliaXSalaDto>(_config);
                }

                //Productor por familia EXCEL
                else if (_reportesPendientesDto.NombreProceso.Equals(TiposReporte.ProductoPorFamiliaExcel.Value.ToUpper()))
                {
                    _dto = GenerarReporteProductorPorFamiliaExcel <ProductoXFamiliaXSalaDto>(_config);
                }

                //Provision de producto
                else if (_reportesPendientesDto.NombreProceso.Equals(TiposReporte.ProvisionDeProducto.Value.ToUpper()))
                {
                    _dto = GenerarReporteProvisionDeProducto <ProvisionProductosReporteDto>(_config);
                }

                //Provision de producto especiales
                else if (_reportesPendientesDto.NombreProceso.Equals(TiposReporte.ProvisionDeProductoCE.Value.ToUpper()))
                {
                    _dto = GenerarReporteProvisionDeProductoCE <ProvisionProductosReporteDto>(_config);
                }

                //Salas cuna
                else if (_reportesPendientesDto.NombreProceso.Equals(TiposReporte.SalasCuna.Value.ToUpper()))
                {
                    _dto = GenerarReporteSalasCuna(_config);
                }

                //Beneficiario
                else if (_reportesPendientesDto.NombreProceso.Equals(TiposReporte.Beneficiario.Value.ToUpper()))
                {
                    _dto = GenerarReporteBeneficiario <BeneficiarioReporteDto>(_config);
                }

                if (_dto != null)
                {
                    List <ReportParameter> _reportParams = DeterminarParametros(_reportesPendientesDto);

                    //4)Creo el reporte en disco
                    ReportViewerUtil.GenerateAndPersist(_config, ref _nombreArchivo, _dto, _reportParams);
                    _ok = true;
                }
            }
            catch (Exception e)
            {
                Console.Write(e);
            }
            finally
            {
                FinalizarProceso(_reportesPendientesDto.ProcesoId, _ok);
                EnviarMail(_reportesPendientesDto.Cuil, _ok, _nombreArchivo, _params, _config.AsuntoEmail);
            }
        }