Exemple #1
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);
            }
        }
Exemple #2
0
        public IHttpActionResult GenerarReporteBeneficiarios([FromUri] BeneficiarioReporteQuery query)
        {
            if (query.SalaCunaId != null || !String.IsNullOrEmpty(query.Codigo))
            {
                BeneficiarioReporteQueryResult queryResult = _queryDispatcher.Dispatch <BeneficiarioReporteQuery, BeneficiarioReporteQueryResult>(query);
                ReportDataSource dsBeneficiario            = new ReportDataSource("DSBeneficiario", queryResult.Beneficiarios);
                //String _params = JsonHelper.GetJsonStringFromObject(queryResult);

                Boolean          _ok            = false;
                String           _nombreArchivo = String.Empty;
                ReporteConfigDto _config        = ReportesConfiguracion.GetReporteConfig(TiposReporte.Beneficiario.Value);
                try
                {
                    byte[] bytes = ReportViewerUtil.GenerateAndPersist(_config, ref _nombreArchivo, queryResult.Beneficiarios, null);
                    GenerateExcelFromReportViewer(bytes, _config.OutputFileName + "." + _config.Format);
                    _ok = true;
                }
                catch (Exception e) {
                    Console.Write(e);
                }
                finally{
                    EnviarMail(GetUsuarioLogueado().Cuil.ToString(), _ok, _nombreArchivo, "", _config.AsuntoEmail);
                }
            }
            else
            {
                StringBuilder builder   = new StringBuilder();
                long          tickDesde = (query.FechaDesde != null ? query.FechaDesde.Value : DateTimeHelper.GetMinDateTimeNullable(query.FechaDesde)).Ticks;
                builder.Append(tickDesde);
                builder.Append(",");
                long tickHasta = (query.FechaHasta == null && query.FechaDesde != null ? DateTime.Today : DateTimeHelper.GetMinDateTimeNullable(query.FechaHasta)).Ticks;
                builder.Append(tickHasta);
                builder.Append(",");
                builder.Append(query.PersonaJuridicaId != null ? query.PersonaJuridicaId.Value : -1);
                builder.Append(",");
                builder.Append(query.SalaCunaId != null ? query.SalaCunaId.Value : -1);
                builder.Append(",");
                builder.Append(query.Codigo);
                builder.Append(",");
                builder.Append(query.NroDocumento);
                builder.Append(",");
                builder.Append(query.DadosBaja ? 'S' : 'N');
                builder.Append(",");
                builder.Append(query.DepartamentoId != null ? query.DepartamentoId.Value : -1);
                builder.Append(",");
                builder.Append(query.LocalidadId != null ? query.LocalidadId.Value : -1);
                builder.Append(",");
                builder.Append(query.BarrioId != null ? query.BarrioId.Value : -1);
                builder.Append(",");
                builder.Append(query.SituacionCritica);
                builder.Append(",");
                builder.Append(query.TipoBeneficiario != null ? query.TipoBeneficiario : "0");
                builder.Append(",");
                builder.Append(query.TipoDocumentoId);
                builder.Append(",");
                builder.Append(query.PageNumber != null ? query.PaginationFrom.Value : 0);
                builder.Append(",");
                builder.Append(query.PageNumber != null ? query.PaginationTo.Value : 10000);

                ActualizarReporteCommand command = new ActualizarReporteCommand();
                command.IdEstado      = (int)EstadoReporteEnum.Pendiente;
                command.StringProceso = builder.ToString();
                command.IdUsuario     = GetUsuarioLogueado().Id;
                command.NombreProceso = TiposReporte.Beneficiario.Value;
                _commandDispatcher.Dispatch <ActualizarReporteCommand>(command);
            }

            var respuesta = new { mensaje = _mensaje + GetEmailUsuarioLogueado() };

            return(Ok(respuesta));
        }