Beispiel #1
0
        /// <summary>
        /// 命令执行
        /// </summary>
        /// <param name="context"></param>
        public override void Execute(DataContext context)
        {
            UserCacheInfo userCache  = UserBiz.ReadUserCacheInfo(context.UserId);
            int           userSite   = userCache.UserSite;
            string        appChannel = context.ReqChannel;

            var        ads    = ExtendBiz.GetTopAdverts(appChannel, userSite, 5);
            AdvertList adList = new AdvertList {
                DataList = ads.Select(a => a.ToAdvert()).ToList()
            };

            context.Flush <AdvertList>(adList);
        }
Beispiel #2
0
        private static void GetAdvertisingPlaylist(string advertListPath, string demographicDataPath,
                                                   DemographicRangeVerifier demographicRangeVerifier, string password, Playlist playlist, ChannelData channelData,
                                                   ChannelSubscriptions channelSubscriptions, DateTime now, Logger logger)
        {
            // if the advertisment or the demographic data file is not found, an exception will be thrown
            // if user has corrupted any of the files, an exception will be thrown
            AdvertList advertList = (AdvertList)Serializer.Deserialize(typeof(AdvertList), advertListPath, password);

            // flatten channel definitions
            HashSet <string> channelDefinitions = new HashSet <string>();

            foreach (Channel channel in channelData.Channels)
            {
                SplitAndInsertChannelDefinitions(ref channelDefinitions, channel.ChannelDefinitions);
            }

            // flatten advert definitions
            HashSet <string> advertDefinitions = new HashSet <string>();

            foreach (AdvertAsset advertasset in advertList.Adverts)
            {
                SplitAndInsertChannelDefinitions(ref advertDefinitions, advertasset.AdvertDefinitions);
            }

            var advertListsFiltered = HashSetLinqAccess.ToHashSet <AdvertPlaylistAsset>(from AdvertAsset advertAsset in advertList.Adverts
                                                                                        where demographicRangeVerifier.IsAssetDemoSyntaxPlayable(advertAsset.DemoRequirements) &&
                                                                                        TreeSearch.IncludeByChannelClassifications(channelDefinitions, advertAsset.InclusionExclusionList) == true &&
                                                                                        TreeSearch.IncludeByAdvertClassifications(advertDefinitions, channelData, channelSubscriptions) == true &&
                                                                                        now >= advertAsset.StartDateTime &&
                                                                                        now <= advertAsset.EndDateTime
                                                                                        select new AdvertPlaylistAsset
            {
                AssetID               = advertAsset.AssetID,
                AssetFilename         = advertAsset.AssetFilename,
                ClickDestination      = advertAsset.ClickDestination,
                AssetWebSite          = advertAsset.AssetWebSite,
                PlayerType            = advertAsset.PlayerType,
                ScheduleInfo          = advertAsset.ScheduleInfo,
                DisplayLength         = advertAsset.DisplayDuration,
                WeightingUnnormalized = advertAsset.Weighting,
                StartDateTime         = advertAsset.StartDateTime,
                EndDateTime           = advertAsset.EndDateTime
            });

            playlist.AdvertBucket.AdvertAssets = advertListsFiltered;
        }