Esempio n. 1
0
        /// <summary>
        /// Eliminar privilegios de rol.
        /// </summary>
        /// <param name="ROL_ID"></param>
        /// <param name="lprivilegios"></param>
        /// <param name="MODIFICADO_POR"></param>
        public void EliminarPrivilegios(int ROL_ID, List <int> lprivilegios, string MODIFICADO_POR)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.roles", "ROL_ID", ROL_ID);

                    var r = db.GetObjectByKey(k);

                    rol role = (rol)r;

                    foreach (int priv_id in lprivilegios)
                    {
                        var p = db.GetObjectByKey(new EntityKey("colinasEntities.privilegios", "PRIV_ID", priv_id));

                        privilegio privilegioEntity = (privilegio)p;
                        role.privilegios.Remove(privilegioEntity);
                    }

                    role.MODIFICADO_POR     = MODIFICADO_POR;
                    role.FECHA_MODIFICACION = DateTime.Today;

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al eliminar privilegios.", ex);
                throw;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Eliminar roles de usuario.
        /// </summary>
        /// <param name="USR_USERNAME"></param>
        /// <param name="roles"></param>
        /// <param name="MODIFICADO_POR"></param>
        public void EliminarRoles(string USR_USERNAME, List <int> roles, string MODIFICADO_POR)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.usuarios", "USR_USERNAME", USR_USERNAME);

                    var u = db.GetObjectByKey(k);

                    usuario user = (usuario)u;

                    foreach (int rol_id in roles)
                    {
                        var r = db.GetObjectByKey(new EntityKey("colinasEntities.roles", "ROL_ID", rol_id));

                        rol rolEntity = (rol)r;
                        user.roles.Remove(rolEntity);
                    }

                    user.MODIFICADO_POR     = MODIFICADO_POR;
                    user.FECHA_MODIFICACION = DateTime.Today;

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al eliminar roles.", ex);
                throw;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Envia correo de rol nuevo
        /// </summary>
        /// <param name="USR_USERNAME"></param>
        /// <param name="ROL_ID"></param>
        /// <param name="Configuracion"></param>
        public static void EnviarCorreoRolNuevo(string USR_USERNAME, int ROL_ID, XmlDocument Configuracion)
        {
            try
            {
                UsuarioLogic usuariologica = new UsuarioLogic();
                usuario      user          = usuariologica.GetUsuario(USR_USERNAME);

                string mailto = user.USR_CORREO;
                string nombre = user.USR_NOMBRE + " " + user.USR_APELLIDO;

                string rol   = "";
                string privs = "";

                string subject = "";
                string message = "";

                using (var db = new colinasEntities())
                {
                    EntityKey k    = new EntityKey("colinasEntities.roles", "ROL_ID", ROL_ID);
                    var       r    = db.GetObjectByKey(k);
                    rol       role = (rol)r;

                    rol = role.ROL_NOMBRE + " - " + role.ROL_DESCRIPCION;

                    foreach (privilegio p in role.privilegios)
                    {
                        privs += p.PRIV_NOMBRE + ", ";
                    }

                    if (privs.Length > 2)
                    {
                        privs.Remove(privs.Length - 2);
                    }


                    EntityKey k2 = new EntityKey("colinasEntities.plantillas_notificaciones", "PLANTILLAS_LLAVE", "ROLNUEVO");
                    var       pl = db.GetObjectByKey(k2);
                    plantilla_notificacion plantilla = (plantilla_notificacion)pl;

                    subject = plantilla.PLANTILLAS_ASUNTO;
                    message = plantilla.PLANTILLAS_MENSAJE;
                }

                message = message.Replace("{NOMBRE}", nombre);
                message = message.Replace("{USUARIO}", USR_USERNAME);
                message = message.Replace("{ROL}", rol);
                message = message.Replace("{PRIVILEGIOS}", privs);

                EnviarCorreo(mailto, subject, message, Configuracion);
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al enviar correo de rol nuevo.", ex);
                throw;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Actualiza la plantilla de notificación.
        /// </summary>
        /// <param name="PLANTILLAS_LLAVE"></param>
        /// <param name="PLANTILLAS_NOMBRE"></param>
        /// <param name="PLANTILLAS_ASUNTO"></param>
        /// <param name="PLANTILLAS_MENSAJE"></param>
        /// <param name="CREADO_POR"></param>
        /// <param name="FECHA_CREACION"></param>
        /// <param name="MODIFICADO_POR"></param>
        /// <param name="FECHA_MODIFICACION"></param>
        public void ActualizarPlantilla
            (string PLANTILLAS_LLAVE,
            string PLANTILLAS_NOMBRE,
            string PLANTILLAS_ASUNTO,
            string PLANTILLAS_MENSAJE,
            string CREADO_POR,
            DateTime FECHA_CREACION,
            string MODIFICADO_POR,
            DateTime FECHA_MODIFICACION)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k  = new EntityKey("colinasEntities.plantillas_notificaciones", "PLANTILLAS_LLAVE", PLANTILLAS_LLAVE);
                    var       pl = db.GetObjectByKey(k);
                    plantilla_notificacion plantilla = (plantilla_notificacion)pl;

                    plantilla.PLANTILLAS_NOMBRE  = PLANTILLAS_NOMBRE;
                    plantilla.PLANTILLAS_ASUNTO  = PLANTILLAS_ASUNTO;
                    plantilla.PLANTILLAS_MENSAJE = PLANTILLAS_MENSAJE;
                    plantilla.MODIFICADO_POR     = MODIFICADO_POR;
                    plantilla.FECHA_MODIFICACION = DateTime.Today;

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al actualizar plantilla.", ex);
                throw;
            }
        }
        /// <summary>
        /// Actualiza la clasificación de café.
        /// </summary>
        /// <param name="CLASIFICACIONES_CAFE_ID"></param>
        /// <param name="CLASIFICACIONES_CAFE_NOMBRE"></param>
        /// <param name="CLASIFICACIONES_CAFE_DESCRIPCION"></param>
        /// <param name="CLASIFICACIONES_CAFE_CATACION"></param>
        /// <param name="CREADO_POR"></param>
        /// <param name="FECHA_CREACION"></param>
        /// <param name="MODIFICADO_POR"></param>
        /// <param name="FECHA_MODIFICACION"></param>
        public void ActualizarClasificacionDeCafe
            (int CLASIFICACIONES_CAFE_ID,
            string CLASIFICACIONES_CAFE_NOMBRE,
            string CLASIFICACIONES_CAFE_DESCRIPCION,
            bool CLASIFICACIONES_CAFE_CATACION,
            string CREADO_POR,
            DateTime FECHA_CREACION,
            string MODIFICADO_POR,
            DateTime FECHA_MODIFICACION)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.clasificaciones_cafe", "CLASIFICACIONES_CAFE_ID", CLASIFICACIONES_CAFE_ID);

                    var tp = db.GetObjectByKey(k);

                    clasificacion_cafe coffeeClassif = (clasificacion_cafe)tp;

                    coffeeClassif.CLASIFICACIONES_CAFE_NOMBRE      = CLASIFICACIONES_CAFE_NOMBRE;
                    coffeeClassif.CLASIFICACIONES_CAFE_DESCRIPCION = CLASIFICACIONES_CAFE_DESCRIPCION;
                    coffeeClassif.CLASIFICACIONES_CAFE_CATACION    = CLASIFICACIONES_CAFE_CATACION;
                    coffeeClassif.MODIFICADO_POR     = MODIFICADO_POR;
                    coffeeClassif.FECHA_MODIFICACION = DateTime.Today;

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al actualizar clasificacion de cafe.", ex);
                throw;
            }
        }
Esempio n. 6
0
        public List <privilegio> GetPrivilegiosParaNotaDePesoDeUsuario(string USR_USERNAME)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    db.privilegios.MergeOption = MergeOption.NoTracking;

                    EntityKey k = new EntityKey("colinasEntities.usuarios", "USR_USERNAME", USR_USERNAME);

                    var u = db.GetObjectByKey(k);

                    usuario user = (usuario)u;

                    var query = from r in user.roles
                                from pr in r.privilegios
                                where pr.PRIV_LLAVE.Contains(COCASJOL.LOGIC.Inventario.Ingresos.EstadoNotaDePesoLogic.PREFIJO_PRIVILEGIO)
                                select pr;

                    return(query.ToList <privilegio>());
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al obtener privilegios de usuario.", ex);
                throw;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Verifica si el estado de nota de peso esta siendo utilizado en notas de peso. Si hay notas de peso en el estado especificado.
        /// </summary>
        /// <param name="ESTADOS_NOTA_ID"></param>
        /// <returns>True si hay notas de peso en estado. False si no hay notas de peso en estado.</returns>
        public bool EstadoDeNotaDePesoTieneReferencias(int ESTADOS_NOTA_ID)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.estados_nota_de_peso", "ESTADOS_NOTA_ID", ESTADOS_NOTA_ID);

                    var esn = db.GetObjectByKey(k);

                    estado_nota_de_peso noteStatus = (estado_nota_de_peso)esn;

                    if (noteStatus.notas_de_peso.Count > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al intentar verificar estado de nota de peso.", ex);
                throw;
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Envia correo a usuario de password nuevo
        /// </summary>
        /// <param name="USR_USERNAME"></param>
        /// <param name="USR_PASSWORD"></param>
        /// <param name="Configuracion"></param>
        public static void EnviarCorreoUsuarioPasswordNuevo(string USR_USERNAME, string USR_PASSWORD, XmlDocument Configuracion)
        {
            try
            {
                UsuarioLogic usuariologica = new UsuarioLogic();
                usuario      user          = usuariologica.GetUsuario(USR_USERNAME);

                string mailto = user.USR_CORREO;
                string nombre = user.USR_NOMBRE + " " + user.USR_APELLIDO;

                string subject = "";
                string message = "";

                using (var db = new colinasEntities())
                {
                    EntityKey k  = new EntityKey("colinasEntities.plantillas_notificaciones", "PLANTILLAS_LLAVE", "PASSWORDNUEVO");
                    var       pl = db.GetObjectByKey(k);
                    plantilla_notificacion plantilla = (plantilla_notificacion)pl;

                    subject = plantilla.PLANTILLAS_ASUNTO;
                    message = plantilla.PLANTILLAS_MENSAJE;
                }

                message = message.Replace("{NOMBRE}", nombre);
                message = message.Replace("{USUARIO}", USR_USERNAME);
                message = message.Replace("{CONTRASEÑA}", USR_PASSWORD);

                EnviarCorreo(mailto, subject, message, Configuracion);
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al enviar correo de password nuevo.", ex);
                throw;
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Elimina todas las notificaciones del usuario.
        /// </summary>
        /// <param name="USR_USERNAME"></param>
        public void EliminarNotificacionesDeUsuario(string USR_USERNAME)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.usuarios", "USR_USERNAME", USR_USERNAME);

                    var u = db.GetObjectByKey(k);

                    usuario user = (usuario)u;

                    var query = from n in user.notificaciones
                                where n.NOTIFICACION_ESTADO == (int)EstadosNotificacion.Leido
                                select n;

                    foreach (notificacion notif in query.ToList <notificacion>())
                    {
                        db.notificaciones.DeleteObject(notif);
                    }

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al eliminar todas las notificaciones de usuario.", ex);
                throw;
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Obtiene los roles de usuario.
        /// </summary>
        /// <param name="USR_USERNAME"></param>
        /// <param name="ROL_ID"></param>
        /// <param name="ROL_NOMBRE"></param>
        /// <returns>Roles de usuario.</returns>
        public List <rol> GetRoles(string USR_USERNAME, int ROL_ID, string ROL_NOMBRE)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    db.roles.MergeOption = MergeOption.NoTracking;//optimizacion

                    EntityKey k = new EntityKey("colinasEntities.usuarios", "USR_USERNAME", USR_USERNAME);

                    var u = db.GetObjectByKey(k);

                    usuario user = (usuario)u;

                    var query = from r in user.roles
                                select r;

                    var filter = from rls in query
                                 where
                                 (ROL_ID.Equals(0) ? true : rls.ROL_ID.Equals(ROL_ID)) &&
                                 (string.IsNullOrEmpty(ROL_NOMBRE) ? true : rls.ROL_NOMBRE.Contains(ROL_NOMBRE))
                                 select rls;

                    return(filter.OrderBy(r => r.ROL_NOMBRE).ToList <rol>());
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al obtener roles de usuario.", ex);
                throw;
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Actualiza el rol.
        /// </summary>
        /// <param name="ROL_ID"></param>
        /// <param name="ROL_NOMBRE"></param>
        /// <param name="ROL_DESCRIPCION"></param>
        /// <param name="CREADO_POR"></param>
        /// <param name="FECHA_CREACION"></param>
        /// <param name="MODIFICADO_POR"></param>
        /// <param name="FECHA_MODIFICACION"></param>
        public void ActualizarRol
            (int ROL_ID,
            string ROL_NOMBRE,
            string ROL_DESCRIPCION,
            string CREADO_POR,
            DateTime FECHA_CREACION,
            string MODIFICADO_POR,
            DateTime FECHA_MODIFICACION)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.roles", "ROL_ID", ROL_ID);

                    var r = db.GetObjectByKey(k);

                    rol role = (rol)r;

                    role.ROL_NOMBRE         = ROL_NOMBRE;
                    role.ROL_DESCRIPCION    = ROL_DESCRIPCION;
                    role.CREADO_POR         = CREADO_POR;
                    role.FECHA_CREACION     = FECHA_CREACION;
                    role.MODIFICADO_POR     = MODIFICADO_POR;
                    role.FECHA_MODIFICACION = DateTime.Today;

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al actualizar rol.", ex);
                throw;
            }
        }
Esempio n. 12
0
        public bool NotaDePesoRegistrada(int NOTAS_ID)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.notas_de_peso", "NOTAS_ID", NOTAS_ID);

                    var n = db.GetObjectByKey(k);

                    nota_de_peso note = (nota_de_peso)n;

                    if (note.TRANSACCION_NUMERO != null)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al eliminar nota de peso.", ex);
                throw;
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Obtiene los privilegios de usuario.
        /// </summary>
        /// <param name="USR_USERNAME"></param>
        /// <returns>Lista de privilegios de usuario.</returns>
        public List <privilegio> GetPrivilegiosDeUsuario(string USR_USERNAME)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    db.privilegios.MergeOption = MergeOption.NoTracking;

                    EntityKey k = new EntityKey("colinasEntities.usuarios", "USR_USERNAME", USR_USERNAME);

                    var u = db.GetObjectByKey(k);

                    usuario user = (usuario)u;

                    var query = from r in user.roles
                                from pr in r.privilegios
                                select pr;

                    return(query.ToList <privilegio>());
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al obtener privilegios de usuario.", ex);
                throw;
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Actualiza la clave de usuario.
        /// </summary>
        /// <param name="USR_USERNAME"></param>
        /// <param name="USR_PASSWORD"></param>
        /// <param name="MODIFICADO_POR"></param>
        public void ActualizarClave(string USR_USERNAME, string USR_PASSWORD, string MODIFICADO_POR)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.usuarios", "USR_USERNAME", USR_USERNAME);

                    var u = db.GetObjectByKey(k);

                    usuario user = (usuario)u;

                    user.USR_PASSWORD       = USR_PASSWORD;
                    user.MODIFICADO_POR     = MODIFICADO_POR;
                    user.FECHA_MODIFICACION = DateTime.Today;

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al actualizar clave.", ex);
                throw;
            }
        }
Esempio n. 15
0
        /// <summary>
        /// Obtiene privilegios de rol.
        /// </summary>
        /// <param name="ROL_ID"></param>
        /// <param name="PRIV_ID"></param>
        /// <param name="PRIV_NOMBRE"></param>
        /// <param name="PRIV_LLAVE"></param>
        /// <returns>Lista de privilegios de rol.</returns>
        public List <privilegio> GetPrivilegios(int ROL_ID, int PRIV_ID, string PRIV_NOMBRE, string PRIV_LLAVE)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.roles", "ROL_ID", ROL_ID);

                    var r = db.GetObjectByKey(k);

                    rol role = (rol)r;

                    var filter = from privs in role.privilegios
                                 where
                                 (PRIV_ID.Equals(0) ? true : privs.PRIV_ID.Equals(PRIV_ID)) &&
                                 (string.IsNullOrEmpty(PRIV_NOMBRE) ? true : privs.PRIV_NOMBRE.Contains(PRIV_NOMBRE)) &&
                                 (string.IsNullOrEmpty(PRIV_LLAVE) ? true : privs.PRIV_LLAVE.Contains(PRIV_LLAVE))
                                 select privs;

                    return(filter.OrderBy(p => p.PRIV_LLAVE).ToList <privilegio>());
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al obtener privilegios.", ex);
                throw;
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Desactiva el estado de nota de peso.
        /// </summary>
        /// <param name="ESTADOS_NOTA_ID"></param>
        /// <param name="MODIFICADO_POR"></param>
        public void DesactivarEstado(int ESTADOS_NOTA_ID, string MODIFICADO_POR)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.estados_nota_de_peso", "ESTADOS_NOTA_ID", ESTADOS_NOTA_ID);

                    var esn = db.GetObjectByKey(k);

                    estado_nota_de_peso noteStatus = (estado_nota_de_peso)esn;

                    noteStatus.ESTADOS_NOTA_ESTADO = false;
                    noteStatus.MODIFICADO_POR      = MODIFICADO_POR;
                    noteStatus.FECHA_MODIFICACION  = DateTime.Today;

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al desactivar estado de nota de peso.", ex);
                throw;
            }
        }
Esempio n. 17
0
        /// <summary>
        /// Elimina estados de nota de peso con su detalle. Elimina el privilegio y notificacion si existen.
        /// </summary>
        /// <param name="ESTADOS_NOTA_ID"></param>
        public void EliminarEstadoNotaDePeso(int ESTADOS_NOTA_ID)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    using (var scope1 = new System.Transactions.TransactionScope())
                    {
                        EntityKey k = new EntityKey("colinasEntities.estados_nota_de_peso", "ESTADOS_NOTA_ID", ESTADOS_NOTA_ID);

                        var esn = db.GetObjectByKey(k);

                        estado_nota_de_peso noteStatus = (estado_nota_de_peso)esn;

                        db.DeleteObject(noteStatus);

                        /*--------------------Eliminar privilegio--------------------*/
                        string PRIV_LLAVE = EstadoNotaDePesoLogic.PREFIJO_PRIVILEGIO + noteStatus.ESTADOS_NOTA_LLAVE;

                        var queryPrivilegio = from p in db.privilegios
                                              where p.PRIV_LLAVE == PRIV_LLAVE
                                              select p;

                        privilegio priv = (privilegio)queryPrivilegio.FirstOrDefault();

                        if (priv != null)
                        {
                            db.DeleteObject(priv);
                        }


                        /*--------------------Eliminar plantilla de notificacion--------------------*/
                        string PLANTILLAS_LLAVE = EstadoNotaDePesoLogic.PREFIJO_PLANTILLA + noteStatus.ESTADOS_NOTA_LLAVE;

                        db.plantillas_notificaciones.MergeOption = MergeOption.NoTracking;

                        Object    pl  = null;
                        EntityKey kpl = new EntityKey("colinasEntities.plantillas_notificaciones", "PLANTILLAS_LLAVE", PLANTILLAS_LLAVE);

                        if (db.TryGetObjectByKey(kpl, out pl))
                        {
                            plantilla_notificacion plNotif = (plantilla_notificacion)pl;

                            db.DeleteObject(plNotif);
                        }

                        db.SaveChanges();

                        scope1.Complete();
                    }
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al eliminar estado de nota de peso.", ex);
                throw;
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Actualiza todas las variables de entorno.
        /// </summary>
        /// <param name="VariablesDeEntorno"></param>
        /// <param name="MODIFICADO_POR"></param>
        public void ActualizarVariablesDeEntorno(Dictionary <string, string>[] VariablesDeEntorno, string MODIFICADO_POR)
        {
            try
            {
                List <string> variablesActualizadas = new List <string>();
                using (var db = new colinasEntities())
                {
                    DateTime tday = DateTime.Today;

                    foreach (Dictionary <string, string> VariableDeEntorno in VariablesDeEntorno)
                    {
                        EntityKey k = new EntityKey("colinasEntities.variables_de_entorno", "VARIABLES_LLAVE", VariableDeEntorno["VARIABLES_LLAVE"]);

                        var env = db.GetObjectByKey(k);

                        variable_de_entorno environmentVariables = (variable_de_entorno)env;

                        string valor = VariableDeEntorno["VARIABLES_VALOR"];

                        if (environmentVariables.VARIABLES_VALOR != valor)
                        {
                            environmentVariables.VARIABLES_VALOR    = valor;
                            environmentVariables.MODIFICADO_POR     = MODIFICADO_POR;
                            environmentVariables.FECHA_MODIFICACION = tday;

                            variablesActualizadas.Add(environmentVariables.VARIABLES_LLAVE);
                        }
                    }

                    db.SaveChanges();
                }

                Utiles.PlantillaLogic    plantillalogic    = new Utiles.PlantillaLogic();
                plantilla_notificacion   pl                = plantillalogic.GetPlantilla("VARIABLESACTUALIZADAS");
                Utiles.NotificacionLogic notificacionlogic = new Utiles.NotificacionLogic();

                foreach (string varKey in variablesActualizadas)
                {
                    notificacionlogic.NotifyUsers("", Utiles.EstadosNotificacion.Creado, pl.PLANTILLAS_ASUNTO, pl.PLANTILLAS_MENSAJE, varKey);
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al actualizar variables de entorno.", ex);
                throw;
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Actualiza el usuario.
        /// </summary>
        /// <param name="USR_USERNAME"></param>
        /// <param name="USR_NOMBRE"></param>
        /// <param name="USR_SEGUNDO_NOMBRE"></param>
        /// <param name="USR_APELLIDO"></param>
        /// <param name="USR_SEGUNDO_APELLIDO"></param>
        /// <param name="USR_CEDULA"></param>
        /// <param name="USR_CORREO"></param>
        /// <param name="USR_PUESTO"></param>
        /// <param name="USR_PASSWORD"></param>
        /// <param name="CREADO_POR"></param>
        /// <param name="FECHA_CREACION"></param>
        /// <param name="MODIFICADO_POR"></param>
        /// <param name="FECHA_MODIFICACION"></param>
        public void ActualizarUsuario
            (string USR_USERNAME,
            string USR_NOMBRE,
            string USR_SEGUNDO_NOMBRE,
            string USR_APELLIDO,
            string USR_SEGUNDO_APELLIDO,
            string USR_CEDULA,
            string USR_CORREO,
            string USR_PUESTO,
            string USR_PASSWORD,
            string CREADO_POR,
            DateTime FECHA_CREACION,
            string MODIFICADO_POR,
            DateTime FECHA_MODIFICACION)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.usuarios", "USR_USERNAME", USR_USERNAME);

                    var u = db.GetObjectByKey(k);

                    usuario user = (usuario)u;

                    user.USR_NOMBRE           = USR_NOMBRE;
                    user.USR_SEGUNDO_NOMBRE   = USR_SEGUNDO_NOMBRE;
                    user.USR_APELLIDO         = USR_APELLIDO;
                    user.USR_SEGUNDO_APELLIDO = USR_SEGUNDO_APELLIDO;
                    user.USR_CEDULA           = USR_CEDULA;
                    user.USR_CORREO           = USR_CORREO;
                    user.USR_PUESTO           = USR_PUESTO;
                    user.USR_PASSWORD         = USR_PASSWORD;
                    user.MODIFICADO_POR       = MODIFICADO_POR;
                    user.FECHA_MODIFICACION   = DateTime.Today;

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al actualizar usuario (completo).", ex);
                throw;
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Obtiene plantilla de notificación espcífica.
        /// </summary>
        /// <param name="PLANTILLAS_LLAVE"></param>
        /// <returns>Plantilla de notificación.</returns>
        public plantilla_notificacion GetPlantilla(string PLANTILLAS_LLAVE)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k  = new EntityKey("colinasEntities.plantillas_notificaciones", "PLANTILLAS_LLAVE", PLANTILLAS_LLAVE);
                    var       pl = db.GetObjectByKey(k);
                    plantilla_notificacion plantilla = (plantilla_notificacion)pl;

                    return(plantilla);
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al obtener plantilla.", ex);
                throw;
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Obtiene todas las notificaciones de usuario.
        /// </summary>
        /// <param name="USR_USERNAME"></param>
        /// <returns>Lista de notificaciones.</returns>
        public List <notificacion> GetNotificacionesDeUsuario(string USR_USERNAME)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.usuarios", "USR_USERNAME", USR_USERNAME);

                    var u = db.GetObjectByKey(k);

                    usuario user = (usuario)u;

                    return(user.notificaciones.OrderByDescending(nt => nt.NOTIFICACION_FECHA).ToList <notificacion>());
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al obtener notificaciones de usuario.", ex);
                throw;
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Obtiene los detalles de nota de peso específica.
        /// </summary>
        /// <param name="NOTAS_ID"></param>
        /// <returns>Lista de detalles de nota de peso específica.</returns>
        public List <nota_detalle> GetDetalleNotaDePeso(int NOTAS_ID)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.notas_de_peso", "NOTAS_ID", NOTAS_ID);

                    var n = db.GetObjectByKey(k);

                    nota_de_peso note = (nota_de_peso)n;

                    return(note.notas_detalles.OrderByDescending(nd => nd.DETALLES_PESO).ToList <nota_detalle>());
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al obtener detalles de notas de peso.", ex);
                throw;
            }
        }
Esempio n. 23
0
        /// <summary>
        /// Obtiene el rol específico.
        /// </summary>
        /// <param name="ROL_ID"></param>
        /// <returns>Rol.</returns>
        public rol GetRol(int ROL_ID)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.roles", "ROL_ID", ROL_ID);

                    var r = db.GetObjectByKey(k);

                    rol role = (rol)r;

                    return(role);
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al obtener rol.", ex);
                throw;
            }
        }
Esempio n. 24
0
        /// <summary>
        /// Devuelve si la clasificación de café especificada debe pasar por catación
        /// </summary>
        /// <param name="CLASIFICACIONES_CAFE_ID"></param>
        /// <returns>Verdaro si debe pasar a catación o falso si no es necesario.</returns>
        public bool ClasificacionDeCafePasaPorCatacion(int CLASIFICACIONES_CAFE_ID)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.clasificaciones_cafe", "CLASIFICACIONES_CAFE_ID", CLASIFICACIONES_CAFE_ID);

                    var tp = db.GetObjectByKey(k);

                    clasificacion_cafe coffeeClassif = (clasificacion_cafe)tp;

                    return(coffeeClassif.CLASIFICACIONES_CAFE_CATACION);
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al comprobar si clasificacion de cafe debe pasar por catacion.", ex);
                throw;
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Registra la nota de peso.
        /// </summary>
        /// <param name="NOTAS_ID"></param>
        /// <param name="ESTADO_ID"></param>
        /// <param name="MODIFICADO_POR"></param>
        public int RegistrarNotaDePeso(int NOTAS_ID, int ESTADO_ID, string MODIFICADO_POR)
        {
            try
            {
                int transactionNum = -1;
                using (var db = new colinasEntities())
                {
                    using (var scope1 = new TransactionScope())
                    {
                        EntityKey    k    = new EntityKey("colinasEntities.notas_de_peso", "NOTAS_ID", NOTAS_ID);
                        var          n    = db.GetObjectByKey(k);
                        nota_de_peso note = (nota_de_peso)n;

                        note.ESTADOS_NOTA_ID    = ESTADO_ID;
                        note.MODIFICADO_POR     = MODIFICADO_POR;
                        note.FECHA_MODIFICACION = DateTime.Today;

                        db.SaveChanges();

                        if (note.estados_nota_de_peso.estados_detalles.ESTADOS_DETALLE_ENABLE_REGISTRAR_BTN == true)
                        {
                            InventarioDeCafeLogic inventariodecafelogic = new InventarioDeCafeLogic();
                            note.TRANSACCION_NUMERO = inventariodecafelogic.InsertarTransaccionInventarioDeCafeDeSocio(note, db);
                            db.SaveChanges();
                            transactionNum = note.TRANSACCION_NUMERO == null ? transactionNum : Convert.ToInt32(note.TRANSACCION_NUMERO);
                        }

                        scope1.Complete();
                    }
                }

                return(transactionNum);
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al registrar nota de peso.", ex);
                throw;
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Eliminar el usuario.
        /// </summary>
        /// <param name="USR_USERNAME"></param>
        public void EliminarUsuario(string USR_USERNAME)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.usuarios", "USR_USERNAME", USR_USERNAME);

                    var u = db.GetObjectByKey(k);

                    usuario user = (usuario)u;

                    db.DeleteObject(user);

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al eliminar usuario.", ex);
                throw;
            }
        }
Esempio n. 27
0
        /// <summary>
        /// Elimina la nota de peso.
        /// </summary>
        /// <param name="NOTAS_ID"></param>
        public void EliminarNotaDePeso(int NOTAS_ID)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.notas_de_peso", "NOTAS_ID", NOTAS_ID);

                    var n = db.GetObjectByKey(k);

                    nota_de_peso note = (nota_de_peso)n;

                    db.DeleteObject(note);

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al eliminar nota de peso.", ex);
                throw;
            }
        }
Esempio n. 28
0
        /// <summary>
        /// Elimina la clasificación de café.
        /// </summary>
        /// <param name="CLASIFICACIONES_CAFE_ID"></param>
        public void EliminarClasificacionDeCafe(int CLASIFICACIONES_CAFE_ID)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.clasificaciones_cafe", "CLASIFICACIONES_CAFE_ID", CLASIFICACIONES_CAFE_ID);

                    var tp = db.GetObjectByKey(k);

                    clasificacion_cafe coffeeClassif = (clasificacion_cafe)tp;

                    db.DeleteObject(coffeeClassif);

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al eliminar clasificacion de cafe.", ex);
                throw;
            }
        }
Esempio n. 29
0
        /// <summary>
        /// Eliminar el rol.
        /// </summary>
        /// <param name="ROL_ID"></param>
        public void EliminarRol(int ROL_ID)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.roles", "ROL_ID", ROL_ID);

                    var r = db.GetObjectByKey(k);

                    rol role = (rol)r;

                    db.DeleteObject(role);

                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al eliminar rol.", ex);
                throw;
            }
        }
Esempio n. 30
0
        /// <summary>
        /// Obtiene el usuario específico.
        /// </summary>
        /// <param name="USR_USERNAME"></param>
        /// <returns>Usuario.</returns>
        public usuario GetUsuario(string USR_USERNAME)
        {
            try
            {
                using (var db = new colinasEntities())
                {
                    db.usuarios.MergeOption = MergeOption.NoTracking;

                    EntityKey k = new EntityKey("colinasEntities.usuarios", "USR_USERNAME", USR_USERNAME);

                    var u = db.GetObjectByKey(k);

                    usuario user = (usuario)u;

                    return(user);
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al obtener usuario.", ex);
                throw;
            }
        }