void ISecurityCacheManager.BatchTypeClear()
 {
     if (VPCCache.GetInstance().Contains <List <KeyValuePair <Guid, VPC.Entities.BatchType.BatchType> > >(string.Format("{0}", EntityCacheType.BatchTypes)))
     {
         VPCCache.GetInstance().Remove <List <KeyValuePair <Guid, VPC.Entities.BatchType.BatchType> > >(string.Format("{0}", EntityCacheType.BatchTypes));
     }
 }
Example #2
0
        List <MenuItem> IMenuManager.GetMenuBytenant(Guid tenantId)
        {
            var cacheKey   = _IMenuCacheManager.GetCacheKey(tenantId);
            var entityName = "";

            if (VPCCache.GetInstance().Contains <List <MenuItem> >(cacheKey))
            {
                return(VPCCache.GetInstance().Get <List <MenuItem> >(cacheKey));
            }

            IMetadataManager _IMetadataManager = new VPC.Framework.Business.MetadataManager.Contracts.MetadataManager();

            List <MenuItem> allmenus = new List <MenuItem>();

            allmenus = _review.GetMenuBytenant(tenantId).OrderBy(x => x.Name).ToList();

            foreach (var menuItem in allmenus)
            {
                if (menuItem.ReferenceEntityId != null && menuItem.ReferenceEntityId != "")
                {
                    if (menuItem != null && menuItem.MenuTypeId == 1)
                    {
                        entityName = _IMetadataManager.GetEntityNameByEntityContext(menuItem.ReferenceEntityId, false);
                    }
                    else if (menuItem != null && menuItem.MenuTypeId == 2)
                    {
                        entityName = _IMetadataManager.GetEntityNameByEntityContext(menuItem.ReferenceEntityId, true);
                    }
                    menuItem.ReferenceEntityId = entityName;
                }
            }
            VPCCache.GetInstance().Set(cacheKey, allmenus);

            return(allmenus);
        }
 void IResourceCacheManager.ClearCashe <T>(string cacheKey)
 {
     if (VPCCache.GetInstance().Contains <List <T> >(cacheKey))
     {
         VPCCache.GetInstance().Remove <List <T> >(cacheKey);
     }
 }
        List <VPC.Entities.BatchType.BatchType> ISecurityCacheManager.BatchTypesCache()
        {
            if (VPCCache.GetInstance().Contains <List <VPC.Entities.BatchType.BatchType> >(string.Format("{0}", EntityCacheType.BatchTypes)))
            {
                return(VPCCache.GetInstance().Get <List <VPC.Entities.BatchType.BatchType> >(string.Format("{0}", EntityCacheType.BatchTypes)));
            }
            var batchTypes = batchTypeManager.GetEnabledBatchType();

            VPCCache.GetInstance().Set(string.Format("{0}", EntityCacheType.BatchTypes), batchTypes);
            return(batchTypes);
        }
        private List <WorkFlowInfo> GetWorkFlowCache(Guid tenantId, Guid userId, bool isSuperAdmin)
        {
            VPCCache.GetInstance().Remove <List <WorkFlowInfo> >(string.Format("{0}-{1}", EntityCacheType.WorkFlow, userId));
            if (VPCCache.GetInstance().Contains <List <WorkFlowInfo> >(string.Format("{0}-{1}", EntityCacheType.WorkFlow, userId)))
            {
                return(VPCCache.GetInstance().Get <List <WorkFlowInfo> >(string.Format("{0}-{1}", EntityCacheType.WorkFlow, userId)));
            }
            var workFlows = workFlowManager.GetWorkFlowsByUserCode(tenantId, userId, isSuperAdmin);

            VPCCache.GetInstance().Set(string.Format("{0}-{1}", EntityCacheType.WorkFlow, userId), workFlows);
            return(workFlows);
        }
Example #6
0
        List <Resource> IResourceManager.GetResources(Guid tenantId, string language)
        {
            var cacheKey = _resourceCacheManager.GetCacheKey(tenantId, language);

            // if (VPCCache.GetInstance().Contains<List<Resource>>(cacheKey))
            // {
            //     return VPCCache.GetInstance().Get<List<Resource>>(cacheKey);
            // }

            if (language == null)
            {
                language = _tanantManager.GetTenantLanguageInfo(tenantId).Key;
            }

            var lstResources = _resourceReview.GetResources(tenantId, language);

            VPCCache.GetInstance().Set(cacheKey, lstResources);

            return(lstResources);
        }
        private List <EntitySecurityInfo> GetFunctionCache(Guid tenantId, Guid userId)
        {
            if (VPCCache.GetInstance().Contains <List <EntitySecurityInfo> >(string.Format("{0}-{1}", EntityCacheType.Function, userId)))
            {
                return(VPCCache.GetInstance().Get <List <EntitySecurityInfo> >(string.Format("{0}-{1}", EntityCacheType.Function, userId)));
            }
            var functionSecurities       = _managerEntitySecurity.GetFunctionSecuritiesByUserCode(tenantId, userId);
            var uniqueFunctionContextIds = new List <Guid>();

            uniqueFunctionContextIds = (from functionSecurity in functionSecurities select functionSecurity.FunctionContext).Distinct().ToList();
            var filteredSecurities = new List <EntitySecurityInfo>();

            foreach (var uniqueFunctionContextId in uniqueFunctionContextIds)
            {
                var   itsFunctions    = (from functionSecurity in functionSecurities where functionSecurity.FunctionContext == uniqueFunctionContextId select functionSecurity).ToList();
                int[] values          = new int[] { 0, 0, 0, 0, 0, 0, 0 };
                var   functionContext = Guid.Empty;
                foreach (var itsFunction in itsFunctions)
                {
                    functionContext = itsFunction.FunctionContext;
                    var itsCodes = itsFunction.SecurityCode.ToString().Select(t => int.Parse(t.ToString())).ToArray();
                    for (int i = 0; i < itsCodes.Count(); i++)
                    {
                        if (itsCodes[i] > values[i])
                        {
                            values[i] = itsCodes[i];
                        }
                    }
                }
                var itsCode = string.Join("", values);
                filteredSecurities.Add(new EntitySecurityInfo {
                    SecurityCode = Convert.ToInt32(itsCode), FunctionContext = functionContext
                });
            }

            VPCCache.GetInstance().Set(string.Format("{0}-{1}", EntityCacheType.Function, userId), filteredSecurities);
            return(filteredSecurities);
        }
        private List <EntitySecurityInfo> GetEntityCache(Guid tenantId, Guid userId)
        {
            if (VPCCache.GetInstance().Contains <List <EntitySecurityInfo> >(string.Format("{0}-{1}", EntityCacheType.Entity, userId)))
            {
                return(VPCCache.GetInstance().Get <List <EntitySecurityInfo> >(string.Format("{0}-{1}", EntityCacheType.Entity, userId)));
            }
            var entitySecurities = _managerEntitySecurity.GetEntitySecuritiesByUserCode(tenantId, userId);
            var uniqueEntityIds  = new List <string>();

            uniqueEntityIds = (from entitySecurity in entitySecurities select entitySecurity.EntityId).Distinct().ToList();
            var filteredSecurities = new List <EntitySecurityInfo>();

            foreach (var uniqueEntityId in uniqueEntityIds)
            {
                var   itsEntities = (from entitySecurity in entitySecurities where entitySecurity.EntityId == uniqueEntityId select entitySecurity).ToList();
                int[] values      = new int[] { 0, 0, 0, 0, 0, 0, 0 };
                foreach (var itsEntity in itsEntities)
                {
                    var itsCodes = itsEntity.SecurityCode.ToString().Select(t => int.Parse(t.ToString())).ToArray();
                    for (int i = 0; i < itsCodes.Count(); i++)
                    {
                        if (itsCodes[i] > values[i])
                        {
                            values[i] = itsCodes[i];
                        }
                    }
                }
                var itsCode = string.Join("", values);
                filteredSecurities.Add(new EntitySecurityInfo {
                    EntityId = uniqueEntityId, SecurityCode = Convert.ToInt32(itsCode)
                });
            }

            VPCCache.GetInstance().Set(string.Format("{0}-{1}", EntityCacheType.Entity, userId), filteredSecurities);
            return(filteredSecurities);
        }
 void ISecurityCacheManager.Clear(Guid tenantId, Guid userId, string keyType)
 {
     if (keyType == EntityCacheType.Entity)
     {
         if (VPCCache.GetInstance().Contains <List <EntitySecurityInfo> >(string.Format("{0}-{1}", keyType, userId)))
         {
             VPCCache.GetInstance().Remove <List <EntitySecurityInfo> >(string.Format("{0}-{1}", keyType, userId));
         }
     }
     else if (keyType == EntityCacheType.WorkFlow)
     {
         if (VPCCache.GetInstance().Contains <List <WorkFlowInfo> >(string.Format("{0}-{1}", keyType, userId)))
         {
             VPCCache.GetInstance().Remove <List <WorkFlowInfo> >(string.Format("{0}-{1}", keyType, userId));
         }
     }
     else if (keyType == EntityCacheType.Function)
     {
         if (VPCCache.GetInstance().Contains <List <EntitySecurityInfo> >(string.Format("{0}-{1}", keyType, userId)))
         {
             VPCCache.GetInstance().Remove <List <EntitySecurityInfo> >(string.Format("{0}-{1}", keyType, userId));
         }
     }
 }