Beispiel #1
0
        public bool registrarLog(Guid UniqueIdentifierUser, String Pagina)
        {
            int idOperacion = 0;
            using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
            {
                var paginas = (from d in ctx.OPERACION

                               where d.URL.Contains(Pagina)
                               select d).Distinct();
                if (paginas.Any())
                {
                    idOperacion = paginas.First().ID_OPERACION;

                }

                Activity act = new Activity();

                act.ActivityDay = DateTime.Now;
                act.Id_Operacion = idOperacion;
                act.UserId = UniqueIdentifierUser;
                ctx.Activity.InsertOnSubmit(act);
                ctx.SubmitChanges();

            }

            return true;
        }
Beispiel #2
0
        public bool AsociarPerfilMenu(int IdPerfil, int idMenu)
        {
            List<PERFIL_OPERACION> insertar = new List<PERFIL_OPERACION>();

            using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
            {
                var menu = (from d in ctx.OPERACION

                            where d.ID_OPERACION_PADRE == idMenu || d.ID_OPERACION == idMenu
                            select d).Distinct();

                if (menu.Any())
                {
                    foreach (var data in menu)
                    {
                        insertar.Add(new PERFIL_OPERACION()
                        {
                            ID_PERFIL = IdPerfil,
                            ID_OPERACION = data.ID_OPERACION,

                        });
                    }
                    ctx.PERFIL_OPERACION.InsertAllOnSubmit(insertar);
                    ctx.SubmitChanges();

                }
            }
            return true;
        }
Beispiel #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="idMenu"></param>
        /// <returns></returns>
        public List<PERFIL> consultaPerfilesAsociadosAMenu(int idMenu)
        {
            List<PERFIL> retorno = new List<PERFIL>();

            using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
            {
                var operacionMenu = (from operacin in ctx.OPERACION
                                     where operacin.ID_OPERACION_PADRE == null
                                     && operacin.ID_OPERACION == idMenu
                                     select operacin.ID_OPERACION);

                var idperfil = (from d in ctx.PERFIL_OPERACION

                                where d.ID_OPERACION == idMenu
                                select d.ID_PERFIL).Distinct().ToList();

                var PERFILES = (from perfil in ctx.PERFIL
                                where idperfil.Contains(perfil.ID_PERFIL)
                                select perfil);

                if (PERFILES.Any())
                {
                    foreach (var data in PERFILES)
                    {
                        retorno.Add(new PERFIL()
                        {
                            ID_PERFIL = data.ID_PERFIL,
                            NOMBRE_PERFIL = data.NOMBRE_PERFIL
                        });
                    }
                }
            }
            return retorno;
        }
        public bool ActualizarDescripcionesMenu(int IDMenu, String NombreMenu, String UrlMenu)
        {
            try
            {
                using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
                {
                    var oldentity = (from d in ctx.OPERACION
                                     where d.ID_OPERACION == IDMenu
                                     select d).FirstOrDefault();

                    if (oldentity != null)
                    {
                        oldentity.NOMBRE = NombreMenu;
                        oldentity.URL = UrlMenu;

                        ctx.Refresh(System.Data.Linq.RefreshMode.KeepCurrentValues, oldentity);
                        ctx.SubmitChanges();
                    }

                }
                return true;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public bool consultaExisteEnbaseDatos(int perfil, int idMenuOperacionPadre)
        {
            using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
            {
                var operfil = (from po in ctx.PERFIL_OPERACION
                               where po.ID_PERFIL == perfil && po.ID_OPERACION == idMenuOperacionPadre
                               select po);

                if (operfil.Any())
                    return true;
                else
                    return false;

            }
        }
Beispiel #6
0
        public bool ActualizarPerfil(string Nombre, String Descripcion, int idPerfil)
        {
            using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
            {
                var oldentity = (from d in ctx.PERFIL
                                 where d.ID_PERFIL == idPerfil
                                 select d);

                if (oldentity.Any())
                {
                    oldentity.First().NOMBRE_PERFIL = Nombre;
                    oldentity.First().DESCRIPCION = Descripcion;
                    ctx.Refresh(System.Data.Linq.RefreshMode.KeepCurrentValues, oldentity);
                    ctx.SubmitChanges();
                }

            }

            return true;
        }
        //Agrego el menu
        public bool AgregarMenuCabecera(String NombreMenu, String Url, Boolean EsPadre, int MenuPadre)
        {
            using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
            {
                OPERACION nueva = new OPERACION();
                nueva.VISIBLE_MENU = "S";
                nueva.URL = Url;
                if (!EsPadre)
                {
                    nueva.ID_OPERACION_PADRE = MenuPadre;
                }
                nueva.NOMBRE = NombreMenu;

                ctx.OPERACION.InsertOnSubmit(nueva);

                ctx.SubmitChanges();

                InsertarOperacionAlPerfil(MenuPadre, nueva.ID_OPERACION);
            }
            return true;
        }
        public List<PreguntasSecreta> ObtenerPreguntas()
        {
            try
            {
                List<PreguntasSecreta> listaRetorno = new List<PreguntasSecreta>();
                using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
                {
                    var DATOS = (from c in ctx.PreguntasSecreta
                                 select c);
                    if (DATOS.Any())
                    {
                        listaRetorno = DATOS.ToList();
                    }
                }

                return listaRetorno;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <summary>
        /// sE CONSULTA EL MENU PARA AGREGAR O QUITAR FUNCIONALIDADES
        /// </summary>
        /// <param name="PageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="totalRows"></param>
        /// <returns></returns>
        public List<Operacion> ConsultarMenuCabecera(int PageIndex, int pageSize, ref int totalRows)
        {
            var Resultados = new List<Operacion>();
            int skip = ((PageIndex - 1) * pageSize);

            using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
            {
                var estados = (from d in ctx.OPERACION

                               where d.ID_OPERACION_PADRE == null
                               select d).Distinct();
                if (estados.Any())
                {
                    estados = estados.Skip(skip).Take(pageSize);

                    foreach (var operacion in estados)
                    {
                        Resultados.Add(MapeadorOperaciones.MapOperacionesToBizEntity(operacion));
                    }
                }
            }
            return Resultados;
        }
Beispiel #10
0
        public List<PERFIL> GetPerfiles(int PageIndex, int pageSize, ref int totalRecords)
        {
            var Resultados = new List<PERFIL>();
            int skip = ((PageIndex - 1) * pageSize);

            using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
            {
                var estados = (from d in ctx.PERFIL
                               select d).Distinct();
                if (estados.Any())
                {
                    estados = estados.Skip(skip).Take(pageSize);
                    Resultados = estados.ToList();

                }
            }
            return Resultados;
        }
Beispiel #11
0
        public bool DesasociarPerfilMenu(int IdPerfil, int IdMenu)
        {
            using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
            {
                var operacionesPerfilEliminar = (from d in ctx.PERFIL_OPERACION
                                                 where d.ID_PERFIL == IdPerfil
                                                 select d).ToList();

                if (operacionesPerfilEliminar.Any())
                {
                    ctx.PERFIL_OPERACION.DeleteAllOnSubmit(operacionesPerfilEliminar);
                }
                ctx.SubmitChanges();
            }

            return true;
        }
Beispiel #12
0
        public void InsertarOperacionAlPerfil(int idOperacionPadre, int idOperacionhija)
        {
            List<PERFIL_OPERACION> insertar = new List<PERFIL_OPERACION>();

            using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
            {

                var Perfiles = (from perfiles in ctx.PERFIL_OPERACION
                                where perfiles.ID_OPERACION == idOperacionPadre
                                select perfiles.ID_PERFIL).Distinct();

                if (Perfiles.Any())
                {
                    foreach (var datos in Perfiles.ToList())
                    {
                        insertar.Add(new PERFIL_OPERACION()
                        {
                            ID_PERFIL = datos.Value,
                            ID_OPERACION = idOperacionhija,
                        });
                    }
                }

                ctx.PERFIL_OPERACION.InsertAllOnSubmit(insertar);
                ctx.SubmitChanges();
            }
        }
Beispiel #13
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="Perfil"></param>
        /// <param name="idMenuOperacionPadre"></param>
        /// <returns></returns>
        public bool InsertarOperacionesPerfil(String Perfil, int idMenuOperacionPadre)
        {
            using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
            {
                List<PERFIL_OPERACION> insertar = new List<PERFIL_OPERACION>();
                // Consultar el menu
                var perfilP = (from perfil in ctx.PERFIL
                               where perfil.PREFIJO == Perfil
                               select perfil).First().ID_PERFIL;

                var hijos = (from d in ctx.OPERACION
                             where d.ID_OPERACION_PADRE == idMenuOperacionPadre
                             select d);

                if (hijos != null)
                {
                    foreach (var data in hijos)
                    {
                        insertar.Add(new PERFIL_OPERACION()
                        {
                            ID_PERFIL = perfilP,
                            ID_OPERACION = data.ID_OPERACION,

                        });
                    }
                }
                insertar.Add(new PERFIL_OPERACION()
                {
                    ID_PERFIL = perfilP,
                    ID_OPERACION = idMenuOperacionPadre,
                });
                ctx.PERFIL_OPERACION.InsertAllOnSubmit(insertar);
                ctx.SubmitChanges();

            }
            return true;
        }
Beispiel #14
0
        //Para desactivar cualquier menu o item de menu
        public bool DesactivarMenuCabeceraOHijo(Boolean Activar, int idMenu)
        {
            try
            {
                using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
                {
                    var oldentity = (from d in ctx.OPERACION
                                     where d.ID_OPERACION == idMenu
                                     select d).FirstOrDefault();

                    if (oldentity != null)
                    {
                        oldentity.VISIBLE_MENU = Activar == true ? "S" : "N";
                        ctx.Refresh(System.Data.Linq.RefreshMode.KeepCurrentValues, oldentity);
                        ctx.SubmitChanges();
                    }

                }
                return true;
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Beispiel #15
0
        public bool DeleteOperacionesPerfil(String Perfil, int idMenuOperacionPadre)
        {
            using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
            {
                List<PERFIL_OPERACION> insertar = new List<PERFIL_OPERACION>();
                // Consultar el menu
                int idPerfil = 0;
                var perfilesP = (from perfil in ctx.PERFIL
                                 where perfil.PREFIJO.Contains(Perfil)
                                 select perfil);//.First().ID_PERFIL;
                if (perfilesP.Any())
                {

                    idPerfil = perfilesP.First().ID_PERFIL;
                }

                var hijos = (from d in ctx.OPERACION
                             where d.ID_OPERACION_PADRE == idMenuOperacionPadre || d.ID_OPERACION == idMenuOperacionPadre
                             select d.ID_OPERACION).ToList();

                var operfil = (from po in ctx.PERFIL_OPERACION
                               join perfiles in ctx.PERFIL on po.ID_PERFIL equals perfiles.ID_PERFIL
                               join oper in ctx.OPERACION on po.ID_OPERACION equals oper.ID_OPERACION
                               where perfiles.ID_PERFIL == idPerfil
                     && hijos.Contains(oper.ID_OPERACION)

                               select po).ToList();

                ctx.PERFIL_OPERACION.DeleteAllOnSubmit(operfil);
                ctx.SubmitChanges();

            }
            return true;
        }
Beispiel #16
0
        /// <summary>
        /// PARA ARMAR EL MENU POR EL PERFIL ASOCIADO
        /// </summary>
        /// <param name="prefijoPerfil"></param>
        /// <returns></returns>
        public List<Operacion> ConsultarOperacionesMenuPorPrefijoPerfil(string prefijoPerfil)
        {
            try
            {
                var Resultados = new List<Operacion>();

                using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
                {
                    var estados = (from d in ctx.OPERACION
                                   join u in ctx.PERFIL_OPERACION on d.ID_OPERACION equals u.ID_OPERACION
                                   join per in ctx.PERFIL on u.ID_PERFIL equals per.ID_PERFIL
                                   where per.PREFIJO == prefijoPerfil && d.VISIBLE_MENU == "S"
                                   select d).Distinct();

                    if (estados.Any())
                    {
                        foreach (var operacion in estados)
                        {
                            Resultados.Add(MapeadorOperaciones.MapOperacionesToBizEntity(operacion));
                        }
                    }
                }

                return Resultados;
            }
            catch (Exception ex)
            {

                throw new Exception("Error tratando de Obtener listado de OperacionesPorPerfil.", ex);
            }
        }
Beispiel #17
0
        public bool InsertPerfil(string Nombre, String Descripcion, String Prefijo)
        {
            using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
            {
                PERFIL nueva = new PERFIL();
                nueva.NOMBRE_PERFIL = Nombre;
                nueva.DESCRIPCION = Descripcion;
                nueva.PREFIJO = Prefijo;

                ctx.PERFIL.InsertOnSubmit(nueva);
                ctx.SubmitChanges();
            }

            return true;
        }
Beispiel #18
0
        /// <summary>
        /// Verifica si el perfil del uisuario tiene acceso a la URL o pagina
        /// </summary>
        /// <param name="Perfil">perfil del usuario</param>
        /// <param name="Pagina">Nombre de la pagina a la cual esta ingresando</param>
        /// <returns>True si tiene acceso, false si no lo tiene</returns>
        public bool PerfilTieneAcceso(string Perfil, string Pagina)
        {
            using (AccesoDatosDataContext ctx = new AccesoDatosDataContext(ConfigurationManager.ConnectionStrings["UniandesConnectionString"].ConnectionString))
            {

                //var idPerfil = (from d in ctx.PERFIL
                //                where d.PREFIJO == Perfil
                //                select d.ID_PERFIL).First();

                //var idoperacion = (from d in ctx.OPERACION
                //                   where d.URL == Pagina
                //                   select d.ID_OPERACION).First();

                //var existe = (from d in ctx.PERFIL_OPERACION
                //              where d.ID_PERFIL == idPerfil
                //              && d.ID_OPERACION == idoperacion
                //              select d).ToList();
                var existe = (from d in ctx.PERFIL_OPERACION
                              where d.PERFIL.PREFIJO == Perfil
                              && SqlMethods.Like(d.OPERACION.URL, "%" + Pagina + "%")
                              select d).ToList();

                if (existe.Any())
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }