Пример #1
0
        /// <summary>
        ///     Get the collection of all campaigns.
        /// </summary>
        /// <param name="noCache">Bypass the cache</param>
        /// <param name="refreshCache">Force refresh the cache</param>
        /// <returns>A set of campaigns</returns>
        public CampaignSet GetCampaigns(bool noCache, bool refreshCache)
        {
            // If no cache the load and return a entity set from the database
            if (noCache && !refreshCache)
            {
                return(LoadCampaignSet());
            }

            CampaignSet campaignSet;

            string cacheKey = CampaignSet.StaticGetCacheKey();

            if (!CacheManagerProvider.GetCacheManagerInstance().Contains <CampaignSet>(cacheKey) || refreshCache)
            {
                // Load the entity set from the database
                campaignSet = LoadCampaignSet();

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

            return(campaignSet);
        }