示例#1
0
        /// <summary>
        ///     Get the collection of all channelOwners.
        /// </summary>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns>A set of channelOwners</returns>
        public ChannelOwnerSet GetChannelOwners(bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity set from the database
            if (noCache && !refreshCache)
            {
                return(LoadChannelOwnerSet());
            }

            ChannelOwnerSet channelOwnerSet;

            string cacheKey = ChannelOwnerSet.StaticGetCacheKey();

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <ChannelOwnerSet>(cacheKey) || refreshCache)
            {
                // Load the entity set from the database
                channelOwnerSet = LoadChannelOwnerSet();

                if (channelOwnerSet != null)
                {
                    // Add the entity set to the cache by reading caching parameters from the configuration
                    CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, channelOwnerSet,
                                                                          ConfigurationManager.GetCacheExpirationByType(
                                                                              channelOwnerSet.GetType()));
                }
            }
            else
            {
                channelOwnerSet = CacheManagerProvider.GetCacheManagerInstance().Get <ChannelOwnerSet>(cacheKey);
            }

            return(channelOwnerSet);
        }
示例#2
0
        /// <summary>
        ///    Get the collection of all StoreOptions. The cache is enabled by default.
        /// </summary>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns>A set of StoreOptions</returns>
        public StoreOptionTypeSet GetStoreOptions(bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity set from the database
            if (noCache && !refreshCache)
            {
                return(LoadStoreOptionTypeSet());
            }

            StoreOptionTypeSet storeOptionSet;

            var cacheKey = StoreOptionTypeSet.StaticGetCacheKey();

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <StoreOptionTypeSet>(cacheKey) || refreshCache)
            {
                // Load the entity set from the database
                storeOptionSet = LoadStoreOptionTypeSet();
                if (storeOptionSet != null)
                {
                    // Add the entity set to the cache by reading caching parameters from the configuration
                    CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, storeOptionSet,
                                                                          ConfigurationManager.GetCacheExpirationByType(
                                                                              storeOptionSet.GetType()));
                }
            }
            else
            {
                storeOptionSet = CacheManagerProvider.GetCacheManagerInstance().Get <StoreOptionTypeSet>(cacheKey);
            }

            return(storeOptionSet);
        }
示例#3
0
        /// <summary>
        ///     Get the collection of all channel stores. The cache is enabled by default.
        /// </summary>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <param name="channelId">Bypass the cache</param>
        /// param name="channelId">Bypass the cache</param>
        /// <returns></returns>
        public List <ChannelStore> GetChannelStoresByChannelId(int channelId, bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity set from the database
            if (noCache && !refreshCache)
            {
                return(GetChannelStoreById(channelId));
            }

            List <ChannelStore> channelStoreList;

            var cacheKey = ChannelStoreSet.StaticGetCacheKey();

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <ChannelStoreSet>(cacheKey) || refreshCache)
            {
                // Load the entity set from the database
                channelStoreList = GetChannelStoreById(channelId);

                if (channelStoreList != null)
                {
                    // Add the entity set to the cache by reading caching parameters from the configuration
                    CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, channelStoreList,
                                                                          ConfigurationManager.GetCacheExpirationByType(
                                                                              channelStoreList.GetType()));
                }
            }
            else
            {
                channelStoreList = CacheManagerProvider.GetCacheManagerInstance().Get <List <ChannelStore> >(cacheKey);
            }
            return(channelStoreList);
        }
示例#4
0
        /// <summary>
        ///     Get the current channelOwner of a channelOwner. The cache is not bypassed by default.
        /// </summary>
        /// <param name="channelOwnerId">The channelOwner identifier</param>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns>A channelOwner</returns>
        public ChannelOwner GetChannelOwner(int channelOwnerId, bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity from the database
            if (noCache && !refreshCache)
            {
                return(LoadChannelOwner(channelOwnerId));
            }

            ChannelOwner channelOwner;

            string cacheKey = ChannelOwner.GetCacheKeyById(channelOwnerId);

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <ChannelOwner>(cacheKey) || refreshCache)
            {
                // Load the entity from the database
                channelOwner = LoadChannelOwner(channelOwnerId);

                if (channelOwner != null)
                {
                    // Add the entity to the cache by reading caching parameters from the configuration
                    CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, channelOwner,
                                                                          ConfigurationManager.GetCacheExpirationByType(
                                                                              channelOwner.GetType()));
                }
            }
            else
            {
                channelOwner = CacheManagerProvider.GetCacheManagerInstance().Get <ChannelOwner>(cacheKey);
            }

            return(channelOwner);
        }
示例#5
0
        /// <summary>
        ///     Get the collection of all product items.
        /// </summary>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns>A set of product items</returns>
        public ProductItemSet GetProductItems(bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity set from the database
            if (noCache && !refreshCache)
            {
                return(LoadProductItemSet());
            }

            ProductItemSet productItemSet;

            string cacheKey = ProductItemSet.StaticGetCacheKey();

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <ProductItemSet>(cacheKey) || refreshCache)
            {
                // Load the entity set from the database
                productItemSet = LoadProductItemSet();

                if (productItemSet != null)
                {
                    // Add the entity set to the cache by reading caching parameters from the configuration
                    CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, productItemSet,
                                                                          ConfigurationManager.GetCacheExpirationByType(
                                                                              productItemSet.GetType()));
                }
            }
            else
            {
                productItemSet = CacheManagerProvider.GetCacheManagerInstance().Get <ProductItemSet>(cacheKey);
            }

            return(productItemSet);
        }
示例#6
0
        /// <summary>
        ///     Get the campaign item. The cache is not bypassed by default.
        /// </summary>
        /// <param name="campaignItemId">The campaign item identifier</param>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns>A campaign item</returns>
        public CampaignItem GetCampaignItem(int campaignItemId, bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity from the database
            if (noCache && !refreshCache)
            {
                return(LoadCampaign(campaignItemId));
            }

            CampaignItem campaignItem;

            string cacheKey = CampaignItem.GetCacheKeyById(campaignItemId);

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <CampaignItem>(cacheKey) || refreshCache)
            {
                // Load the entity from the database
                campaignItem = LoadCampaign(campaignItemId);

                if (campaignItem != null)
                {
                    // Add the entity to the cache by reading caching parameters from the configuration
                    CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, campaignItem,
                                                                          ConfigurationManager.GetCacheExpirationByType(
                                                                              campaignItem.GetType()));
                }
            }
            else
            {
                campaignItem = CacheManagerProvider.GetCacheManagerInstance().Get <CampaignItem>(cacheKey);
            }

            return(campaignItem);
        }
示例#7
0
        /// <summary>
        ///     Get the product item. The cache is not bypassed by default.
        /// </summary>
        /// <param name="productId">The product identifier</param>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns>A product</returns>
        public ProductItem GetProductItem(string itemCode, bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity from the database
            if (noCache && !refreshCache)
            {
                return(GetProductByItemCode(itemCode));
            }

            ProductItem product;

            string cacheKey = ProductItem.GetCustomCacheKey(itemCode);

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <ProductItem>(cacheKey) || refreshCache)
            {
                // Load the entity from the database
                product = GetProductByItemCode(itemCode);

                if (product != null)
                {
                    // Add the entity to the cache by reading caching parameters from the configuration
                    CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, product,
                                                                          ConfigurationManager.GetCacheExpirationByType(
                                                                              product.GetType()));
                }
            }
            else
            {
                product = CacheManagerProvider.GetCacheManagerInstance().Get <ProductItem>(cacheKey);
            }

            return(product);
        }
示例#8
0
        /// <summary>
        ///     Get the collection of all redemptionCodes.
        /// </summary>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns>A set of redemptionCodes</returns>
        public RedemptionCodeSet GetRedemptionCodes(bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity set from the database
            if (noCache && !refreshCache)
            {
                return(LoadRedemptionCodeSet());
            }

            RedemptionCodeSet redemptionCodeSet;

            string cacheKey = RedemptionCodeSet.StaticGetCacheKey();

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <RedemptionCodeSet>(cacheKey) || refreshCache)
            {
                // Load the entity set from the database
                redemptionCodeSet = LoadRedemptionCodeSet();

                if (redemptionCodeSet != null)
                {
                    // Add the entity set to the cache by reading caching parameters from the configuration
                    CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, redemptionCodeSet,
                                                                          ConfigurationManager.GetCacheExpirationByType(
                                                                              redemptionCodeSet.GetType()));
                }
            }
            else
            {
                redemptionCodeSet = CacheManagerProvider.GetCacheManagerInstance().Get <RedemptionCodeSet>(cacheKey);
            }

            return(redemptionCodeSet);
        }
示例#9
0
        /// <summary>
        ///     Get the current redemptionCode of a redemptionCode. The cache is not bypassed by default.
        /// </summary>
        /// <param name="redemptionCodeId">The redemptionCode identifier</param>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns>A redemptionCode</returns>
        public RedemptionCode GetRedemptionCode(int redemptionCodeId, bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity from the database
            if (noCache && !refreshCache)
            {
                return(LoadRedemptionCode(redemptionCodeId));
            }

            RedemptionCode redemptionCode;

            string cacheKey = RedemptionCode.GetCacheKeyById(redemptionCodeId);

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <RedemptionCode>(cacheKey) || refreshCache)
            {
                // Load the entity from the database
                redemptionCode = LoadRedemptionCode(redemptionCodeId);

                if (redemptionCode != null)
                {
                    // Add the entity to the cache by reading caching parameters from the configuration
                    CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, redemptionCode,
                                                                          ConfigurationManager.GetCacheExpirationByType(
                                                                              redemptionCode.GetType()));
                }
            }
            else
            {
                redemptionCode = CacheManagerProvider.GetCacheManagerInstance().Get <RedemptionCode>(cacheKey);
            }

            return(redemptionCode);
        }
示例#10
0
        /// <summary>
        ///     Get the channel item from product ID. The cache is not bypassed by default.
        /// </summary>
        /// <param name="productId">The product identifier</param>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns>A Channel</returns>
        public ChannelItem GetChannelProcduct(int productId, int channelId, bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity from the database
            if (noCache && !refreshCache)
            {
                return(GetChannelProductByProductId(productId, channelId));
            }

            ChannelItem channel;

            string cacheKey = ChannelItem.GetCustomCacheKey(productId.ToString());

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <ChannelItem>(cacheKey) || refreshCache)
            {
                // Load the entity from the database
                channel = GetChannelProductByProductId(productId, channelId);

                if (channel != null)
                {
                    // Add the entity to the cache by reading caching parameters from the configuration
                    CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, channel,
                                                                          ConfigurationManager.GetCacheExpirationByType(
                                                                              channel.GetType()));
                }
            }
            else
            {
                channel = CacheManagerProvider.GetCacheManagerInstance().Get <ChannelItem>(cacheKey);
            }
            return(channel);
        }
示例#11
0
        /// <summary>
        ///     Remove entity from the cache.
        /// </summary>
        public void Refresh()
        {
            // Remove entity of the cache
            string cacheKey = GetCacheKey();

            if (CacheManagerProvider.GetCacheManagerInstance().Contains <T>(cacheKey))
            {
                CacheManagerProvider.GetCacheManagerInstance().Remove(cacheKey, this);
            }
        }