public static PROFESIONALES Obtener(string IDRED) { PROFESIONALES oP = new PROFESIONALES(); SqlDataReader dr = DAL.PROFESIONALES.ObtenerDatosLogin(IDRED); if (dr.Read()) { oP.bIdentificado = true; oP.IdFicepi = (int)dr["t001_idficepi"]; oP.Profesional = dr["Profesional"].ToString(); oP.Nombre = dr["NOMBRE"].ToString(); oP.Apellido1 = dr["APELLIDO1"].ToString(); oP.Apellido2 = dr["APELLIDO2"].ToString(); oP.Administrador = dr["ADM"].ToString(); oP.t001_botonfecha = dr["t001_botonfecha"].ToString(); } dr.Close(); dr.Dispose(); return(oP); }
public static void CargarRoles(int t001_idficepi, string sAdmin) { #region Creación dinámica de roles // Roles Administrador y especiales if (!Roles.RoleExists("A")) { Roles.CreateRole("A"); } if (!Roles.RoleExists("DIS")) { Roles.CreateRole("DIS"); } if (!Roles.RoleExists("REC")) { Roles.CreateRole("REC"); } // Invitado if (!Roles.RoleExists("I")) { Roles.CreateRole("I"); } // Controlador if (!Roles.RoleExists("C")) { Roles.CreateRole("C"); } // Facturador if (!Roles.RoleExists("F")) { Roles.CreateRole("F"); } // Medios if (!Roles.RoleExists("M")) { Roles.CreateRole("M"); } // Interesado if (!Roles.RoleExists("U")) { Roles.CreateRole("U"); } #endregion string sUserWindows = HttpContext.Current.User.Identity.Name.ToString(); //Se borran los roles que pudiera tener el usuario. //foreach (string Rol in Roles.GetRolesForUser(User.Identity.Name)) foreach (string Rol in Roles.GetRolesForUser(HttpContext.Current.User.Identity.Name)) { //if (Rol == "REC" && HttpContext.Current.Session["IDFICEPI_ENTRADA"] != null) continue; if (HttpContext.Current.User.IsInRole(Rol)) { Roles.RemoveUserFromRole(HttpContext.Current.User.Identity.Name.ToString(), Rol); } } //Obtengo las diferentes figuras del usuario y genero los roles //Si es administrador o superadministrador no me molesto en consultar la base de datos if (sAdmin != "") { if (!HttpContext.Current.User.IsInRole("A")) { Roles.AddUserToRole(sUserWindows, "A"); } } if (PROFESIONALES.bPerteneceDIS(int.Parse(HttpContext.Current.Session["IDFICEPI_ENTRADA"].ToString()))) { if (!HttpContext.Current.User.IsInRole("DIS")) { Roles.AddUserToRole(sUserWindows, "DIS"); } HttpContext.Current.Session["DIS"] = "S"; } if (HttpContext.Current.Session["Admin"].ToString() == "A") { if (!HttpContext.Current.User.IsInRole("REC")) { Roles.AddUserToRole(sUserWindows, "REC"); } } SqlParameter[] aParam = new SqlParameter[1]; aParam[0] = new SqlParameter("@t001_idficepi", SqlDbType.Int, 4); aParam[0].Value = t001_idficepi; SqlDataReader dr = SqlHelper.ExecuteSqlDataReader("GEM_FIGURAS", aParam); //string sFiguras = ""; while (dr.Read()) { if (!HttpContext.Current.User.IsInRole(dr["figura"].ToString())) { Roles.AddUserToRole(sUserWindows, dr["figura"].ToString()); } //sFiguras+= dr["figura"].ToString().Trim() + ","; } //if (sFiguras.Length > 0) sFiguras = sFiguras.Substring(0, sFiguras.Length - 1); //HttpContext.Current.Session["FIGURAS"] = sFiguras; dr.Close(); dr.Dispose(); }