Ejemplo n.º 1
0
        private static void DirectApiImport()
        {
            var context = new SpecialistWebDataContext();
            var result  = DirectApiService.GetActiveCompaignIDs();

            for (int j = 0; j < 3; j++)
            {
                //WL(DirectApiProxy.GetBannerPhrases(new [] {1297662}));
                var compaigns = result.Skip(10 * j).Take(10).ToList();
                //	WL(compaigns);
                var bannerIds = DirectApiService.GetBanners(new {
                    CampaignIDS = compaigns,
                    Filter      = new {
                        IsActive = new[] { "Yes" }
                    }
                }).AsJEnumerable().Select(x => x.Value <int>("BannerID"))
                                .Distinct()
                                .ToList();
                //WL(banners);

                var phraseList = DirectApiService.GetBannerPhrasesFilter(bannerIds).AsJEnumerable();
                var phrases    = phraseList
                                 .Select(x => new YdBannerPhrase {
                    PhraseID        = x["PhraseID"].Value <int>(),
                    CampaignID      = x["CampaignID"].Value <int>(),
                    Phrase          = x["Phrase"].Value <string>(),
                    CurrentOnSearch = x["CurrentOnSearch"].Value <double>(),
                    BannerID        = x["BannerID"].Value <int>()
                });
                var final = phrases.Where(x => DirectApiService.Phrases.Contains(x.Phrase)).ToList();
                context.YdBannerPhrases.InsertAllOnSubmit(final);
            }

            context.SubmitChanges();
        }
Ejemplo n.º 2
0
        private static void UpdateActiveByActualDate()
        {
            var context = new SpecialistWebDataContext();
            var banners = context.Banners
                          .Where(b => b.ActualDate < DateTime.Today && b.IsActive);

            foreach (var banner in banners)
            {
                banner.IsActive = false;
            }
            context.SubmitChanges();
        }