Example #1
0
        public List <DTOMercado> GetAllMercados()
        {
            string            keyCache = KEY_ALL_MERCADOS;
            List <DTOMercado> mercados = CacheLayer.Get <List <DTOMercado> >(keyCache);

            if (mercados == null)
            {
                List <MercadoEntity> mercadoEntities;
                using (var ctx = new OrdenesContext())
                {
                    mercadoEntities = (from d in ctx.Mercado select d).ToList <MercadoEntity>();
                }
                if (mercadoEntities != null)
                {
                    mercados = new List <DTOMercado>();
                    foreach (MercadoEntity mercado in mercadoEntities)
                    {
                        mercados.Add(new DTOMercado()
                        {
                            IdMercado   = mercado.IdMercado,
                            Codigo      = mercado.Codigo,
                            Descripcion = mercado.Descripcion,
                            EsInterno   = mercado.EsInterno,
                            ProductoHabilitadoDefecto = mercado.ProductoHabilitadoDefecto
                        });
                    }
                    CacheLayer.Add <List <DTOMercado> >(mercados, keyCache);
                }
            }
            return(mercados);
        }
Example #2
0
        public ConcurrentDictionary <int, List <DTOUsuario> > GetChatsUsuarios()
        {
            string keyCache = KEY_USUARIOS_CHATS;
            ConcurrentDictionary <int, List <DTOUsuario> > dicChatUsuarios = CacheLayer.Get <ConcurrentDictionary <int, List <DTOUsuario> > >(keyCache);

            if (dicChatUsuarios == null)
            {
                dicChatUsuarios = new ConcurrentDictionary <int, List <DTOUsuario> >();
                using (OrdenesContext dbContext = new OrdenesContext())
                {
                    List <ChatEntity> chats = (from d in dbContext.Chats
                                               select d).ToList();
                    foreach (ChatEntity chat in chats)
                    {
                        List <DTOUsuario> usuarios = (from d in dbContext.ChatUsuarios
                                                      where d.IdChat == chat.IdChat
                                                      select new DTOUsuario()
                        {
                            IdUsuario = d.IdUsuario
                        }).ToList();


                        //TODO validar que se puede hacer si no logra agregarlo
                        dicChatUsuarios.TryAdd(chat.IdChat, usuarios);
                    }
                }
                if (dicChatUsuarios != null)
                {
                    CacheLayer.Add <ConcurrentDictionary <int, List <DTOUsuario> > >(dicChatUsuarios, keyCache);
                }
            }

            return(dicChatUsuarios);
        }
Example #3
0
        public DTOUsuario GetUsuariosPartiesDTO(Int64 idUsuario)
        {
            string     keyCache     = KEY_USUARIOS_PARTIES + "#" + idUsuario;
            DTOUsuario usuarioParty = CacheLayer.Get <DTOUsuario>(keyCache);

            if (usuarioParty == null)
            {
                using (OrdenesContext context = new OrdenesContext())
                {
                    usuarioParty = (from d in context.Usuario
                                    where d.IdUsuario == idUsuario
                                    select new DTOUsuario()
                    {
                        IdParty = d.IdPersona,
                        IdUsuario = d.IdUsuario
                    }
                                    ).FirstOrDefault();
                }
                if (usuarioParty != null)
                {
                    CacheLayer.Add(usuarioParty, keyCache);
                }
            }

            return(usuarioParty);
        }
Example #4
0
        public DTOPortfolio GetPortfolioById(int idPortfolio)
        {
            string keyCache = PORTFOLIOS_ALL;
            List <DTOPortfolio> dtoPortfolios = CacheLayer.Get <List <DTOPortfolio> >(keyCache);

            if (dtoPortfolios == null)
            {
                using (OrdenesContext mc = new OrdenesContext())
                {
                    dtoPortfolios = (from p in mc.Portfolios
                                     select new DTOPortfolio()
                    {
                        IdPortfolio = p.IdPortfolio,
                        Nombre = p.Nombre,
                        Codigo = p.Codigo,
                        EsDeSistema = p.EsDeSistema
                    }).ToList();
                }
                if (dtoPortfolios != null)
                {
                    CacheLayer.Add(dtoPortfolios, keyCache);
                }
            }

            return(dtoPortfolios.Find(x => x.IdPortfolio == idPortfolio));
        }
Example #5
0
        public List <DTOPortfolio> GetPortfoliosByIdPersona(int idPersona)
        {
            string keyCache = KEY_PORTFOLIO_BY_PERSONA + "#" + idPersona;
            List <DTOPortfolio> dtoPortfolio = CacheLayer.Get <List <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
                                    join u in mc.Usuario on pu.IdUsuario equals u.IdUsuario
                                    where u.IdPersona == idPersona
                                    select new DTOPortfolio()
                    {
                        IdPortfolio = p.IdPortfolio,
                        Nombre = p.Nombre,
                        Codigo = p.Codigo,
                        EsDeSistema = p.EsDeSistema
                    }).Distinct().ToList();
                }
                if (dtoPortfolio != null)
                {
                    CacheLayer.Add(dtoPortfolio, keyCache);
                }
            }

            return(dtoPortfolio);
        }
Example #6
0
        public DTOPortfolio GetPortfolioByCodigo(string codigo)
        {
            string       keyCache     = KEY_PORTFOLIO_CODIGO + "#" + codigo;
            DTOPortfolio dtoPortfolio = CacheLayer.Get <DTOPortfolio>(keyCache);

            if (dtoPortfolio == null)
            {
                using (OrdenesContext mc = new OrdenesContext())
                {
                    dtoPortfolio = (from p in mc.Portfolios
                                    where p.Codigo == codigo
                                    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);
        }
Example #7
0
        public DTOPortfolio GetPortfolioByIdProducto(int idProducto)
        {
            string keyCache = PORTFOLIOS_ALL;
            List <DTOPortfolio>        dtoPortfolios = CacheLayer.Get <List <DTOPortfolio> >(keyCache);
            PortfolioComposicionEntity pce           = new PortfolioComposicionEntity();


            using (OrdenesContext mc = new OrdenesContext())
            {
                pce = (from pc in mc.PortfoliosComposicion
                       where pc.IdProducto == idProducto
                       select pc).FirstOrDefault();
                if (dtoPortfolios == null)
                {
                    dtoPortfolios = (from p in mc.Portfolios
                                     select new DTOPortfolio()
                    {
                        IdPortfolio = p.IdPortfolio,
                        Nombre = p.Nombre,
                        Codigo = p.Codigo,
                        EsDeSistema = p.EsDeSistema
                    }).ToList();
                    CacheLayer.Add(dtoPortfolios, keyCache);
                }
            }

            return(dtoPortfolios.Find(x => x.IdPortfolio == pce.IdPortfolio));
        }
Example #8
0
        public void ClearUser(int idusuario)
        {
            string        keyCache = KEY_USUARIO_BY_ID + idusuario;
            UsuarioEntity user     = CacheLayer.Get <UsuarioEntity>(keyCache);

            if (user != null)
            {
                CacheLayer.Clear(keyCache);
            }
        }
Example #9
0
        public void ClearUser(string Username)
        {
            string        keyCache = KEY_USUARIO_BY_USERNAME + Username;
            UsuarioEntity user     = CacheLayer.Get <UsuarioEntity>(keyCache);

            if (user != null)
            {
                CacheLayer.Clear(keyCache);
            }
        }
Example #10
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);
        }
Example #11
0
        public AutorizationType GetAutorizacion(int idUsuario, short idAccion, TipoPermiso tipo_permiso)
        {
            string           keyCache     = KEY_AUTHORIZE + idUsuario + idAccion + tipo_permiso;
            AutorizationType autorizacion = CacheLayer.Get <AutorizationType>(keyCache);

            if (autorizacion == null)
            {
                autorizacion = new AutorizationType();
                autorizacion.tipoAutorizacion = SecurityHelper.AuthorizeAccion(idUsuario, (short)idAccion.GetHashCode(), tipo_permiso);
                if (autorizacion != null)
                {
                    Insert(keyCache, autorizacion, DateTime.Now.AddMinutes(30));
                }
            }
            return(autorizacion);
        }
Example #12
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);
        }
Example #13
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);
        }
Example #14
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);
        }
Example #15
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);
        }
Example #16
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);
        }
Example #17
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);
        }
Example #18
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);
        }
Example #19
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);
        }
Example #20
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);
        }
Example #21
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);
        }
Example #22
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);
        }
Example #23
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);
        }
Example #24
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);
        }
Example #25
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);
        }
Example #26
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);
        }
Example #27
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);
        }
Example #28
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);
        }
Example #29
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);
        }
Example #30
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);
        }