protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DaoActivity actividad = new DaoActivity();

            if (Thread.CurrentPrincipal.Identity.IsAuthenticated)
            {
                string usuarioActual = Thread.CurrentPrincipal.Identity.Name;
                //  string nombreUsuario = SessionHelper.GetSessionData("NombreUsuario").ToString();
                MembershipUser u  = Membership.GetUser(usuarioActual);
                var            up = new GestionRoles().GetRolesForUser(usuarioActual);
                //validamos que tenga permisos para esta pagina

                var tienePermisos = new DaoPerfil().PerfilTieneAcceso(up.First(), PaginaActual);
                if (!tienePermisos)
                {
                    SessionHelper.SetSessionData("SINPERMISOS", "No tiene Permisos para estar en esta pagina");
                    Response.Redirect("../Paginas/Default.aspx");
                }
                Guid a = new Guid(u.ProviderUserKey.ToString());
                actividad.registrarLog(a, PaginaActual);
            }
        }
    }
    public static object Eliminar(
        int ID, string Prefijo
        )
    {
        try
        {
            DaoPerfil perfilDao = new DaoPerfil();



            bool resultado = false;

            resultado = perfilDao.DeletePerfil(ID);
            GestionRoles gestRoles = new GestionRoles();
            #region ("Resultado agregar")
            if (resultado)
            {
                gestRoles.DeleteRole(Prefijo);

                return(new
                {
                    Ok = "OK",
                    mensaje = "Se ha agregado el registro Correctamente"
                });
            }
            else
            {
                return(new
                {
                    Ok = "error",
                    mensaje = "No se ha podido registrar el usuario."
                });
            }
            #endregion
        }
        catch (Exception ex)
        {
            return(new
            {
                Ok = "Error",
                mensaje = "ha Ocurrido un error inesperado: " + ex.ToString()
            });
        }
    }
Beispiel #3
0
    public static object Eliminar(
        String ID
        )
    {
        try
        {
            DaoPerfil      perfilDao = new DaoPerfil();
            GestionUsuario gestor    = new GestionUsuario();


            bool resultado = false;

            resultado = gestor.DeleteUser(ID);
            GestionRoles gestRoles = new GestionRoles();
            #region ("Resultado agregar")
            if (resultado)
            {
                return(new
                {
                    OK = "OK",
                    mensaje = "Se ha Eliminado el registro Correctamente"
                });
            }
            else
            {
                return(new
                {
                    OK = "error",
                    mensaje = "No se ha podido eliminar el usuario."
                });
            }
            #endregion
        }
        catch (Exception ex)
        {
            return(new
            {
                OK = "Error",
                mensaje = "ha Ocurrido un error inesperado: " + ex.ToString()
            });
        }
    }
    public static object EditarAgregar(
        string NombrePerfil, string Descripcion, string Prefijo,
        int ID,
        bool EsEditar)
    {
        try
        {
            DaoPerfil perfilDao = new DaoPerfil();

            GestionRoles gestRoles = new GestionRoles();

            //
            if (!EsEditar)
            {
                #region ("AGREGAR")


                bool resultado = false;
                #region (verificar si existe el rol por el prefijo)
                var existe = gestRoles.RoleExists(Prefijo);
                if (existe)
                {
                    return(new
                    {
                        Ok = "Error",
                        mensaje = "El perfil ya existe en nuestra base de datos, se identifica por el PREFIJO"
                    });
                }

                #endregion
                resultado = perfilDao.InsertPerfil(NombrePerfil, Descripcion, Prefijo);
                #region ("Resultado agregar")
                if (resultado)
                {
                    gestRoles.CreateRole(Prefijo);

                    return(new
                    {
                        Ok = "OK",
                        mensaje = "Se ha agregado el registro Correctamente"
                    });
                }
                else
                {
                    return(new
                    {
                        Ok = "error",
                        mensaje = "No se ha podido registrar el usuario."
                    });
                }
                #endregion
            }
            else
            {
                var resultado = perfilDao.ActualizarPerfil(NombrePerfil, Descripcion, ID);
                if (resultado)
                {
                    return(new
                    {
                        Ok = "OK",
                        mensaje = "Se ha Actualizado el registro Correctamente"
                    });
                }
                else
                {
                    return(new
                    {
                        Ok = "error",
                        mensaje = "No se ha podido Actualizar el registro ."
                    });
                }
            }


            #endregion
        }
        catch (Exception ex)
        {
            return(new
            {
                Ok = "Error",
                mensaje = "ha Ocurrido un error inesperado: " + ex.ToString()
            });
        }
    }
    private static GridData _getListListConPaginacion(int pageIndex, int pageSize, int pageCount, bool isSearch, string searchField, string searchString, string searchOper)
    {
        try
        {
            int totalRecords = 0;

            DaoPerfil perfilDao = new DaoPerfil();

            var resultado = perfilDao.GetPerfiles(pageIndex, pageSize, ref totalRecords);
            totalRecords = resultado.Count();
            List <GridRow> listProcesos = new List <GridRow>();

            #region ("TOTAL==0")
            if (totalRecords == 0)
            {
                return(new GridData
                {
                    page = pageIndex,
                    total = (int)Math.Ceiling((double)totalRecords / (double)pageSize),
                    records = totalRecords,
                    rows = new List <GridRow>(),
                    userMessage = "Se han cargado los datos con éxito.",
                    logMessage = "Carga satisfactoria...",
                    status = Status.OK
                });
            }
            #endregion
            else
            {
                //pageIndex,
                //pageSize, ref totalRecords, estado, banda, UID, plan, cliente);
                int id = 0;
                foreach (var proceso in resultado)
                {
                    id++;
                    listProcesos.Add(

                        new GridRow()
                    {
                        id   = proceso.ID_PERFIL.ToString(),
                        cell = new List <object>()
                        {
                            proceso.ID_PERFIL,
                            proceso.NOMBRE_PERFIL,
                            proceso.DESCRIPCION,
                            proceso.PREFIJO
                        }
                    });
                }
            }

            /// Con la información de los procesos y de la consulta se ensambla el objeto GridData de respuesta.
            ///
            return(new GridData
            {
                page = pageIndex,
                total = (int)Math.Ceiling((double)totalRecords / (double)pageSize),
                records = totalRecords,
                rows = listProcesos,
                userMessage = "Se han cargado los datos con éxito.",
                logMessage = "Carga satisfactoria...",
                status = Status.OK
            });
        }
        catch (Exception ex)
        {
            AppLog.Write(" Error consultando la informacion de Cities ", AppLog.LogMessageType.Error, ex, "IbMallsLog");

            return(new GridData
            {
                page = pageIndex,
                total = default(int),
                records = default(int),
                rows = new List <GridRow>(),
                userMessage = "Se han cargado los datos con éxito.",
                logMessage = "Carga satisfactoria...",
                status = Status.OK_WITH_MESSAGES
            });
        }
    }
Beispiel #6
0
    private static GridData _getListListConPaginacion(int pageIndex, int pageSize, int pageCount, bool isSearch, string searchField, string searchString, string searchOper)
    {
        try
        {
            int totalRecords = 0;

            DaoPerfil      perfilDao     = new DaoPerfil();
            GestionUsuario gestorusuario = new GestionUsuario();


            var resultado = gestorusuario.GetAllUsers(pageIndex - 1, pageSize, out totalRecords);// perfilDao.GetPerfiles(pageIndex, pageSize, ref totalRecords);
            //  totalRecords = resultado.Count();
            List <GridRow> listProcesos = new List <GridRow>();

            #region ("TOTAL==0")
            if (totalRecords == 0)
            {
                return(new GridData
                {
                    page = pageIndex,
                    total = (int)Math.Ceiling((double)totalRecords / (double)pageSize),
                    records = totalRecords,
                    rows = new List <GridRow>(),
                    userMessage = "Se han cargado los datos con éxito.",
                    logMessage = "Carga satisfactoria...",
                    status = Status.OK
                });
            }
            #endregion
            else
            {
                //pageIndex,
                //pageSize, ref totalRecords, estado, banda, UID, plan, cliente);
                int id       = 0;
                var userList = new List <MembershipUser>();
                foreach (MembershipUser user in resultado)
                {
                    userList.Add(user);
                }
                foreach (var proceso in userList)
                {
                    id++;

                    var rolesForUser = Roles.GetRolesForUser(proceso.UserName);


                    string rolP = "";
                    foreach (var roles in rolesForUser)
                    {
                        rolP = rolP + roles;
                        rolP = rolP + "; ";
                    }
                    listProcesos.Add(


                        new GridRow()
                    {
                        id   = proceso.UserName.ToString(),
                        cell = new List <object>()
                        {
                            proceso.UserName,
                            proceso.IsLockedOut,
                            proceso.LastActivityDate.ToString("yyyy/MM/dd HH:mm"),
                            proceso.Email,
                            rolP
                        }
                    });
                }
            }

            /// Con la información de los procesos y de la consulta se ensambla el objeto GridData de respuesta.
            ///
            return(new GridData
            {
                page = pageIndex,
                total = (int)Math.Ceiling((double)totalRecords / (double)pageSize),
                records = totalRecords,
                rows = listProcesos,
                userMessage = "Se han cargado los datos con éxito.",
                logMessage = "Carga satisfactoria...",
                status = Status.OK
            });
        }
        catch (Exception ex)
        {
            AppLog.Write(" Error consultando la informacion de Cities ", AppLog.LogMessageType.Error, ex, "IbMallsLog");

            return(new GridData
            {
                page = pageIndex,
                total = default(int),
                records = default(int),
                rows = new List <GridRow>(),
                userMessage = "Se han cargado los datos con éxito.",
                logMessage = "Carga satisfactoria...",
                status = Status.OK_WITH_MESSAGES
            });
        }
    }
        public List <PERFIL> Read()
        {
            DaoPerfil dao = new DaoPerfil();

            return(dao.Read());
        }
        public string Insert(PERFIL dto)
        {
            DaoPerfil dao = new DaoPerfil();

            return(dao.Insert(dto));
        }
        public string Delete(string dto)
        {
            DaoPerfil dao = new DaoPerfil();

            return(dao.Delete(dto));
        }
        public string Update(PERFIL dto)
        {
            DaoPerfil dao = new DaoPerfil();

            return(dao.Update(dto));
        }
    public static object DesactivarActivar(

        String ID, bool Activar, int Padre, int Perfil
        )
    {
        try
        {
            DaoOperaciones operacionesDao = new DaoOperaciones();

            if (!Activar)
            {
                #region desactivar perfil de la operacion
                var resultado = operacionesDao.DeleteOperacionesPerfil(ID, Padre);


                if (resultado)
                {
                    return(new
                    {
                        Ok = "OK",
                        mensaje = "Se han desasociado los perifiles para este menu, Correctamente"
                    });
                }
                else
                {
                    return(new
                    {
                        Ok = "error",
                        mensaje = "No se ha podido actualizar el regitro"
                    });
                }
                #endregion
            }
            else
            {
                DaoPerfil p      = new DaoPerfil();
                int       i      = 0;
                var       perfil = p.GetPerfiles(1, 999999, ref i);

                var idPerfil = perfil.Where(x => x.PREFIJO == ID).First().ID_PERFIL;

                //validar que el perfil no exista en la base de datos ya
                var existe = operacionesDao.consultaExisteEnbaseDatos(idPerfil, Padre);
                if (existe)
                {
                    return(new
                    {
                        Ok = "ER",
                        mensaje = "El perfil ya existe asociado a este menu."
                    });
                }
                else
                {
                    var resultadoinsertar = operacionesDao.InsertarOperacionesPerfil(ID, Padre);
                    if (resultadoinsertar)
                    {
                        return(new
                        {
                            Ok = "OK",
                            mensaje = "Se han Asociados los perifiles para este menu, Correctamente"
                        });
                    }
                    else
                    {
                        return(new
                        {
                            Ok = "error",
                            mensaje = "No se ha podido actualizar el regitro"
                        });
                    }
                }
            }
        }
        catch (Exception ex)
        {
            return(new
            {
                Ok = "Error",
                mensaje = "ha Ocurrido un error inesperado" + ex.ToString()
            });
        }
    }