Esempio n. 1
0
        public List <Permiso> GetAllPermisosByIdUsuario(int idUsuario)
        {
            string         keyCache = KEY_PERIMISOS_BY_USUARIO_ID + idUsuario;
            List <Permiso> permisos = CacheLayer.Get <List <Permiso> >(keyCache);

            if (permisos == null)
            {
                permisos = SecurityDAL.GetAllPermisos(idUsuario);
                if (permisos != null)
                {
                    CacheLayer.Add(permisos, keyCache);
                }
            }

            return(permisos);
        }
Esempio n. 2
0
        public MercadoEntity GetMercadoById(byte idMercado)
        {
            string        keyCache = KEY_MERCADO_BY_ID + "#" + idMercado.ToString();
            MercadoEntity mercado  = CacheLayer.Get <MercadoEntity>(keyCache);

            if (mercado == null)
            {
                using (OrdenesContext mc = new OrdenesContext())
                {
                    mercado = (from p in mc.Mercado where p.IdMercado == idMercado select p).FirstOrDefault();
                }
                if (mercado != null)
                {
                    CacheLayer.Add <MercadoEntity>(mercado, keyCache);
                }
            }

            return(mercado);
        }
Esempio n. 3
0
        public List <TipoOrdenEntity> GetAllTipoOrden()
        {
            string keyCache = KEY_ALL_TIPOSORDEN;

            List <TipoOrdenEntity> TiposOrdenes = CacheLayer.Get <List <TipoOrdenEntity> >(keyCache);

            if (TiposOrdenes == null)
            {
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    TiposOrdenes = (from d in dbContext.TiposOrden select d).ToList <TipoOrdenEntity>();
                }
                if (TiposOrdenes != null)
                {
                    CacheLayer.Add <List <TipoOrdenEntity> >(TiposOrdenes, keyCache);
                }
            }
            return(TiposOrdenes);
        }
Esempio n. 4
0
        public PartyEntity GetPersonaByCBU(string CBU)
        {
            string      keyCache = KEY_PERSONA_BY_CBU + CBU;
            PartyEntity persona  = CacheLayer.Get <PartyEntity>(keyCache);

            if (persona == null)
            {
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    persona =
                        (from d in dbContext.Persona where d.CBU.Equals(CBU) select d).FirstOrDefault();
                }
                if (persona != null)
                {
                    CacheLayer.Add <PartyEntity>(persona, keyCache);
                }
            }
            return(persona);
        }
Esempio n. 5
0
        public PartyEntity GetPersonaByNroCliente(string nroCliente)
        {
            string      keyCache = KEY_PERSONA_BY_NROCLIENTE + nroCliente;
            PartyEntity persona  = CacheLayer.Get <PartyEntity>(keyCache);

            if (persona == null)
            {
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    persona =
                        (from d in dbContext.Persona where d.MarketCustomerNumber.Equals(nroCliente) select d).FirstOrDefault();
                }
                if (persona != null)
                {
                    CacheLayer.Add <PartyEntity>(persona, keyCache);
                }
            }
            return(persona);
        }
Esempio n. 6
0
        public PartyEntity GetPersonaById(int idPersona)
        {
            string      keyCache = KEY_PERSONA_BY_ID + idPersona;
            PartyEntity persona  = CacheLayer.Get <PartyEntity>(keyCache);

            if (persona == null)
            {
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    persona =
                        (from d in dbContext.Persona where d.IdParty == idPersona select d).FirstOrDefault();
                }
                if (persona != null)
                {
                    CacheLayer.Add(persona, keyCache);
                }
            }
            return(persona);
        }
Esempio n. 7
0
        public bool GetConfirmacionManual(int idProducto, int idPersona, byte source)
        {
            string keyCache = KEY_AUTOCONFIRMA + "#" + idProducto.ToString() + "#" + idPersona.ToString() + "#" + source.ToString();
            List <ConfirmacionManualEntity> ConfirmacionManual = CacheLayer.Get <List <ConfirmacionManualEntity> >(keyCache);

            if (ConfirmacionManual == null)
            {
                using (OrdenesContext mc = new OrdenesContext())
                {
                    ConfirmacionManual = (from p in mc.ConfirmacionManual where p.IdProducto == idProducto && p.IdParty == idPersona && p.IdSourceApplication == source select p).ToList();
                }
                if (ConfirmacionManual != null)
                {
                    CacheLayer.Add <List <ConfirmacionManualEntity> >(ConfirmacionManual, keyCache);
                }
            }

            return(ConfirmacionManual.Count > 0);
        }
Esempio n. 8
0
        public List <MonedaEntity> GetAllMonedas()
        {
            string keyCache = KEY_ALL_MONEDAS;

            List <MonedaEntity> monedas = CacheLayer.Get <List <MonedaEntity> >(keyCache);

            if (monedas == null)
            {
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    monedas = (from d in dbContext.Moneda select d).ToList <MonedaEntity>();
                }
                if (monedas != null)
                {
                    CacheLayer.Add <List <MonedaEntity> >(monedas, keyCache);
                }
            }
            return(monedas);
        }
Esempio n. 9
0
        public DTOPortfolio GetPortfolioDefaultByIdUsuario(int idUsuario)
        {
            string       keyCache     = KEY_PORTFOLIO_DEFAULT_USUARIO + "#" + idUsuario;
            DTOPortfolio dtoPortfolio = CacheLayer.Get <DTOPortfolio>(keyCache);

            if (dtoPortfolio == null)
            {
                using (OrdenesContext mc = new OrdenesContext())
                {
                    dtoPortfolio = (from p in mc.Portfolios
                                    join pu in mc.PortfoliosUsuario on p.IdPortfolio equals pu.IdPortfolio
                                    where pu.IdUsuario == idUsuario &&
                                    pu.PorDefecto
                                    select new DTOPortfolio()
                    {
                        IdPortfolio = p.IdPortfolio,
                        Nombre = p.Nombre,
                        Codigo = p.Codigo,
                        EsDeSistema = p.EsDeSistema
                    }).FirstOrDefault();
                    if (dtoPortfolio == null)
                    {
                        dtoPortfolio = (from p in mc.Portfolios
                                        join pu in mc.PortfoliosUsuario on p.IdPortfolio equals pu.IdPortfolio
                                        where pu.IdUsuario == idUsuario
                                        select new DTOPortfolio()
                        {
                            IdPortfolio = p.IdPortfolio,
                            Nombre = p.Nombre,
                            Codigo = p.Codigo,
                            EsDeSistema = p.EsDeSistema
                        }).FirstOrDefault();
                    }
                }
                if (dtoPortfolio != null)
                {
                    CacheLayer.Add(dtoPortfolio, keyCache);
                }
            }

            return(dtoPortfolio);
        }
Esempio n. 10
0
        public List <UsuarioEntity> GetAllUsuarios()
        {
            string keyCache = KEY_GETALLUSUARIOS;
            List <UsuarioEntity> usuarios = CacheLayer.Get <List <UsuarioEntity> >(keyCache);

            if (usuarios == null)
            {
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    usuarios =
                        (from d in dbContext.Usuario select d).ToList();
                }
                if (usuarios != null)
                {
                    CacheLayer.Add <List <UsuarioEntity> >(usuarios, keyCache);
                }
            }

            return(usuarios);
        }
Esempio n. 11
0
        public RolEntity GetRolByValorNumerico(int valornumerico)
        {
            string    keyCache = KEY_ROL + valornumerico;
            RolEntity Rol      = CacheLayer.Get <RolEntity>(keyCache);

            if (Rol == null)
            {
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    Rol =
                        (from d in dbContext.Rol where d.ValorNumerico == valornumerico select d).FirstOrDefault();
                }
                if (Rol != null)
                {
                    CacheLayer.Add <RolEntity>(Rol, keyCache);
                }
            }

            return(Rol);
        }
Esempio n. 12
0
        public List <RolUsuarioEntity> GetRolesUsuario(int idusuario)
        {
            string keyCache = KEY_ROLES_USUARIOS + idusuario;
            List <RolUsuarioEntity> Roles = CacheLayer.Get <List <RolUsuarioEntity> >(keyCache);

            if (Roles == null)
            {
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    Roles =
                        (from d in dbContext.RolUsuario where d.IdUsuario == idusuario select d).ToList();
                }
                if (Roles != null)
                {
                    CacheLayer.Add <List <RolUsuarioEntity> >(Roles, keyCache);
                }
            }

            return(Roles);
        }
Esempio n. 13
0
        public List <RolEntity> GetAllRoles()
        {
            string           keyCache = KEY_GETALLROLES;
            List <RolEntity> roles    = CacheLayer.Get <List <RolEntity> >(keyCache);

            if (roles == null)
            {
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    roles =
                        (from d in dbContext.Rol select d).ToList();
                }
                if (roles != null)
                {
                    CacheLayer.Add <List <RolEntity> >(roles, keyCache);
                }
            }

            return(roles);
        }
Esempio n. 14
0
        public ConfiguracionSeguridadEntity GetConfiguracionSeguridad()
        {
            string keyCache = KEY_CONFIG_SEGURIDAD;
            ConfiguracionSeguridadEntity config = CacheLayer.Get <ConfiguracionSeguridadEntity>(keyCache);

            if (config == null)
            {
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    config =
                        (from d in dbContext.ConfiguracionSeguridad select d).FirstOrDefault();
                }
                if (config != null)
                {
                    CacheLayer.Add <ConfiguracionSeguridadEntity>(config, keyCache);
                }
            }

            return(config);
        }
Esempio n. 15
0
        public List <AccionEntity> GetAllAcciones()
        {
            string keyCache = KEY_ALL_ACCIONES;
            List <AccionEntity> acciones = CacheLayer.Get <List <AccionEntity> >(keyCache);

            if (acciones == null)
            {
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    acciones =
                        (from d in dbContext.Acciones select d).ToList();
                }
                if (acciones != null)
                {
                    CacheLayer.Add <List <AccionEntity> >(acciones, keyCache);
                }
            }


            return(acciones);
        }
Esempio n. 16
0
        public UsuarioEntity GetUsuarioByUsername(string Username)
        {
            string        keyCache = KEY_USUARIO_BY_USERNAME + Username;
            UsuarioEntity user     = CacheLayer.Get <UsuarioEntity>(keyCache);

            if (user == null)
            {
                using (OrdenesContext context = new OrdenesContext())
                {
                    user = (from d in context.Usuario
                            where d.Username == Username
                            select d).FirstOrDefault();
                }
                if (user != null)
                {
                    CacheLayer.Add <UsuarioEntity>(user, keyCache);
                }
            }

            return(user);
        }
Esempio n. 17
0
        public UsuarioEntity GetByIdUsuario(int idusuario)
        {
            string        keyCache = KEY_USUARIO_BY_ID + idusuario;
            UsuarioEntity user     = CacheLayer.Get <UsuarioEntity>(keyCache);

            if (user == null)
            {
                using (OrdenesContext context = new OrdenesContext())
                {
                    user = (from d in context.Usuario
                            where d.IdUsuario == idusuario
                            select d).FirstOrDefault();
                }
                if (user != null)
                {
                    CacheLayer.Add <UsuarioEntity>(user, keyCache);
                }
            }

            return(user);
        }
Esempio n. 18
0
        public PartyEntity GetPadreByIdHijo(int idHijo)
        {
            string      keyCache = KEY_PADRE_BY_ID_HIJO + idHijo;
            PartyEntity persona  = CacheLayer.Get <PartyEntity>(keyCache);

            if (persona == null)
            {
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    persona = (from p in dbContext.Persona
                               join ph in dbContext.PartyHierarchyEntities on p.IdParty equals ph.IdPartyFather
                               where ph.IdPartyHijo == idHijo
                               select p).FirstOrDefault();
                }
                if (persona != null)
                {
                    CacheLayer.Add(persona, keyCache);
                }
            }
            return(persona);
        }
Esempio n. 19
0
        public PartyEntity GetPersonaByNroClienteTipo(string nroCliente, TipoPersona tipoPersona)
        {
            string      keyCache = KEY_PERSONA_BY_NRO_TIPO + "_" + nroCliente + tipoPersona;
            PartyEntity persona  = CacheLayer.Get <PartyEntity>(keyCache);

            if (persona == null)
            {
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    persona =
                        (from d in dbContext.Persona
                         where d.IdPartyType == (byte)tipoPersona &&
                         (string.IsNullOrEmpty(nroCliente) || d.MarketCustomerNumber.Equals(nroCliente.Trim()))
                         select d).FirstOrDefault();
                }
                if (persona != null)
                {
                    CacheLayer.Add(persona, keyCache);
                }
            }
            return(persona);
        }
Esempio n. 20
0
        public PartyEntity getPersonaParteByIdUsuarioLogin(long?identity_rid)
        {
            string      keyCache = KEY_PERSONAPARTE_BY_USUARIOLOGIN + "_" + identity_rid;
            PartyEntity persona  = CacheLayer.Get <PartyEntity>(keyCache);

            if (persona == null)
            {
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    persona =
                        (from d in dbContext.Persona
                         join u in dbContext.Usuario on d.IdParty equals u.IdPersona
                         where u.IdUsuario == identity_rid
                         select d).FirstOrDefault();
                }
                if (persona != null)
                {
                    CacheLayer.Add(persona, keyCache);
                }
            }
            return(persona);
        }
Esempio n. 21
0
        public bool UsuarioBloqueadoParaOperar(int idPersona, DateTime fechaOperacion, string bloqueoParaTipoOperacion)
        {
            string keyCache = KEY_USUARIOBLOQUEADO + idPersona.ToString() + bloqueoParaTipoOperacion;
            List <UsuarioBloqueadoEntity> usuariobloqueado = CacheLayer.Get <List <UsuarioBloqueadoEntity> >(keyCache);

            if (usuariobloqueado == null)
            {
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    usuariobloqueado =
                        (from d in dbContext.UsuarioBloqueado
                         where d.IdPersona == idPersona &&
                         d.TipoOperacion == bloqueoParaTipoOperacion &&
                         (fechaOperacion >= d.FechaBloqueoDesde && fechaOperacion <= d.FechaBloqueoHasta)
                         select d).ToList();
                }
                if (usuariobloqueado != null)
                {
                    CacheLayer.Add <List <UsuarioBloqueadoEntity> >(usuariobloqueado, keyCache);
                }
            }

            return(true);
        }
Esempio n. 22
0
        //public void ClearSession(Guid idSesion)
        //{
        //    string keyCache = KEY_SESSION_BY_ID + idSesion.ToString();
        //    MAEUserSession session = CacheLayer.Get<MAEUserSession>(keyCache);

        //    if (session != null)
        //    {
        //        CacheLayer.Clear(keyCache);
        //    }
        //}

        public M4TraderUserSessionLogin GetMaeUserSessionLogin(string idSesion, long idAplicacion = (long)TipoAplicacion.ORDENES)
        {
            string keyCache = KEY_SESSION_BY_ID_LOGIN + idSesion.ToString();
            M4TraderUserSessionLogin session = CacheLayer.Get <M4TraderUserSessionLogin>(keyCache);

            if (session == null)
            {
                Dictionary <string, string> javascriptAllowedCommands = new Dictionary <string, string>();
                Guid IdSesion  = OrdenesApplication.Instance.GetSessionIdFromRequest(idSesion);
                int  IdUsuario = 0;
                Dictionary <string, int> mapeoAcciones = new Dictionary <string, int>();
                var Acciones = CachingManager.Instance.GetAllAcciones();
                OrdenesApplication.Instance.GetComandosHabilitados((TipoAplicacion)idAplicacion)
                .ForEach(cmd =>
                {
                    var k = OrdenesApplication.Instance.Encryptor.DynamicEncryption(cmd.FullName);
                    javascriptAllowedCommands.Add(cmd.Key, k);
                    mapeoAcciones.Add(k, cmd.IdAccion);
                });
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    var sesion = dbContext.Sesion.Where(x => x.IdSesion == IdSesion).FirstOrDefault();
                    IdUsuario = sesion.IdUsuario;
                    int idEstadoSistema = dbContext.EstadoSistema.Where(p1 => p1.IdEstadoSistema != 0).Max(r => r.IdEstadoSistema);
                    var estadoSistema   = dbContext.EstadoSistema.Where(p => p.IdEstadoSistema == idEstadoSistema).FirstOrDefault();
                    session = (from s in dbContext.Sesion
                               join u in dbContext.Usuario on s.IdUsuario equals u.IdUsuario
                               join p in dbContext.Persona on u.IdPersona equals p.IdParty
                               where s.IdSesion == IdSesion
                               select new M4TraderUserSessionLogin()
                    {
                        Ok = true,
                        NombrePersona = p.Name,
                        TipoPersona = UserHelper.getNombreTipoPersona(p.IdPartyType),
                        EstadoSistema = estadoSistema.EstadoAbierto ? "Abierto" : "Cerrado",
                        UserName = u.Nombre,
                        JavascriptAllowedCommands = javascriptAllowedCommands,
                        FechaFinalizacionSesion = s.FechaFinalizacion,
                        PermisosUsuario = new Dictionary <string, bool>()
                    }
                               ).FirstOrDefault();
                }
                if (session != null)
                {
                    List <Permiso> PermisosUsuario = CachingManager.Instance.GetAllPermisosByIdUsuario(IdUsuario);
                    foreach (KeyValuePair <string, int> kv in mapeoAcciones)
                    {
                        Permiso p = PermisosUsuario.Find(x => x.IdAccion == kv.Value);
                        if (p != null)
                        {
                            var  permisoAccion = Acciones.Find(x => x.IdAccion == kv.Value).HabilitarPermisos;
                            bool habilitado    = (p.Permisos & permisoAccion) != 0;
                            session.PermisosUsuario.Add(kv.Key, habilitado);
                        }
                    }
                    CacheLayer.Add(session, keyCache);
                }
                else
                {
                    session = new M4TraderUserSessionLogin()
                    {
                        Ok      = false,
                        Message = "Sesión Expirada"
                    };
                }
            }
            return(session);
        }
Esempio n. 23
0
 public static void Insert(string key, object valor, DateTime fechaExperacion)
 {
     CacheLayer.Add(valor, key, fechaExperacion);
 }