public ViewModelReporteTipoOpinionCaptacion CragarCatalogosPdf(int pi, int?idRol)
        {
            ViewModelReporteTipoOpinionCaptacion vmr = new ViewModelReporteTipoOpinionCaptacion();
            ErrorProcedimientoAlmacenado         errorProcedimientoAlmacenado = new ErrorProcedimientoAlmacenado();

            vmr.Delegacion   = new List <SelectListItem>();
            vmr.ReportesList = new List <SelectListItem>();
            vmr.FiltroPdf    = new FiltroReportePorTiposOpinionCaptacion();
            vmr.ReportesList.Add(new SelectListItem {
                Value = "0", Text = "-Selecciona-"
            });
            vmr.ReportesList.Add(new SelectListItem {
                Value = "2", Text = "Peticiones por tipo de opinión."
            });
            vmr.ReportesList.Add(new SelectListItem {
                Value = "3", Text = "Peticiones por delegación."
            });
            vmr.ReportesList.Add(new SelectListItem {
                Value = "4", Text = "Tipo opinión más ejercida."
            });
            try
            {
                var lista = rdnListaDelegaciones.solicitarDelegaciones(pi, errorProcedimientoAlmacenado);
                if (idRol == 1)
                {
                    vmr.Delegacion.Add(new SelectListItem {
                        Value = "", Text = "-Selecciona-", Selected = true
                    });
                }
                foreach (var item in lista)
                {
                    vmr.Delegacion.Add(new SelectListItem {
                        Value = item.IdUnidadAdministrativa.ToString(), Text = item.Nombre
                    });
                }
                return(vmr);
            }
            catch
            {
                return(vmr);
            }
        }
Ejemplo n.º 2
0
        public ActionResult Reportes(ViewModelReporteTipoOpinionCaptacion vmr, int ReporteNumero)
        {
            //System.Threading.Thread.Sleep(5000);

            //System.Threading.Thread.Sleep(10000);


            int?idRol = Convert.ToInt32(Session["IdUsuarioRolReportes"]);
            CargaCatalogoReportesPdf vmrFI = new CargaCatalogoReportesPdf();

            vmr.ReporteNumero = ReporteNumero;
            //List<string>  MI =  FormularioReportes.AllKeys.ToList();
            ////string CatTipOp = (Request["datepickerStart"]).ToString();

            if (vmr.FiltroPdf.FechaInicio == null || vmr.FiltroPdf.FechaFin == null)
            {
                ViewBag.ErrorMessage = "Se necesita una fecha inicio y fecha fin.";
                return(View(vmrFI.CragarCatalogosPdf(Convert.ToInt32(Session["UserLoggedId"]), idRol)));
            }
            if (vmr.ReporteNumero == 0)
            {
                ViewBag.ErrorMessage = "Selecciona algún reporte, en la lista Reportes.";
                return(View(vmrFI.CragarCatalogosPdf(Convert.ToInt32(Session["UserLoggedId"]), idRol)));
            }
            if (vmr.ReporteNumero == 3)
            {
                if ((vmr.FiltroPdf.FechaInicio != null && vmr.FiltroPdf.FechaFin != null))
                {
                    if ((vmr.FiltroPdf.FechaInicio <= vmr.FiltroPdf.FechaFin) && (vmr.FiltroPdf.FechaFin >= vmr.FiltroPdf.FechaInicio))
                    {
                        try
                        {
                            return(generarReportePorPeticionesDelegacion(vmr.FiltroPdf));
                        }
                        catch (Exception e)
                        {
                            if (e.Source == "Peticiones por delegación, vacío.")
                            {
                                ViewBag.InfoMessage = "Sin información en el rango de fechas: reporte por peticiones por delegación, vacío..";
                            }
                            else
                            {
                                ViewBag.ErrorMessage = "Al descargar el reporte por peticiones por delegación." + e.ToString();
                            }
                            return(View(vmrFI.CragarCatalogosPdf(Convert.ToInt32(Session["UserLoggedId"]), idRol)));;
                        }
                    }
                    else
                    {
                        ViewBag.WarningMessage = "La fecha inicio no puede ser mayor a la fecha fin o la fecha fin no puede ser menor a la fecha inicio.";
                        return(View(vmrFI.CragarCatalogosPdf(Convert.ToInt32(Session["UserLoggedId"]), idRol)));
                    }
                }
            }
            else if (vmr.ReporteNumero == 2)
            {
                if ((vmr.FiltroPdf.FechaInicio != null && vmr.FiltroPdf.FechaFin != null))
                {
                    if ((vmr.FiltroPdf.FechaInicio <= vmr.FiltroPdf.FechaFin) && (vmr.FiltroPdf.FechaFin >= vmr.FiltroPdf.FechaInicio))
                    {
                        try
                        {
                            return(generarReportePorPeticionesTipoOpinion(vmr.FiltroPdf));
                        }
                        catch (Exception e)
                        {
                            if (e.Source == "Reporte por peticiones por tipo opinión, vacío.")
                            {
                                ViewBag.InfoMessage = "Sin información en el rango de fechas: reporte por peticiones por tipo de opinión.";
                            }
                            else
                            {
                                ViewBag.ErrorMessage = "Al descargar el reporte por peticiones por tipo de opinión: " + e.ToString();
                            }
                            return(View(vmrFI.CragarCatalogosPdf(Convert.ToInt32(Session["UserLoggedId"]), idRol)));
                        }
                    }
                    else
                    {
                        ViewBag.WarningMessage = "La fecha inicio no puede ser mayor a la fecha fin o la fecha fin no puede ser menor a la fecha inicio.";
                        return(View(vmrFI.CragarCatalogosPdf(Convert.ToInt32(Session["UserLoggedId"]), idRol)));
                    }
                }
            }
            else if (vmr.ReporteNumero == 4)
            {
                if ((vmr.FiltroPdf.FechaInicio != null && vmr.FiltroPdf.FechaFin != null))
                {
                    if ((vmr.FiltroPdf.FechaInicio <= vmr.FiltroPdf.FechaFin) && (vmr.FiltroPdf.FechaFin >= vmr.FiltroPdf.FechaInicio))
                    {
                        try
                        {
                            return(generarReporteTipoOpinionMasEjercida(vmr.FiltroPdf));
                        }
                        catch (Exception e)
                        {
                            if (e.Source == "Reporte tipo opinión más ejercida, vacío.")
                            {
                                ViewBag.InfoMessage = "Sin información en el rango de fechas: reporte por tipo opinión más ejercida.";
                            }
                            else
                            {
                                ViewBag.ErrorMessage = "Al descargar el reporte por tipo opinión más ejercida: " + e.ToString();
                            }
                            return(View(vmrFI.CragarCatalogosPdf(Convert.ToInt32(Session["UserLoggedId"]), idRol)));
                        }
                    }
                    else
                    {
                        ViewBag.WarningMessage = "La fecha inicio no puede ser mayor a la fecha fin o la fecha fin no puede ser menor a la fecha inicio.";
                        return(View(vmrFI.CragarCatalogosPdf(Convert.ToInt32(Session["UserLoggedId"]), idRol)));
                    }
                }
            }

            return(RedirectToAction("Reportes"));
        }