Exemplo n.º 1
0
		private static void SetUpRequestRules(Bobs.Banner.Positions position, bool isHttpsContext, Identity id, RequestRules requestRules)
		{
			requestRules.Add(new BannerPositionRule(position));
			requestRules.Add(id.IdentityRules);
			requestRules.Add(new Rules.TypesOfRule.BannerIsLiveRule());
			if (isHttpsContext)
			{
				requestRules.Add(new BannerIsNotHtmlRule());
			}
		}
Exemplo n.º 2
0
		internal void Add(RequestRules rr)
		{
			foreach (Rule rule in rr.Rules)
			{
				rulesInfo[rule] = rr.Get(rule);
			}
			this.MusicTypes.Add(rr.MusicTypes);
			this.PlacesVisited.Add(rr.PlacesVisited);
			cacheKey = null;
			bannersSatsfyingQueryConditionsInTimeslot = null;
		}
Exemplo n.º 3
0
		public List<BannerDataHolder> GetBanners(Bobs.Banner.Positions position, bool isHttpsContext, int numberOfBannersToGet, Identity id, RequestRules rules)
		{
			Timeslot currentTimeslot = Timeslots.GetCurrentTimeslot();
			currentTimeslot.CallsToBannerServer().Increment();

			SetUpRequestRules(position, isHttpsContext, id, rules);

			List<BannerDataHolder> chosenBanners = new List<BannerDataHolder>(numberOfBannersToGet);

			foreach (BannerQuerySetInfo bannerQuerySetInfo in rules.BannerQuerySetInfosInDescendingPriorityOrder(currentTimeslot))
			{
				AddBanners(numberOfBannersToGet, id, bannerQuerySetInfo, chosenBanners);
				if (chosenBanners.Count == chosenBanners.Capacity) { return chosenBanners; }
			}
			#region REMOVED DUE TO BANNER SERVER BUG
			//rules.RemoveBannersWhichHaveReachedTargetsFromCachedQuery(currentTimeslot);
			#endregion
			PadOutChosenBannersWithNulls(chosenBanners);
			return chosenBanners;
		}
Exemplo n.º 4
0
		public BannerDataHolder GetBanner(Bobs.Banner.Positions position, bool isHttpsContext, Identity identity, RequestRules requestRules)
		{
			List<BannerDataHolder> banners = GetBanners(position, isHttpsContext, 1, identity, requestRules);
			return banners[0];
		}
Exemplo n.º 5
0
		public BannerRenderInfo GetBanner(int positionAsInt, string relevantPlacesCsv, string relevantMusicTypesCsv)
		{
			var position = (Banner.Positions) positionAsInt;
			var rules = new RequestRules();
			if (relevantMusicTypesCsv.Length > 0)
			{
				foreach (var i in relevantMusicTypesCsv.Split(',').Select(s => int.Parse(s)))
				{
					rules.MusicTypes.Add(i);
				}
			}
			if (relevantPlacesCsv.Length > 0)
			{
				foreach (var i in relevantPlacesCsv.Split(',').Select(s => int.Parse(s)))
				{
					rules.PlacesVisited.Add(i);
				}
			}

			var server = new Bobs.BannerServer.Server();
			BannerDataHolder bdh = server.GetBanner(position, false, Identity.Current, rules);
			for (int i = 0; i < 5 && bdh == null; i++)
			{
				bdh = server.GetBanner(position, false, Identity.Current, rules);

			}
			BannerRenderInfo bannerRenderInfo = null;
			if (bdh != null)
			{
				
				switch (bdh.Banner.DisplayType)
				{
					case Banner.DisplayTypes.AnimatedGif:
					case Banner.DisplayTypes.AutoEventBanner:
					case Banner.DisplayTypes.CustomAutoEventBanner:
					case Banner.DisplayTypes.Jpg:
						Page pageHolder = new Page();
						var genericBanner = (GenericBanner) pageHolder.LoadControl("/Controls/Banners/GenericBanner.ascx");
						pageHolder.Controls.Add(genericBanner);

						//bControl.ClickHelperLeftOffset = ClickHelperLeftOffset;
						//bControl.ClickHelperTopOffset = ClickHelperTopOffset;
						//bControl.ShowClickHelper = ShowClickHelper;
						genericBanner.CurrentBanner = bdh.Banner;
						genericBanner.Bind();
						
						StringBuilder stringBuilder = new StringBuilder();
						using (var stringWriter = new StringWriter(stringBuilder))
						{
							HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);
							
							HttpContext.Current.Server.Execute(pageHolder, stringWriter, false);

						}
						bannerRenderInfo = new BannerRenderInfo()
						{
							bannerRenderInfoType = BannerRenderInfoType.Html,
							html = stringBuilder.ToString()
						};
						
						break;
					case Banner.DisplayTypes.FlashMovie:
					{
						bannerRenderInfo = new BannerRenderInfo()
						{
							bannerRenderInfoType = BannerRenderInfoType.Flash,
							flashUrl = bdh.Banner.Misc.Url(),
							flashVersion = string.IsNullOrEmpty(bdh.Banner.Misc.RequiredFlashVersion) ? "7" : bdh.Banner.Misc.RequiredFlashVersion,
							targetTag = bdh.Banner.InternalLink ? "_self" : "_blank",
							linkTag = bdh.Banner.LinkUrlLive.StartsWith("http://") ? bdh.Banner.LinkUrlLive : "http://" + Vars.DomainName + bdh.Banner.LinkUrlLive,
							miscNeedsClickHelper = !bdh.Banner.Misc.BannerLinkTag
						};
						break;
					}
					case Banner.DisplayTypes.CustomHtml:
					default:
						break;

				}
				if (bannerRenderInfo != null)
				{
					bannerRenderInfo.k = bdh.Banner.K;
					bannerRenderInfo.height = bdh.Banner.Height;
					bannerRenderInfo.width = bdh.Banner.Width;
					bannerRenderInfo.duration = (bdh.Banner.DisplayDuration ?? Common.Settings.DefaultBannerDurationInSeconds)*1000;
					Log.Items itemRotation;
					Log.Items itemHit;
					switch(position)
					{
						case Banner.Positions.Hotbox:
							itemRotation = Log.Items.HotboxRotation;
							itemHit = Log.Items.HotBoxHit;
							break;
						case Banner.Positions.Leaderboard:
							itemRotation = Log.Items.LeaderboardRotation;
							itemHit = Log.Items.LeaderboardHit; break;
						case Banner.Positions.Skyscraper:
							itemRotation = Log.Items.SkyScraperRotation;
							itemHit = Log.Items.SkyScraperHit; break;
						case Banner.Positions.PhotoBanner:
							itemRotation = Log.Items.PhotoBannerRotation;
							itemHit = Log.Items.PhotoBannerHit; break;
						default:
							throw new NotImplementedException();
					}
					Log.Increment(itemRotation);
					Log.Increment(itemHit);
					bdh.Banner.RegisterHit();
				}
			}
			
			return bannerRenderInfo;
		}