Example #1
0
        /// <summary>
        ///     Get the collection of all campaign stores. The cache is enabled by default.
        /// </summary>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns></returns>
        public CampaignStoreSet GetCampaignStores(bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity set from the database
            if (noCache && !refreshCache)
            {
                return(LoadCampaignStoreSet());
            }

            CampaignStoreSet campaignStoreSet;

            string cacheKey = CampaignStoreSet.StaticGetCacheKey();

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <CampaignStoreSet>(cacheKey) || refreshCache)
            {
                // Load the entity set from the database
                campaignStoreSet = LoadCampaignStoreSet();

                if (campaignStoreSet != null)
                {
                    // Add the entity set to the cache by reading caching parameters from the configuration
                    CacheManagerProvider.GetCacheManagerInstance().Insert(cacheKey, campaignStoreSet,
                                                                          ConfigurationManager.GetCacheExpirationByType(
                                                                              campaignStoreSet.GetType()));
                }
            }
            else
            {
                campaignStoreSet = CacheManagerProvider.GetCacheManagerInstance().Get <CampaignStoreSet>(cacheKey);
            }
            return(campaignStoreSet);
        }
Example #2
0
        /// <summary>
        ///     Load all campaign stores from the database.
        /// </summary>
        /// <returns></returns>
        private CampaignStoreSet LoadCampaignStoreSet()
        {
            var campaignStoreSet = new CampaignStoreSet();

            // Get the collection from the ORM data layer
            var metaData = new LinqMetaData();
            IQueryable <CampaignStoreEntity> campaignStores = from c in metaData.CampaignStore select c;

            var campaignStoreCollection = ((ILLBLGenProQuery)campaignStores).Execute <CampaignStoreCollection>();

            if (campaignStoreCollection.Count > 0)
            {
                foreach (var campaignStoreEntity in campaignStoreCollection)
                {
                    var campaignStore = new CampaignStore(campaignStoreEntity);
                    campaignStoreSet.Add(campaignStore);
                }
            }
            return(campaignStoreSet);
        }