示例#1
0
        /// <summary>
        ///     Load all campaigns from the database.
        /// </summary>
        /// <returns></returns>
        private CampaignSet LoadCampaignSet()
        {
            var campaignSet = new CampaignSet();

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

            IQueryable <CampaignEntity> campaigns = from c in metaData.Campaign select c;

            var campaignCollection = ((ILLBLGenProQuery)campaigns).Execute <CampaignCollection>();

            // Fill the entity set from the data collection
            if (campaignCollection.Count > 0)
            {
                foreach (var campaignEntity in campaignCollection)
                {
                    var campaign = new Campaign(campaignEntity);
                    campaign.CampaignType   = ServiceManagerProvider.GetCampaignTypeManager().GetCampaignType(campaign.CampaignTypeId);
                    campaign.RedemptionCode = ServiceManagerProvider.GetRedemptionCodeManager().GetRedemptionCode(campaign.RedemptionCodeId);

                    campaignSet.Add(campaign);
                }
            }

            // Return the entity set
            return(campaignSet);
        }
        private static void ShowReputationForCampaigns(CampaignSet tallTales, string name, bool onlyIncomplete)
        {
            char allTalesDone = tallTales.EmblemsTotal == tallTales.EmblemsUnlocked ? 'X' : ' ';

            Console.WriteLine($"[{allTalesDone}] {name}");

            if (allTalesDone == 'X')
            {
                return;
            }

            foreach (var tale in tallTales.Campaigns)
            {
                string   campaignName     = tale.Key;
                Campaign compaign         = tale.Value;
                char     campaignComplete = compaign.EmblemsTotal == compaign.EmblemsUnlocked ? 'X' : ' ';

                if (onlyIncomplete && campaignComplete == 'X')
                {
                    continue;
                }

                Console.WriteLine($"{Indent}[{campaignComplete}] {compaign.Title}");

                PrintEmblems(compaign.Emblems, onlyIncomplete, 2);
            }
        }
示例#3
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);
        }
示例#4
0
        /// <summary>
        /// Method to retrieve all campaigns from database and store into a campaign set
        /// </summary>
        /// <returns></returns>
        private static IEnumerable <CampaignViewModel> GetCampaignViewModels()
        {
            _campaigns = ServiceManagerProvider.GetCampaignManager().GetCampaigns();

            return(_campaigns.OrderByDescending(campaign => campaign.StartDate).Select(campaign => new CampaignViewModel
            {
                BusinessFormat = campaign.BusinessFormat,
                CampaignId = campaign.CampaignId,
                CampaignCode = campaign.CampaignCode,
                CampaignName = campaign.CampaignName,
                CampaignTypeId = campaign.CampaignTypeId,
                Description = campaign.Description,
                StartDate = campaign.StartDate,
                EndDate = campaign.EndDate,
                RedemptionCodeId = campaign.RedemptionCodeId,
                IsLocked = campaign.IsLocked,
                CreatedBy = campaign.CreatedBy
            }).ToList());
        }