Example #1
0
        /// <summary>
        /// Método que crea un usuario. 
        /// </summary>
        private void ObtenerRolesUsuario()
        {
            //Obtengo todos los roles del usuario y los cargo en el Data.
            string[] arrRoles = Roles.GetRolesForUser(Data.Usuario.Nombre);

            foreach (string rolUsuario in arrRoles)
            {
                DTRol objDTRol = new DTRol { Nombre = rolUsuario, NombreCorto = rolUsuario.ToLower() };
                //Obtiene el IDRol desde la enumeracion enumRoles
                objDTRol.ID = Enum.Parse(typeof(enumRoles), rolUsuario).GetHashCode();
                Data.Usuario.ListaRoles.Add(objDTRol);
            }
        }
Example #2
0
 /// <summary>
 /// Recorrers the coleccion.
 /// </summary>
 /// <param name="nodo">The nodo.</param>
 /// <returns></returns>
 private Seccion recorrerColeccion(SiteMapNode nodo)
 {
     List<DTRol> listaRoles;
     List<Seccion> listaSecciones = new List<Seccion>();
     Seccion objSeccion;
     DTRol rol;
     objSeccion = new Seccion();
     objSeccion.title = nodo.Title;
     objSeccion.url = nodo.Url;
     listaRoles = new List<DTRol>();
     foreach (string strRol in nodo.Roles)
     {
         rol = new DTRol();
         rol.Nombre = strRol;
         listaRoles.Add(rol);
     }
     objSeccion.listaRoles = listaRoles;
     foreach (SiteMapNode nodoHijo in nodo.ChildNodes)
     {
         listaSecciones.Add(recorrerColeccion(nodoHijo));
     }
     objSeccion.listaSecciones = listaSecciones;
     return objSeccion;
 }
Example #3
0
        /// <summary>
        /// Ventanas the aceptar.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void VentanaAceptar(object sender, EventArgs e)
        {
            try
            {
                DTRol objRol;
                switch (AccionPagina)
                {
                    case enumAcciones.Eliminar:
                        AccionPagina = enumAcciones.Limpiar;
                        objRol = new DTRol();
                        objRol.Nombre = propRol.Nombre;
                        EliminarRol(objRol);
                        break;
                    case enumAcciones.Guardar:
                        AccionPagina = enumAcciones.Limpiar;
                        objRol = new DTRol();
                        if (esNuevo)
                        {
                            objRol.Descripcion = txtNuevaDescripcion.Text;
                            objRol.Nombre = txtNuevoRol.Text;
                            objRol.NombreCorto = objRol.Nombre.ToLower();
                            objRol.RoleId = null;
                        }
                        else
                        {
                            objRol.Descripcion = txtDescripcion.Text;
                            objRol.RoleId = propRol.RoleId;
                            objRol.Nombre = propRol.Nombre;
                        }
                        GuardarRol(objRol);
                        Master.MostrarMensaje(enumTipoVentanaInformacion.Satisfactorio.ToString(), UIConstantesGenerales.MensajeGuardadoOk, enumTipoVentanaInformacion.Satisfactorio);
                        break;
                    case enumAcciones.Nuevo:
                        break;

                }
                CargarPresentacion();
            }
            catch (Exception ex)
            {
                Master.ManageExceptions(ex);
            }
        }
Example #4
0
        /// <summary>
        /// Handles the CreatedUser event of the RegisterUser control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void RegisterUser_CreatedUser(object sender, EventArgs e)
        {
            propSeguridad = new DTSeguridad();
            propSeguridad.Usuario.Nombre = RegisterUser.UserName.Trim();
            //Personal = 1,
            //Alumno = 2,
            //Tutor = 3
            DTRol rol = new DTRol();

            switch (propPersona.idTipoPersona)
            {
                case 1:
                    rol.Nombre = enumRoles.Administrativo.ToString();
                    break;
                case 2:
                    rol.Nombre = enumRoles.Alumno.ToString();
                    break;
                case 3:
                    rol.Nombre = enumRoles.Tutor.ToString();
                    break;
            }
            //asigna un rol por defecto, en función de la persona
            propSeguridad.Usuario.ListaRoles.Add(rol);
            propSeguridad.Usuario.Aprobado = true;
            propSeguridad.Usuario.EsUsuarioInicial = false;

            //encriptar la password
            propSeguridad.Usuario.PasswordNuevo = BLEncriptacion.Encrypt(RegisterUser.Password);
            propSeguridad.Usuario.Password = RegisterUser.Password;

            objBLSeguridad = new BLSeguridad(propSeguridad);
            objBLSeguridad.ActualizarUsuario();

            objBLSeguridad.CambiarPassword();

            //actualiza el nombre de usuario en la persona
            propPersona.username = propSeguridad.Usuario.Nombre;
            BLPersona objBLPersona = new BLPersona(propPersona);
            objBLPersona.Save();

            //loquea al usuario y lo redirecciona a la pagina de inicio de usuarios logueados
            Session.Abandon();
            FormsAuthentication.SignOut();
            FormsAuthentication.Initialize();
            FormsAuthentication.SetAuthCookie(propSeguridad.Usuario.Nombre, true /* createPersistentCookie */);
            ObjSessionDataUI.ObjDTUsuario = propSeguridad.Usuario;

            string continueUrl = RegisterUser.ContinueDestinationPageUrl;
            if (string.IsNullOrEmpty(continueUrl))
                continueUrl = "~/Private/Account/Welcome.aspx";
            Response.Redirect(continueUrl, false);
        }
Example #5
0
        /// <summary>
        /// Guardars the rol.
        /// </summary>
        private void GuardarRol(DTRol objRol)
        {
            DTSeguridad objDTSeguridad = new DTSeguridad { Rol = objRol };
            objBLSeguridad = new BLSeguridad();
            objBLSeguridad.Data = objDTSeguridad;
            objBLSeguridad.GuardarRol();

            BuscarRoles(propSeguridad);
            LimpiarCampos();
        }
Example #6
0
 /// <summary>
 /// Método que se llama al hacer click sobre las acciones de la grilla
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewCommandEventArgs"/> instance containing the event data.</param>
 protected void gvwPerfiles_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     try
     {
         switch (e.CommandName)
         {
             case "Eliminar":
                 AccionPagina = enumAcciones.Eliminar;
                 propRol = new DTRol();
                 propRol.Nombre = e.CommandArgument.ToString();
                 Master.MostrarMensaje(enumTipoVentanaInformacion.Confirmación.ToString(), UIConstantesGenerales.MensajeEliminar, enumTipoVentanaInformacion.Confirmación);
                 break;
             case "Editar":
                 AccionPagina = enumAcciones.Modificar;
                 esNuevo = false;
                 propRol = new DTRol();
                 propRol.RoleId = e.CommandArgument.ToString();
                 propRol.Nombre = lblNombreRol.Text;
                 btnBuscar.Visible = false;
                 btnNuevo.Visible = false;
                 btnVolver.Visible = true;
                 btnGuardar.Visible = true;
                 CargarRol();
                 udpEditRoles.Visible = true;
                 udpEditRoles.Update();
                 break;
         }
     }
     catch (Exception ex)
     {
         Master.ManageExceptions(ex);
     }
 }
Example #7
0
        public void UpdateRol(DTRol objRol)
        {
            try
            {
                const string query = @"UPDATE aspnet_Roles
                                        SET Description = @Descripcion
                                        WHERE RoleId = @RoleId";

                transaction.DBcomand = transaction.DataBase.GetSqlStringCommand(query);

                // Añadir parámetros
                transaction.DataBase.AddInParameter(transaction.DBcomand, "@RoleId", DbType.String, objRol.RoleId);
                transaction.DataBase.AddInParameter(transaction.DBcomand, "@Descripcion", DbType.String, objRol.Descripcion);

                transaction.DataBase.ExecuteNonQuery(transaction.DBcomand);
            }
            catch (SqlException ex)
            {
                throw new CustomizedException(string.Format("Fallo en {0} - UpdateRol()", ClassName),
                                                       ex, enuExceptionType.SqlException);
            }
            catch (Exception ex)
            {
                throw new CustomizedException(string.Format("Fallo en {0} - UpdateRol()", ClassName),
                                                       ex, enuExceptionType.DataAccesException);
            }
        }
Example #8
0
        /// <summary>
        /// Método que obtiene la lista de Roles de la aplicacion
        /// </summary>  
        /// <param name="objDTSeguridad">DTO con los parametros dentro</param>
        /// <returns>Lista con los roles</returns>
        public List<DTRol> GetRoles(DTSeguridad objDTSeguridad)
        {
            string rolesParam = string.Empty;
            try
            {
                string query = @"SELECT
                                             ROL.RoleId
                                            ,ROL.RoleName
                                            ,ROL.LoweredRoleName
                                            ,ROL.Description
                                        FROM
                                            aspnet_Roles			AS ROL
                                            INNER JOIN
                                            aspnet_Applications AS APP
                                            ON
                                            ROL.ApplicationId = APP.ApplicationId
                                        WHERE
                                            APP.ApplicationName = @ApplicationName";

                if (objDTSeguridad.ListaRoles.Count != 0)
                {
                    foreach (DTRol rol in objDTSeguridad.ListaRoles)
                        rolesParam += string.Format("'{0}',", rol.Nombre);

                    rolesParam = rolesParam.Substring(0, rolesParam.Length - 1);
                    query = string.Format("{0} AND ROL.RoleName IN ({1})", query, rolesParam);
                }

                transaction.DBcomand = transaction.DataBase.GetSqlStringCommand(query);

                // Añadir parámetros
                transaction.DataBase.AddInParameter(transaction.DBcomand, "@ApplicationName", DbType.String, objDTSeguridad.Aplicacion);

                IDataReader reader = transaction.DataBase.ExecuteReader(transaction.DBcomand);
                List<DTRol> listaRoles = new List<DTRol>();
                while (reader.Read())
                {
                    DTRol rol = new DTRol()
                    {
                        RoleId = reader["RoleId"].ToString(),
                        Descripcion = reader["Description"].ToString(),
                        Nombre = reader["RoleName"].ToString(),
                        NombreCorto = reader["LoweredRoleName"].ToString()
                    };
                    listaRoles.Add(rol);
                }
                return listaRoles;
            }
            catch (SqlException ex)
            {
                throw new CustomizedException(string.Format("Fallo en {0} - GetRoles()", ClassName),
                                                       ex, enuExceptionType.SqlException);
            }
            catch (Exception ex)
            {
                throw new CustomizedException(string.Format("Fallo en {0} - GetRoles()", ClassName),
                                                       ex, enuExceptionType.DataAccesException);
            }
        }
Example #9
0
        /// <summary>
        /// Método que obtiene un rol filtrado por el ID
        /// </summary>  
        /// <param name="objRol">DTO con los parametros dentro</param>
        /// <returns>Rol</returns>
        public DTRol GetRol(DTRol objRol)
        {
            try
            {
                const string query = @"
                                        SELECT
                                             ROL.RoleId
                                            ,ROL.RoleName
                                            ,ROL.LoweredRoleName
                                            ,ROL.Description
                                        FROM
                                            aspnet_Roles AS ROL
                                        WHERE
                                           ( @RoleId IS NULL OR ROL.RoleId = @RoleId )
                                            AND
                                           ( @Nombre IS NULL OR ROL.RoleName = @Nombre )";

                transaction.DBcomand = transaction.DataBase.GetSqlStringCommand(query);

                // Añadir parámetros
                if (!string.IsNullOrEmpty(objRol.RoleId))
                    transaction.DataBase.AddInParameter(transaction.DBcomand, "@RoleId", DbType.String, objRol.RoleId);
                else
                    transaction.DataBase.AddInParameter(transaction.DBcomand, "@RoleId", DbType.String, DBNull.Value);
                if (!string.IsNullOrEmpty(objRol.Nombre))
                    transaction.DataBase.AddInParameter(transaction.DBcomand, "@Nombre", DbType.String, objRol.Nombre);
                else
                    transaction.DataBase.AddInParameter(transaction.DBcomand, "@Nombre", DbType.String, DBNull.Value);

                IDataReader reader = transaction.DataBase.ExecuteReader(transaction.DBcomand);

                while (reader.Read())
                {
                    objRol.RoleId = reader["RoleId"].ToString();
                    objRol.Nombre = reader["RoleName"].ToString();
                    objRol.NombreCorto = reader["LoweredRoleName"].ToString();
                    if (!string.IsNullOrEmpty(reader["Description"].ToString()))
                        objRol.Descripcion = reader["Description"].ToString();
                }
                return objRol;
            }
            catch (SqlException ex)
            {
                throw new CustomizedException(string.Format("Fallo en {0} - GetRol()", ClassName),
                                                       ex, enuExceptionType.SqlException);
            }
            catch (Exception ex)
            {
                throw new CustomizedException(string.Format("Fallo en {0} - GetRol()", ClassName),
                                                       ex, enuExceptionType.DataAccesException);
            }
        }