Пример #1
0
        /// <summary>
        ///     Load all campaign items from the database.
        /// </summary>
        /// <returns></returns>
        private CampaignItemSet LoadCampaignItemSet()
        {
            var campaignItemSet = new CampaignItemSet();

            // Get the collection from the ORM data layer
            var metaData = new LinqMetaData();

            IQueryable <CampaignItemEntity> campaignItems = from c in metaData.CampaignItem select c;

            var campaignItemCollection = ((ILLBLGenProQuery)campaignItems).Execute <CampaignItemCollection>();

            // Fill the entity set from the data collection
            if (campaignItemCollection.Count > 0)
            {
                foreach (var campaignItemEntity in campaignItemCollection)
                {
                    var campaignItem = new CampaignItem(campaignItemEntity);

                    campaignItemSet.Add(campaignItem);
                }
            }

            // Return the entity set
            return(campaignItemSet);
        }
Пример #2
0
        /// <summary>
        ///     Get the collection of all campaign items.
        /// </summary>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns>A set of campaign items</returns>
        public CampaignItemSet GetCampaignItems(bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity set from the database
            if (noCache && !refreshCache)
            {
                return(LoadCampaignItemSet());
            }

            CampaignItemSet campaignItemSet;

            string cacheKey = CampaignItemSet.StaticGetCacheKey();

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <CampaignItemSet>(cacheKey) || refreshCache)
            {
                // Load the entity set from the database
                campaignItemSet = LoadCampaignItemSet();

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

            return(campaignItemSet);
        }