Ejemplo n.º 1
0
        //
        // GET: /Home/
        public ActionResult Index()
        {
            if (Session["logged"] == null || int.Parse(Session["logged"].ToString()) == 0)
            {
                return(this.RedirectToAction("ShowForm", "Auth"));
            }

            Session["grupos"] = DaoLib.grupos_del_usuario(int.Parse(Session["usuario"].ToString()));
            if ((Session["grupos"] as List <object>).Count == 0)
            {
                TempData["error"] = "Sin grupos.<br/>Debe pedir el alta en el sistema";
                return(RedirectToAction("Login", "Auth"));
            }

            var datos = DaoLib.datos_del_usuario(Session["usuario"].ToString());

            ViewData["datos_del_usuario"] = datos;

            //HACK: Hasta que ricardo actualice
            if (ConfigurationManager.AppSettings["validate_access_level"] == "false")
            {
                (datos[0] as Dictionary <string, string>)["NIVACC"] = "6";
            }

            //Si es 1 (!=6 && !=9): solo reportes
            if ((datos[0] as Dictionary <string, string>)["NIVACC"] != "6" && (datos[0] as Dictionary <string, string>)["NIVACC"] != "9")
            {
                return(RedirectToAction("Index", "Reporte"));
            }

            //Debe profilear?
            string[] profile_users = ConfigurationManager.AppSettings["profile_users"].Split(',');
            Session["should_profile"] = profile_users.Contains(Session["usuario"].ToString()) ? "yes" : null;

            int grp = int.Parse(((Session["grupos"] as List <object>)[0] as Dictionary <string, string>)["GRUPO"]);

            Session["grupo"] = grp;
            Session["zonas"] = DaoLib.zonas_del_grupo(grp);

            string id = ((Session["zonas"] as List <object>)[0] as Dictionary <string, string>)["ID"];

            Session["punto"] = id;

            recalcular_barcos_para_punto(id);

            return(View());
        }