public void TestThatNamespaceCacheKeysAreInvalidatedBySqlCommands()
		{
			Caching.Instances.Main.FlushAll();
			Usr u1 = new Usr()
			{
				NickName= Guid.NewGuid().ToString(),
				Email = Guid.NewGuid().ToString()
			};
			u1.Update();
			Usr u2 = new Usr()
			{
				NickName = Guid.NewGuid().ToString(),
				Email = Guid.NewGuid().ToString()
			};
			u1.Update();
			u2.Update();
			Assert.IsNull(Caching.Instances.Main.Get(Caching.CacheKeys.Usr.Banners(u1.K)));
			Assert.IsNull(Caching.Instances.Main.Get(Caching.CacheKeys.Usr.Banners(u2.K)));
			Banner b = new Banner() { UsrK = u1.K };
			b.Update();
			Assert.IsNotNull(Caching.Instances.Main.Get(Caching.CacheKeys.Usr.Banners(u1.K)));
			Assert.IsNull(Caching.Instances.Main.Get(Caching.CacheKeys.Usr.Banners(u2.K)));
			
			b.UsrK= u2.K;
			b.Update();
			Assert.IsNotNull(Caching.Instances.Main.Get(Caching.CacheKeys.Usr.Banners(u1.K)));
			Assert.IsNotNull(Caching.Instances.Main.Get(Caching.CacheKeys.Usr.Banners(u2.K)));
			
			
		}
		protected void Page_Load(object sender, EventArgs e)
		{
			Usr.KickUserIfNotLoggedIn();
			if (!Usr.Current.IsAdmin)
			{
				throw new DsiUserFriendlyException("You can't view these details.");
			}

			ContainerPage.SetPageTitle("Promoter administration - Advanced banner options");
			
			if (!IsPostBack)
			{
				Banner b = new Banner(BannerK);
				SetUpCheckBoxSelectedStatuses(b.TargettingPropertiesToExclude);
				SetFrequencyCappingValue(b.FrequencyCapPerIdentifierPerDay);
				txtPriority.Text = b.Priority.ToString();
				cbAlwaysShow.Checked = b.AlwaysShow;
				if (b.DisplayDuration == null)
				{
					this.uiUseDefaultBannerRotationRadio.Checked = true;
					this.uiCustomRotationValue.Text = Common.Settings.DefaultBannerDurationInSeconds.ToString();
					this.uiCustomRotationValue.Style["visibility"] = "hidden";
				}
				else
				{
					this.uiUseCustomBannerRotationRadio.Checked = true;
					this.uiCustomRotationValue.Text = b.DisplayDuration.ToString();
					this.uiCustomRotationValue.Style["visibility"] = "";
				}
			}
			
		}
예제 #3
0
		protected void Page_Load(object sender, EventArgs e)
		{
			Banner b = new Banner(ContainerPage.Url[0]);
			if (b.PromoterK == 7950 || (Vars.DevEnv && b.PromoterK == 1622))
			{
				b.RegisterClick();
				//do something in here to register a click with unruly
				if (Usr.Current != null)
				{

					try
					{
						Thread t = new Thread(int.Parse(b.LinkUrl.Substring(b.LinkUrl.LastIndexOf('-') + 1)));


						Group g = t.Group;// new Group(4307);
						GroupUsr gu = g.GetGroupUsr(Usr.Current);

						if (gu == null || !g.IsMember(gu))
						{
							try
							{
								g.Join(Usr.Current, gu);
							}
							catch { }
						}
					}
					catch { }

				}
				Response.Redirect(b.LinkUrl.Replace("http://www.dontstayin.com", string.Empty));
			}
			else
				throw new Exception();
		}
		public override double GetNumberOfTrafficBlocksBetweenDates(DateTime startDateTime, DateTime endDateTime, Banner.Positions position)
		{
			return Caching.Instances.Main.GetWithLocalCaching(
				String.Format("GetNumberOfTrafficBlocksBetweenDates(startDateTime={0}, endDateTime={1}, position={2}, UseBannerTypeStats={3})", startDateTime, endDateTime, position, Settings.UsePerBannerTypeStats),
				() => this.GetPredictedCountOfLogItemBetweenDates(Banner.GetLogItemTypeFromPositionType(position), startDateTime, endDateTime),
				5.Minutes(),
				1.Days()
			);
		}
예제 #5
0
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (ContainerPage.Url["BannerK"].IsInt)
			{
				Banner b = new Banner(ContainerPage.Url["BannerK"]);

				b.RegisterClick();
				Response.Redirect(b.LinkTargetUrl);
			}
		}
예제 #6
0
		private void Page_Init(object sender, System.EventArgs e)
		{
			try
			{
				if (CountryK == 225)
				{
					Banner b = new Banner(9110);
					b.RegisterHit();
				}
			}
			catch { }

			if (Request.QueryString["ChangeHomeCountryK"] != null)
			{
				int newFilterK = int.Parse(Request.QueryString["ChangeHomeCountryK"]);
				Country.FilterK = newFilterK;
			}
		}
		private long GetTotalRequiredImpressions(Banner.Positions position, DateTime date)
		{
			return Caching.Instances.Main.Get("RequiredImpressionsForBannerImpressionStats" + date.ToString("yyyymmdd") + position.ToString(), () =>
			{
				long desiredHits = 0;
				using (new Common.General.Context<Clock>(() => Common.Time.Clock, (c) => Common.Time.Clock = c, new FixedClock(date)))
				{
					Query q = new Query();
					q.QueryCondition = new And(Banner.IsLiveQ, new Q(Banner.Columns.Position, position));
					BannerSet bs = new BannerSet(q);

					foreach (Banner b in bs)
					{
						for (Timeslot timeslot = new Timeslot(date); timeslot.StartTime < date.AddDays(1); timeslot = timeslot.GetNextTimeslot())
						{
							BannerTimeslotInfoWithDesiredHits bannerTimeslotInfo = new BannerTimeslotInfoWithDesiredHits(b, timeslot);
							desiredHits += bannerTimeslotInfo.DesiredHits;
						}
					}
				}
				return desiredHits;
				}
			);
		}
예제 #8
0
		void GetBannerFromBannerServer()
		{
			Bobs.BannerServer.Server server = new Bobs.BannerServer.Server();
			BannerDataHolder banner = server.GetBanner(Position, Vars.UrlScheme.Equals("https"), identity, ((Master.DsiPage)Page).BannerRequestRules);
			if (banner != null)
			{
				BannerServerBanner = new Banner(banner.K);
			}

			//if ((mainThread.ThreadState & System.Threading.ThreadState.WaitSleepJoin) == System.Threading.ThreadState.WaitSleepJoin)
			//{
			//    mainThread.Interrupt();
			//}
		}
예제 #9
0
		void ShowBanner(Banner banner)
		{

			if (banner != null)
			{
				if (Vars.UrlScheme.Equals("https") && banner.DisplayType.Equals(Banner.DisplayTypes.CustomHtml))
				{
					EmitDefaultText();
				}
				else
				{
					AddPromoterBanner(banner, true);
				}

			}
			else if (ThreadSafeRandom.NextDouble() < (double.Parse(Common.Settings.HouseBannersAsPercentageOfNullBanners.Replace("%", "")) / 100.0))
			{
				try
				{
					Query q = new Query();
					q.CacheDuration = TimeSpan.FromHours(1);
					q.QueryCondition = new And(
						new Q(Banner.Columns.PromoterK, 1622),
						new Q(Banner.Columns.BannerFolderK, 5879),
						new Q(Banner.Columns.Position, this.Position),
						new Q(Banner.Columns.StatusArtwork, true)
						);
					BannerSet bs = new BannerSet(q);
					if (bs.Count > 0)
					{
						AddPromoterBanner(bs[ThreadSafeRandom.Next(bs.Count)], true);
					}
					else
					{
						EmitDefaultText();
					}
				}
				catch 
				{
					EmitDefaultText();
				}
				Timeslots.GetCurrentTimeslot().TotalNotShown().Increment();

			}
			else if( Common.Settings.UseGoogleAds && !(Vars.UrlScheme.Equals("https") ))
			{
				EmitGoogleTag();
			}
			else
			{
				EmitDefaultText();
				Timeslots.GetCurrentTimeslot().TotalNotShown().Increment();
			}

			
		}
예제 #10
0
		private void SetDemograpicsBitsInfoType(bool value, Banner.TargettingProperty trueProperty, Banner.TargettingProperty falseProperty)
		{
			Add(value ? trueProperty : falseProperty);
		}
예제 #11
0
		protected override void OnPreRender(EventArgs e)
		{
			base.OnPreRender(e);

			if (DontRenderBannerBecauseAjaxPartialPageRequestOrCrawler)
			{
				this.Visible = false;
				return;
			}
			this.uiPosition.Value = ((int)Position).ToString();
			
			//if (Position == Banner.Positions.Hotbox && HttpContext.Current != null && (HttpContext.Current.Request.Url.PathAndQuery == "/groups/fosters" || HttpContext.Current.Request.Url.PathAndQuery == "/pages/shadownap"))
			//{
			//    BannerServerBanner = new Banner(11228);
			//    ShowBanner(BannerServerBanner);
			//}
			//else 

			
			if (ShowRoadblockedGroupPageBanner)
			{
				if (Position == Banner.Positions.Hotbox)
				{
					if (Common.Settings.RoadblockOnGroupHotboxBannerK > 0)
						BannerServerBanner = new Banner(Common.Settings.RoadblockOnGroupHotboxBannerK);
					else
						BannerServerBanner = null;
				}
				else if (Position == Banner.Positions.Leaderboard)
				{
					if (Common.Settings.RoadblockOnGroupLeaderboardBannerK > 0)
						BannerServerBanner = new Banner(Common.Settings.RoadblockOnGroupLeaderboardBannerK);
					else
						BannerServerBanner = null;
				}
				else if (Position == Banner.Positions.Skyscraper)
				{
					if (Common.Settings.RoadblockOnGroupSkyscraperBannerK > 0)
						BannerServerBanner = new Banner(Common.Settings.RoadblockOnGroupSkyscraperBannerK);
					else
						BannerServerBanner = null;
				}
			}
			else if (ShowLinkedWootUkBanner)
			{
				if (Position == Banner.Positions.Hotbox)
				{
					BannerServerBanner = new Banner(Common.Settings.WootUkLinkedMpuBannerK);
				}
				else if (Position == Banner.Positions.Leaderboard)
				{
					BannerServerBanner = new Banner(Common.Settings.WootUkLinkedLeaderboardBannerK);
				}
			}
			else if (ShowLinkedBanner)
			{
				if (Position == Banner.Positions.Hotbox)
				{
					BannerServerBanner = new Banner(Common.Settings.LinkedBannersHotboxBannerK);
				}
				else if (Position == Banner.Positions.Leaderboard)
				{
					BannerServerBanner = new Banner(Common.Settings.LinkedBannersLeaderboardBannerK);
				}
			}
			else if (ShowUsaLeaderboard)
			{
				BannerServerBanner = new Banner(Common.Settings.UsaMainLeaderboardBannerK);
			}
			else if (ShowUsaMpu)
			{
				BannerServerBanner = new Banner(Common.Settings.UsaMainMpuBannerK);
			}
			else if (ShowWootUkLeaderboard)
			{
				BannerServerBanner = new Banner(Common.Settings.WootUkMainLeaderboardBannerK);
			}
			else if (ShowWootUkMpu)
			{
				BannerServerBanner = new Banner(Common.Settings.WootUkMainMpuBannerK);
			}
			else
			{
				GiveBannerServerAChanceToCompleteWithinAcceptableTimeLimit();
			}

			if (this.BannerServerBanner != null)
			{
				this.uiK.Value = this.BannerServerBanner.K.ToString();
				this.uiMusicTypes.Value = String.Join(",", ((DsiPage)this.Page).RelevantMusic.Select(mt => mt.ToString()).ToArray());
				this.uiPlaceKs.Value = String.Join(",", ((DsiPage)this.Page).RelevantPlaces.Select(pK => pK.ToString()).ToArray());
				this.uiDuration.Value = ((this.BannerServerBanner.DisplayDuration ?? Common.Settings.DefaultBannerDurationInSeconds) * 1000).ToString();
				this.uiInactivityTimeoutDuration.Value = (Common.Settings.InactivityTimeoutDuration * 1000).ToString();
				this.uiClickHelperLeft.Value = ClickHelperLeftOffset.ToString();
				this.uiClickHelperTop.Value = ClickHelperTopOffset.ToString();
			}

			ShowBanner(BannerServerBanner);
		}
예제 #12
0
		public static IBob Get(Model.Entities.ObjectType type, int k)
		{
			IBob b = null;
			bool wrongType = false;
			try
			{
				switch (type)
				{
					case Model.Entities.ObjectType.Photo:
						b = new Photo(k);
						break;
					case Model.Entities.ObjectType.Event:
						b = new Event(k);
						break;
					case Model.Entities.ObjectType.Venue:
						b = new Venue(k);
						break;
					case Model.Entities.ObjectType.Place:
						b = new Place(k);
						break;
					case Model.Entities.ObjectType.Thread:
						b = new Thread(k);
						break;
					case Model.Entities.ObjectType.Country:
						b = new Country(k);
						break;
					case Model.Entities.ObjectType.Article:
						b = new Article(k);
						break;
					case Model.Entities.ObjectType.Para:
						b = new Para(k);
						break;
					case Model.Entities.ObjectType.Brand:
						b = new Brand(k);
						break;
					case Model.Entities.ObjectType.Promoter:
						b = new Promoter(k);
						break;
					case Model.Entities.ObjectType.Usr:
						b = new Usr(k);
						break;
					case Model.Entities.ObjectType.Region:
						b = new Region(k);
						break;
					case Model.Entities.ObjectType.Gallery:
						b = new Gallery(k);
						break;
					case Model.Entities.ObjectType.Group:
						b = new Group(k);
						break;
					case Model.Entities.ObjectType.Banner:
						b = new Banner(k);
						break;
					case Model.Entities.ObjectType.GuestlistCredit:
						b = new GuestlistCredit(k);
						break;
					case Model.Entities.ObjectType.Ticket:
						b = new Ticket(k);
						break;
					case Model.Entities.ObjectType.Invoice:
						b = new Invoice(k);
						break;
					case Model.Entities.ObjectType.InsertionOrder:
						b = new InsertionOrder(k);
						break;
					case Model.Entities.ObjectType.CampaignCredit:
						b = new CampaignCredit(k);
						break;
					case Model.Entities.ObjectType.UsrDonationIcon:
						b = new UsrDonationIcon(k);
						break;
					default:
						wrongType = true;
						b = null;
						break;
				}
			}
			catch { }
			if (wrongType)
				throw new Exception("Bob.Get attempted to get " + type.ToString() + " - can't do it!!! DUH!");
			return b;
		}
예제 #13
0
		internal IdentityPropertyRules Add(Banner.TargettingProperty targettingBit)
		{
			values[(int)targettingBit] = true;
			return this;
		}
예제 #14
0
		public static Misc UploadFile(HtmlInputFile inputFile, Usr uploadUsr, Promoter promoter, Banner banner)
		{
			return UploadFile(inputFile, uploadUsr, promoter, banner, "");
		}
예제 #15
0
		public static int GetCreditsPerDay(Banner.ExposureLevels exposureLevel)
		{
			if (exposureLevel.Equals(Banner.ExposureLevels.Light))
				return 15;
			else if (exposureLevel.Equals(Banner.ExposureLevels.Medium))
				return 30;
			else if (exposureLevel.Equals(Banner.ExposureLevels.Heavy))
				return 50;
			else
				return 0;
		}
예제 #16
0
		public bool CanDelete(Banner BannerToDelete)
		{
			if (this.IsAdmin)
				return true;
			else if (this.K == BannerToDelete.UsrK)
				return true;
			else if (BannerToDelete.Promoter != null && this.IsPromoterK(BannerToDelete.PromoterK))
				return true;
			else
				return false;
		}
예제 #17
0
		public void AddPromoterBanner(Banner banner, bool registerHit)
		{
			#region Add promoter banner
			GenericBanner bControl = (GenericBanner)this.LoadControl("/Controls/Banners/GenericBanner.ascx");

			if (registerHit)
				banner.RegisterHit();

			bControl.CurrentBanner = banner;
			bControl.ClickHelperLeftOffset = ClickHelperLeftOffset;
			bControl.ClickHelperTopOffset = ClickHelperTopOffset;
			bControl.ShowClickHelper = ShowClickHelper;
			bControl.Bind();
			this.uiBanner.Controls.Add(bControl);
			#endregion
		}
예제 #18
0
		public static void Log(int bannerK, Banner.Positions position, DateTime date, int hits, int uniqueHits, int clicks)
		{
		
			if (Common.Settings.BatchBannerStatUpdates)
			{
				BannerTotalStat stat = null;
				lock (bannerStatTemp)
				{
					if (bannerStatTemp.ContainsKey(bannerK))
					{
						stat = bannerStatTemp[bannerK];
					}
					else
					{
						stat = new BannerTotalStat() { BannerK = bannerK };
						bannerStatTemp.Add(bannerK, stat);
					}
					System.Threading.Monitor.Enter(stat);
				}
				try
				{
					stat.Clicks += clicks;
					stat.Hits += hits;
					stat.UniqueVisitors += uniqueHits;
				}
				finally
				{
					System.Threading.Monitor.Exit(stat);
				}
				lock (lastSavedToDatabaseLock)
				{
					if (lastSavedToDatabase < Time.Now.Subtract(Time.Minutes(1)))
					{
						lock (bannerStatTemp)
						{
							BannerTotalStat[] bannerStats = new BannerTotalStat[bannerStatTemp.Count];
							bannerStatTemp.Values.CopyTo(bannerStats, 0);
							bannerStatTemp.Clear();
							System.Threading.Thread thread = Utilities.GetSafeThread(() => SaveStatsToDatabase(bannerStats, lastSavedToDatabase));
							thread.Start();
							lastSavedToDatabase = Time.Now;
						}
					}
				}
			}
			else
			{
				Bobs.StoredProcedures.Bobs.BannerStat.Log.Execute(bannerK, DateTime.Today, hits, uniqueHits, clicks);
			}
		}
		private static Bobs.Log.Items GetLogItemTypeFromPositionType(Banner.Positions position)
		{
			switch (position)
			{
				case Bobs.Banner.Positions.Hotbox: 
				case Bobs.Banner.Positions.Leaderboard:
				case Bobs.Banner.Positions.Skyscraper: return Log.Items.DsiPageRender;
				case Bobs.Banner.Positions.PhotoBanner: return Log.Items.PhotoImpressions;
				case Bobs.Banner.Positions.EmailBanner: return Log.Items.EmailsSent;
				default: throw new Exception("Unexpected banner position.");
			}
		}
예제 #20
0
		public UrlInfo(string path, HttpBrowserCapabilities browser, bool disableRedirects, bool isMixmagVote, bool isMixmagGreatest)
		{
			this.IsMobile = browser.IsMobileDevice;
			this.ScreenWidth = browser.ScreenPixelsWidth;
			this.ScreenHeight = browser.ScreenPixelsHeight;

			this.DisableAllActions = disableRedirects;
			this.IsMixmagVote = isMixmagVote;
			this.IsMixmagGreatest = isMixmagGreatest;

			if (Usr.Current != null && Usr.Current.Banned)
			{
				PageType = PageTypes.Blank;
				PageName = "Banned";
				return;
			}
			innerHash = new Hashtable();
			innerIndex = new Hashtable();

			#region strip / from start and end of path
			if (path.StartsWith("/"))
				path = path.Substring(1);
			if (path.EndsWith("/"))
				path = path.Substring(0, path.Length - 1);
			#endregion

			string[] urlParts = path.Split('/');

			#region If there's a dot in the last part, handle this file with the default HttpHandler
			if (urlParts[urlParts.Length - 1].Contains("."))
			{
				if (urlParts[urlParts.Length - 1].EndsWith(".rss"))
				{
					IsRss = true;
					urlParts[urlParts.Length - 1] = urlParts[urlParts.Length - 1].Substring(0, urlParts[urlParts.Length - 1].IndexOf("."));
				}
				else
				{
					OverrideHttpHandler = true;
					return;
				}
			}
			#endregion

			#region custom redirects
			if (!DisableAllActions)
			{
				if (urlParts.Length == 1 && urlParts[0] == "facebook")
				{
					Log.Increment(Log.Items.FacebookUrlShortcut);

					HttpContext.Current.Response.Redirect("http://www.facebook.com/pages/dontstayincom/95813938222");
				}

				if (urlParts.Length == 1 && urlParts[0] == "twitter")
				{
					Log.Increment(Log.Items.TwitterUrlShortcut);

					HttpContext.Current.Response.Redirect("http://twitter.com/dontstayin_com");
				}

				if (urlParts.Length == 1 && urlParts[0] == "comps")
				{
					Log.Increment(Log.Items.CompsUrlShortcut);

					string[] par = { };
					HttpContext.Current.Response.Redirect(Vars.GetArchiveUrl(DateTime.Today.Year, DateTime.Today.Month, 0, Model.Entities.ArchiveObjectType.Comp, par, null));
				}

				if (urlParts.Length == 1 && urlParts[0] == "ibizarocks")
				{
					Log.Increment(Log.Items.IbizaRocksUrlShortcut);
					try
					{
						Group ibizaRocksGroup = new Group(10992);
						HttpContext.Current.Response.Redirect(ibizaRocksGroup.Url());
					}
					catch { }
				}

				if (urlParts.Length == 1 && urlParts[0] == "schmucks")
				{
					Log.Increment(Log.Items.SchmucksUrlShortcut);
					try
					{
						Group schmucksGroup = new Group(36543);
						HttpContext.Current.Response.Redirect(schmucksGroup.Url());
					}
					catch { }
				}

				if (urlParts.Length == 1 && urlParts[0] == "tickets")
				{
					try
					{
						Banner b = new Banner(12965);
						b.RegisterClick();
						HttpContext.Current.Response.Redirect(b.LinkTargetUrl);
					}
					catch { }
				}

				if (urlParts.Length == 1 && urlParts[0] == "free")
				{
					try
					{
						Banner b = new Banner(13287);
						b.RegisterClick();
						HttpContext.Current.Response.Redirect(b.LinkTargetUrl);
					}
					catch { }
				}

				if (urlParts.Length == 1 && urlParts[0] == "mixmag")
				{
					try
					{
						Banner b = new Banner(12966);
						b.RegisterClick();
						HttpContext.Current.Response.Redirect(b.LinkTargetUrl);
					}
					catch { }
				}

				if (urlParts.Length == 1 && urlParts[0] == "tick-em-off")
				{
					try
					{
						Group g = new Group(33961);
						HttpContext.Current.Response.Redirect(g.Url());
					}
					catch { }
				}

				if (urlParts.Length == 1 && urlParts[0] == "cream-tickets")
				{
					try
					{
						Banner b = new Banner(13150);
						b.RegisterClick();
						HttpContext.Current.Response.Redirect(b.LinkTargetUrl);
					}
					catch { }
				}

				if (urlParts.Length == 1 && urlParts[0] == "ibizaholiday")
				{
					try
					{
						Banner b = new Banner(13902);
						b.RegisterClick();
						HttpContext.Current.Response.Redirect(b.LinkTargetUrl);
					}
					catch { }
				}

				//13921 north
				if (urlParts.Length == 1 && urlParts[0] == "mixmagfreenorth")
				{
					try
					{
						Banner b = new Banner(13921);
						b.RegisterClick();
						HttpContext.Current.Response.Redirect(b.LinkTargetUrl);
					}
					catch { }
				}

				//13922 south
				if (urlParts.Length == 1 && urlParts[0] == "mixmagfreesouth")
				{
					try
					{
						Banner b = new Banner(13922);
						b.RegisterClick();
						HttpContext.Current.Response.Redirect(b.LinkTargetUrl);
					}
					catch { }
				}
			}
			#endregion

			IsAjaxRequest = (HttpContext.Current.Request.Headers["x-microsoftajax"] != null);

			int currentIndex = 0;

			if (IsMixmagVote)
			{
				if (urlParts.Length > 0 && urlParts[0].Length > 0)
				{
					PageType = PageTypes.MixmagVote;
					if (urlParts[currentIndex].IsNumeric())
					{
						PageName = "Vote";
						ProcessParamParts(urlParts, currentIndex);
					}
					else
					{
						PageName = urlParts[currentIndex];
						ProcessParamParts(urlParts, currentIndex + 1);
					}
				}
				else
				{
					PageType = PageTypes.MixmagVote;
					PageName = "Home";
				}
			}
			else if (IsMixmagGreatest)
			{
				if (urlParts.Length > 0 && urlParts[0].Length > 0)
				{
					bool fbPage = false;
					PageType = PageTypes.MixmagGreatest;
					string name = urlParts[currentIndex];
					if (name == "fb")
					{
						fbPage = true;
						currentIndex++;
						name = urlParts[currentIndex];
					}
					MixmagGreatestDjSet djs = new MixmagGreatestDjSet(new Query(new Q(MixmagGreatestDj.Columns.UrlName, name)));
					if (djs.Count > 0)
					{
						MixmagGreatestDjK = djs[0].K;
						PageName = fbPage ? "Fb" : "Home";
						ProcessParamParts(urlParts, currentIndex);
					}
					else
					{
						PageName = urlParts[currentIndex];
						ProcessParamParts(urlParts, currentIndex + 1);
					}
				}
				else
				{
					PageType = PageTypes.MixmagGreatest;
					PageName = "Home";
				}
			}
			else if (Vars.DevEnv && ((IsMobile && Prefs.Current["ForceMobile"] != "full") || Prefs.Current["ForceMobile"] == "mobile"))
			{
			    PageType = PageTypes.Mobile;
			    PageName = "Home";
			}
			else
			{
				if (ProcessLoginPart(ref currentIndex, urlParts))
					return;

				if (ProcessCustomPage(currentIndex, urlParts))
					return;

				bool searchMore = true;
				int count = 0;
				while (currentIndex < urlParts.Length && searchMore && count < 50)
				{
					count++;

					UrlPartTypes thisType = ProcessFilterPart(ref currentIndex, urlParts);

					if (thisType.Equals(UrlPartTypes.Application))
						searchMore = false;
				}

				ProcessParamParts(urlParts, currentIndex);

				if (PageName == null || PageName.Length == 0)
				{
					PageType = PageTypes.Pages;
					PageName = "Home";
				}
			}

			

			

		}
예제 #21
0
		public static Misc UploadFile(HtmlInputFile inputFile, Usr uploadUsr, Promoter promoter, Banner banner, string folder, List<string> acceptedFileExtensions)
		{
			if (inputFile.PostedFile != null)
			{
				#region Upload file
				Misc m = new Misc();

				m.UsrK = uploadUsr.K;

				if (promoter != null)
					m.PromoterK = promoter.K;

				m.DateTime = DateTime.Now;
				m.Folder = folder;

				m.Guid = Guid.NewGuid();


				if (inputFile.PostedFile.FileName.IndexOf(".") == -1)
					m.Extention = "";
				else
					m.Extention = inputFile.PostedFile.FileName.Substring(inputFile.PostedFile.FileName.LastIndexOf(".") + 1).ToLower();

				if (m.Extention.Equals("jpeg") || m.Extention.Equals("jpe"))
					m.Extention = "jpg";

				if (!acceptedFileExtensions.Contains(m.Extention))
				{
					string listOfFileExtensions = "";
					foreach(string s in acceptedFileExtensions)
						listOfFileExtensions += s + ", ";
					throw new DsiUserFriendlyException("You can only upload " + listOfFileExtensions.Substring(0, listOfFileExtensions.Length-2) + " files with this page.");
				}

				if (promoter != null && m.Extention.Equals("swf"))
				{
					if (m.Size <= 150 * 1024)
						m.NeedsAuth = true;
				}
				
				byte[] bytes = new byte[inputFile.PostedFile.InputStream.Length];
				inputFile.PostedFile.InputStream.Read(bytes, 0, (int)inputFile.PostedFile.InputStream.Length);
				
				m.Size = inputFile.PostedFile.ContentLength;

				m.Name = inputFile.PostedFile.FileName.Substring(inputFile.PostedFile.FileName.LastIndexOf("\\") + 1);

				if (m.Extention.Equals("jpg") || m.Extention.Equals("gif") || m.Extention.Equals("png"))
				{
					using (System.Drawing.Image image = System.Drawing.Image.FromStream(new MemoryStream(bytes)))
					{
						m.Width = image.Width;
						m.Height = image.Height;
					}
				}

				m.Update();

				try
				{
					Storage.AddToStore(bytes, Storage.Stores.Pix, m.Guid, m.Extention, m, "");
				}
				catch (Exception ex)
				{
					m.Delete();
					throw ex;
				}

				if (promoter != null)
				{
					if (promoter != null && m.NeedsAuth)
					{
						Mailer adminMail = new Mailer();
						adminMail.Subject = "New files waiting to be approved!!! uploaded by" + uploadUsr.NickNameSafe;
						adminMail.To = "*****@*****.**";
						adminMail.Body += "<p>New FILES uploaded by <a href=\"[LOGIN(" + uploadUsr.Url() + ")]\">" + uploadUsr.NickNameSafe + "</a></p>";
						if (promoter != null)
							adminMail.Body += "<p>... for promoter <a href=\"[LOGIN(" + promoter.Url() + ")]\">" + promoter.Name + "</a></p>";
						adminMail.Body += "<h2>Files:</h2>";
						adminMail.Body += "<p><a href=\"" + m.Url() + "\">" + HttpUtility.HtmlEncode(m.Name) + "</a> - " + m.FileSizeString + "</p>";
						adminMail.TemplateType = Mailer.TemplateTypes.AdminNote;
						adminMail.RedirectUrl = uploadUsr.Url();
						adminMail.Send();
					}
				}

				if (banner != null)
					banner.AssignMisc(m);

				return m;

				#endregion
			}
			else
				return null;
		}
예제 #22
0
		public static Misc UploadFile(HtmlInputFile inputFile, Usr uploadUsr, Promoter promoter, Banner banner, string folder)
		{
			return UploadFile(inputFile, uploadUsr, promoter, banner, "", new List<string>(){"jpg", "gif", "swf"});
		}
예제 #23
0
		private void Page_Load(object sender, System.EventArgs e)
		{
			Banner b = new Banner(int.Parse(Request.QueryString["K"]));
			b.RegisterHit();
		}
예제 #24
0
		public CanUseAsBannerReturn CanUseAsBanner(Banner.Positions position)
		{
			CanUseAsBannerReturn ret = new CanUseAsBannerReturn();
			ret.CanUseNow = true;
			ret.CanUseAfterAdminCheck = false;
			ret.LinkTagWarning = false;

			if (position.Equals(Banner.Positions.Leaderboard))
			{
				#region Leaderboard specs
				if (this.Extention.Equals("jpg"))
				{
					if (this.Size > (150 * 1024))
					{
						ret.CanUseNow = false;
						ret.Errors.Add("File size must not be over 100KB");
					}
					if (this.Height != 90 || this.Width != 728)
					{
						ret.CanUseNow = false;
						ret.Errors.Add("Image must be 728x90 pixels");
					}
				}
				else if (this.Extention.Equals("gif"))
				{
					if (this.Size > (150 * 1024))
					{
						ret.CanUseNow = false;
						ret.Errors.Add("File size must not be over 100KB");
					}
					if (this.Height != 90 || this.Width != 728)
					{
						ret.CanUseNow = false;
						ret.Errors.Add("Image must be 728x90 pixels");
					}
					if (this.NeedsAuth)
					{
						if (ret.CanUseNow)
						{
							ret.CanUseNow = false;
							ret.CanUseAfterAdminCheck = true;
						}
					}
				}
				else if (this.Extention.Equals("swf"))
				{
					if (this.Size > (150 * 1024))
					{
						ret.CanUseNow = false;
						ret.Errors.Add("File size must not be over 100KB");
					}
					if (this.NeedsAuth)
					{
						if (ret.CanUseNow)
						{
							ret.CanUseNow = false;
							ret.CanUseAfterAdminCheck = true;
						}
					}
					else
					{
						if (!this.BannerLinkTag)
						{
							ret.LinkTagWarning = true;
						}
						if (this.BannerBroken)
						{
							ret.CanUseNow = false;
							ret.Errors.Add("One of our admins failed the banner");
							ret.BrokenError = this.BannerBrokenReason;
						}
					}
				}
				#endregion
			}
			else if (position.Equals(Banner.Positions.Hotbox))
			{
				#region Hotbox specs
				if (this.Extention.Equals("jpg"))
				{
					if (this.Size > (150 * 1024))
					{
						ret.CanUseNow = false;
						ret.Errors.Add("File size must not be over 100KB");
					}
					if ((this.Height != 191 && this.Height != 250) || (this.Width != 191 && this.Width != 300))
					{
						ret.CanUseNow = false;
						ret.Errors.Add("Image must be 300x250 pixels");
					}
				}
				else if (this.Extention.Equals("gif"))
				{
					if (this.Size > (150 * 1024))
					{
						ret.CanUseNow = false;
						ret.Errors.Add("File size must not be over 100KB");
					}
					if ((this.Height != 191 && this.Height != 250) || (this.Width != 191 && this.Width != 300))
					{
						ret.CanUseNow = false;
						ret.Errors.Add("Image must be 300x250 pixels");
					}
					if (this.NeedsAuth)
					{
						if (ret.CanUseNow)
						{
							ret.CanUseNow = false;
							ret.CanUseAfterAdminCheck = true;
						}
					}
				}
				else if (this.Extention.Equals("swf"))
				{
					if (this.Size > (150 * 1024))
					{
						ret.CanUseNow = false;
						ret.Errors.Add("File size must not be over 100KB");
					}
					if (this.NeedsAuth)
					{
						if (ret.CanUseNow)
						{
							ret.CanUseNow = false;
							ret.CanUseAfterAdminCheck = true;
						}
					}
					else
					{
						if (!this.BannerLinkTag)
						{
							ret.LinkTagWarning = true;
						}
						if (this.BannerBroken)
						{
							ret.CanUseNow = false;
							ret.Errors.Add("One of our admins failed the banner");
							ret.BrokenError = this.BannerBrokenReason;
						}
					}
				}
				#endregion
			}
			else if (position.Equals(Banner.Positions.Skyscraper))
			{
				#region Skyscraper specs
				if (this.Extention.Equals("jpg"))
				{
					if (this.Size > (150 * 1024))
					{
						ret.CanUseNow = false;
						ret.Errors.Add("File size must not be over 100KB");
					}
					//XMAS
					if (this.Height != 250 || this.Width != 300)
					{
						ret.CanUseNow = false;
						ret.Errors.Add("Image must be 300x250 pixels");
					}
					//if (this.Height != 600 || (this.Width != 120 && this.Width != 160 && this.Width != 300))
					//{
					//    ret.CanUseNow = false;
					//    ret.Errors.Add("Image must be 300x600, 160x600, 120x600 pixels");
					//}
				}
				else if (this.Extention.Equals("gif"))
				{
					if (this.Size > (150 * 1024))
					{
						ret.CanUseNow = false;
						ret.Errors.Add("File size must not be over 100KB");
					}
					//XMAS
					if (this.Height != 250 || this.Width != 300)
					{
						ret.CanUseNow = false;
						ret.Errors.Add("Image must be 300x250 pixels");
					}
					//if (this.Height != 600 || (this.Width != 120 && this.Width != 160 && this.Width != 300))
					//{
					//    ret.CanUseNow = false;
					//    ret.Errors.Add("Image must be 300x600, 160x600, 120x600 pixels");
					//}
					if (this.NeedsAuth)
					{
						if (ret.CanUseNow)
						{
							ret.CanUseNow = false;
							ret.CanUseAfterAdminCheck = true;
						}
					}
				}
				else if (this.Extention.Equals("swf"))
				{
					if (this.Size > (150 * 1024))
					{
						ret.CanUseNow = false;
						ret.Errors.Add("File size must not be over 100KB");
					}
					if (this.NeedsAuth)
					{
						if (ret.CanUseNow)
						{
							ret.CanUseNow = false;
							ret.CanUseAfterAdminCheck = true;
						}
					}
					else
					{
						if (!this.BannerLinkTag)
						{
							ret.LinkTagWarning = true;
						}
						if (this.BannerBroken)
						{
							ret.CanUseNow = false;
							ret.Errors.Add("One of our admins failed the banner");
							ret.BrokenError = this.BannerBrokenReason;
						}
					}
				}
				#endregion
			}
			else if (position.Equals(Banner.Positions.PhotoBanner))
			{
				#region PhotoBanner specs
				if (this.Extention.Equals("jpg"))
				{
					if (this.Size > (30 * 1024))
					{
						ret.CanUseNow = false;
						ret.Errors.Add("File size must not be over 20KB");
					}
					if (this.Height != 50 || this.Width != 450)
					{
						ret.CanUseNow = false;
						ret.Errors.Add("Image must be 450x50 pixels");
					}
				}
				else if (this.Extention.Equals("gif"))
				{
					if (this.Size > (30 * 1024))
					{
						ret.CanUseNow = false;
						ret.Errors.Add("File size must not be over 20KB");
					}
					if (this.Height != 50 || this.Width != 450)
					{
						ret.CanUseNow = false;
						ret.Errors.Add("Image must be 450x50 pixels");
					}
					if (this.NeedsAuth)
					{
						if (ret.CanUseNow)
						{
							ret.CanUseNow = false;
							ret.CanUseAfterAdminCheck = true;
						}
					}
				}
				else if (this.Extention.Equals("swf"))
				{
					if (this.Size > (30 * 1024))
					{
						ret.CanUseNow = false;
						ret.Errors.Add("File size must not be over 20KB");
					}
					if (this.NeedsAuth)
					{
						if (ret.CanUseNow)
						{
							ret.CanUseNow = false;
							ret.CanUseAfterAdminCheck = true;
						}
					}
					else
					{
						if (!this.BannerLinkTag)
						{
							ret.LinkTagWarning = true;
						}
						if (this.BannerBroken)
						{
							ret.CanUseNow = false;
							ret.Errors.Add("One of our admins failed the banner");
							ret.BrokenError = this.BannerBrokenReason;
						}
					}
				}
				#endregion
			}
			else if (position.Equals(Banner.Positions.EmailBanner))
			{
				#region EmailBanner specs
				if (this.Extention.Equals("jpg"))
				{
					if (this.Size > (40 * 1024))
					{
						ret.CanUseNow = false;
						ret.Errors.Add("File size must not be over 30KB");
					}
					if (this.Height != 51 || this.Width != 331)
					{
						ret.CanUseNow = false;
						ret.Errors.Add("Image must be 331x51 pixels");
					}
				}
				else if (this.Extention.Equals("gif"))
				{
					if (this.Size > (40 * 1024))
					{
						ret.CanUseNow = false;
						ret.Errors.Add("File size must not be over 30KB");
					}
					if (this.Height != 51 || this.Width != 331)
					{
						ret.CanUseNow = false;
						ret.Errors.Add("Image must be 331x51 pixels");
					}
					if (this.NeedsAuth)
					{
						if (ret.CanUseNow)
						{
							ret.CanUseNow = false;
							ret.CanUseAfterAdminCheck = true;
						}
					}
				}
				else if (this.Extention.Equals("swf"))
				{
					ret.CanUseNow = false;
					ret.Errors.Add("Flash banners not supported in emails");
				}
				#endregion
			}
			return ret;
		}
예제 #25
0
		public bool CanEdit(Banner b)
		{
			if (this.IsAdmin)
				return true;
			else if (this.K == b.UsrK)
				return true;
			else if (b.Promoter != null && this.IsPromoterK(b.PromoterK))
				return true;
			else
				return false;
		}
예제 #26
0
		int GetCreditsPerDay(Banner.ExposureLevels exposureLevel)
		{
			return Banner.GetCreditsPerDay(exposureLevel);
		}
예제 #27
0
		//protected void GenBannerStats_Click(object sender, EventArgs eventArgs)
		//{
		//    Banner.GeneratePositionStats();
		//}
		#endregion

		#region UpdateOldDBInvoices_Click
		public void UpdateOldDBInvoices_Click(object o, System.EventArgs e)
		{
			Cambro.Web.Helpers.WriteAlertHeader();

			Cambro.Web.Helpers.WriteAlert("Selecting xxx...", 1);

			Query InvoiceQuery = new Query();
			InvoiceQuery.OrderBy = new OrderBy(Invoice.Columns.K, OrderBy.OrderDirection.Ascending);

			InvoiceSet bs = new InvoiceSet(InvoiceQuery);

			for (int count = 0; count < bs.Count; count++)
			{
				Invoice invoice = bs[count];

				try
				{
					invoice.Type = Invoice.Types.Invoice;
					invoice.IsImmediateCreditCardPayment = true;
					invoice.ActionUsrK = invoice.UsrK;
					invoice.VatCode = Invoice.VATCodes.T1;
					decimal invoicePrice = 0;
					decimal invoiceVat = 0;
					decimal invoiceTotal = 0;

					foreach (InvoiceItem invoiceItem in invoice.Items)
					{
						//invoiceItem.Price = Math.Round(invoiceItem.Price, 2);
						//invoiceItem.Vat = Math.Round(invoiceItem.Vat, 2);
						//invoiceItem.Total = Math.Round(invoiceItem.Total, 2);

						invoicePrice += invoiceItem.Price;
						invoiceVat += invoiceItem.Vat;
						invoiceTotal += invoiceItem.Total;

						if (invoiceItem.Type == InvoiceItem.Types.CharityDonation)
							invoiceItem.VatCode = InvoiceItem.VATCodes.T9;
						else if(invoiceItem.Vat.Equals(0))
							invoiceItem.VatCode = InvoiceItem.VATCodes.T0;
						else
							invoiceItem.VatCode = InvoiceItem.VATCodes.T1;

						if (invoiceItem.Type == InvoiceItem.Types.Banner || invoiceItem.Type == InvoiceItem.Types.BannerEmail || invoiceItem.Type == InvoiceItem.Types.BannerHotbox
							|| invoiceItem.Type == InvoiceItem.Types.BannerPhoto || invoiceItem.Type == InvoiceItem.Types.BannerSkyscraper || invoiceItem.Type == InvoiceItem.Types.BannerTop)
						{
							try
							{
								Banner banner = new Banner(invoiceItem.KeyData);
								invoiceItem.RevenueStartDate = banner.FirstDay;
								invoiceItem.RevenueEndDate = banner.LastDay;
							}
							catch (Exception)
							{ }
						}
						else
						{
							invoiceItem.RevenueStartDate = invoice.CreatedDateTime;
							invoiceItem.RevenueEndDate = invoice.CreatedDateTime;
						}
						invoiceItem.Update();
					}

					invoice.Price = Math.Round(invoicePrice,2);
					invoice.Vat = Math.Round(invoiceVat,2);
					invoice.Total = Math.Round(invoiceTotal, 2);

					if (invoice.DueDateTime.Equals(DateTime.MinValue))
						invoice.DueDateTime = invoice.CreatedDateTime.AddDays(30);

					invoice.UpdateAndSetPaidStatus();

					// If there arent transfers paying for this invoices yet, then create them.
					decimal amountPaid = invoice.AmountPaid;
					if (Math.Round(invoice.Total,2) > Math.Round(amountPaid,2))
					{
						InvoiceTransferSet invoiceTransferSet = new InvoiceTransferSet(new Query(new Q(InvoiceTransfer.Columns.InvoiceK, invoice.K)));
						if (invoiceTransferSet.Count == 0)
						{
							Transfer transfer = new Transfer();
							transfer.ActionUsrK = invoice.UsrK;
							transfer.Amount = Math.Round(invoice.Total - amountPaid, 2);
							transfer.DateTimeComplete = invoice.CreatedDateTime;
							transfer.DateTimeCreated = invoice.CreatedDateTime;
							transfer.Method = Transfer.Methods.Card;
							transfer.AddNote("Autogenerated Transfer to create transfer for old system invoice.", "System");
							transfer.PromoterK = invoice.PromoterK;
							transfer.Status = Transfer.StatusEnum.Success;
							transfer.Type = Transfer.TransferTypes.Payment;
							transfer.UsrK = invoice.UsrK;
							// Will be fully applied
							transfer.IsFullyApplied = true;

							transfer.CardAddress1 = invoice.Address;
							transfer.CardName = invoice.Name;
							transfer.CardPostcode = invoice.Postcode;

							transfer.Update();

							InvoiceTransfer invoiceTransfer = new InvoiceTransfer();
							invoiceTransfer.InvoiceK = invoice.K;
							invoiceTransfer.TransferK = transfer.K;
							invoiceTransfer.Amount = transfer.Amount;

							invoiceTransfer.Update();

							invoice.UpdateAndSetPaidStatus();
						}
					}
					invoice.PaidDateTime = invoice.CreatedDateTime;
					invoice.Update();
					if (count % 10 == 0)
						Cambro.Web.Helpers.WriteAlert("Done " + count + "/" + bs.Count, 2);
				}
				catch (Exception ex)
				{
					Cambro.Web.Helpers.WriteAlert("Exception " + count + "/" + bs.Count + " - " + ex.ToString(), 3);
				}

				bs.Kill(count);
			}
			Cambro.Web.Helpers.WriteAlert("Done!", 3);
			Cambro.Web.Helpers.WriteAlertFooter();
		}
예제 #28
0
		protected void SaveToDatabase()
		{
			if (Page.IsValid)
			{

				Banner b;
				if (CurrentBanner == null)
				{
					Query q = new Query();
					q.QueryCondition = new Q(Banner.Columns.DuplicateGuid, (Guid)ViewState["BannerDuplicateGuid"]);
					BannerSet bs = new BannerSet(q);
					if (bs.Count == 0)
					{
						b = new Banner();
						b.UsrK = Usr.Current.K;
						b.StatusEnabled = true;
						//b.DateLastHit = DateTime.Today;
						b.PromoterK = CurrentPromoter.K;
						b.DuplicateGuid = (Guid)ViewState["BannerDuplicateGuid"];
					}
					else
					{
						Response.Redirect(bs[0].Url());
						return;
					}
				}
				else
				{
					b = CurrentBanner;
				}

				if (((IBuyableCredits)b).IsLocked)
					throw new DsiUserFriendlyException("It looks we're processing a payment for this banner... If not - wait a minute before trying again.");

				#region Link
				b.LinkTarget = GetSelectedLinkTarget();
				b.EventK = b.LinkTarget.Equals(Banner.LinkTargets.Event) ? CurrentEvent.K : 0;
				b.BrandK = b.LinkTarget.Equals(Banner.LinkTargets.Brand) || b.LinkTarget.Equals(Banner.LinkTargets.TicketsBrand) ? CurrentBrand.K : 0;
				b.VenueK = b.LinkTarget.Equals(Banner.LinkTargets.Venue) || b.LinkTarget.Equals(Banner.LinkTargets.TicketsVenue) ? CurrentVenue.K : 0;
				b.LinkUrl = b.LinkTarget.Equals(Banner.LinkTargets.InternalUrl) || b.LinkTarget.Equals(Banner.LinkTargets.ExternalUrl) ? LinkCustomTextBox.Text : "";
				#endregion
				#region Position
				if (!LockedPosition)
				{
					b.Position = GetSelectedBannerPosition();
				}
				#endregion
				#region Dates
				if (!LockedDates)
				{
					if (CustomDatesSelected)
					{
						b.AutomaticDates = false;
						b.AutomaticDatesWeeks = 0;
					}
					else
					{
						b.AutomaticDates = true;
						b.AutomaticDatesWeeks = GetSelectedAutomaticDatesWeeks();
					}
					b.FirstDay = GetSelectedFirstDay();
					b.LastDay = GetSelectedLastDay();
				}
				#endregion
				#region Exposure
				if (!LockedExposure)
				{
					int impressions;
					int credits;
					if (ExposureCustomRadio.Checked)
					{
						b.AutomaticExposure = false;
						b.AutomaticExposureLevel = Banner.ExposureLevels.None;

						impressions = int.Parse(ImpressionsTextBox.Text.Replace(",", ""));
						//credits = (int)Math.Ceiling((double)impressions / (double)GetImpressionsPerCredit());
					}
					else
					{
						b.AutomaticExposure = true;
						b.AutomaticExposureLevel = GetSelectedExposureLevel();

						credits = GetCreditsPerDay(b.AutomaticExposureLevel) * GetTotalDays();
						impressions = credits * GetImpressionsPerCredit();
					}
					b.TotalRequiredImpressions = impressions;
					//b.PriceStored = credits;
					//Should we be storing credits somewhere?
				}
				#endregion
				#region Targetting
				if (DisplayTargettingAutomaticSpan() && TargettingAutomaticRadio.Checked)
				{
					b.AutomaticTargetting = true;
					//we update the music / place targetting below (we need a banner k to do it)
				}
				else if (TargettingCustomRadio.Checked)
				{
					b.AutomaticTargetting = false;
					//we update the music / place targetting below (we need a banner k to do it)
				}
				else
				{
					b.AutomaticTargetting = false;
					b.IsMusicTargetted = false;
					b.IsPlaceTargetted = false;
				}
				#endregion
				#region Artwork
				if (!LockedArtwork)
				{
					b.DisplayType = GetSelectedDisplayType();
					b.DesignType = GetSelectedDesignType();

					if (DisplayArtworkAutomaticSpan() && ArtworkAutomaticRadio.Checked)
					{
						b.SetAutomaticBannerText(AutomaticEventBannerHidden.Value);
						if (!b.StatusArtwork && b.FirstDay < DateTime.Today) b.FirstDay = DateTime.Today;
						b.StatusArtwork = true;
					}

					if (Edit)
					{
						//Remove any non-relevant assigned files
						if (b.DisplayType.Equals(Banner.DisplayTypes.AutoEventBanner) || b.DisplayType.Equals(Banner.DisplayTypes.CustomAutoEventBanner))
						{
							b.MiscK = 0;
							b.NewMiscK = 0;
						}
						else if (b.Misc != null && !b.Misc.DisplayType.Equals(CurrentBanner.DisplayType))
						{
							b.MiscK = 0;
						}
					}
				}
				#endregion
				#region Name
				b.Name = Cambro.Web.Helpers.Strip(NameTextBox.Text);
				#endregion
				#region Folder
				if (DisplayFolderActionEventSpan() && FolderActionEventRadio.Checked)
				{
					Query q = new Query();
					q.QueryCondition = new And(
						new Q(BannerFolder.Columns.EventK, CurrentEvent.K),
						new Q(BannerFolder.Columns.PromoterK, CurrentPromoter.K));
					BannerFolderSet bfs = new BannerFolderSet(q);
					if (bfs.Count == 0)
					{
						BannerFolder bf = new BannerFolder();
						bf.PromoterK = CurrentPromoter.K;
						bf.EventK = CurrentEvent.K;
						bf.Name = "Event: " + Cambro.Misc.Utility.Snip(CurrentEvent.Name, 30) + " @ " + Cambro.Misc.Utility.Snip(CurrentEvent.Venue.Name, 20) + ", " + CurrentEvent.DateTime.ToString("MMM dd yy");
						bf.DuplicateGuid = (Guid)ViewState["BannerFolderDuplicateGuid"];
						bf.DateTimeCreated = DateTime.Now;
						bf.Update();
						b.BannerFolderK = bf.K;
					}
					else
						b.BannerFolderK = bfs[0].K;
				}
				else if (FolderActionExistingRadio.Checked)
				{
					BannerFolder bf = new BannerFolder(int.Parse(FolderExistingDropDown.SelectedValue));
					if (bf.PromoterK != CurrentPromoter.K)
						throw new DsiUserFriendlyException("Selected banner folder isn't in your promoter account!");
					b.BannerFolderK = bf.K;
				}
				else if (FolderActionNewRadio.Checked)
				{
					Query q = new Query();
					q.QueryCondition = new And(
						new Q(BannerFolder.Columns.DuplicateGuid, (Guid)ViewState["BannerFolderDuplicateGuid"]));
					BannerFolderSet bfs = new BannerFolderSet(q);
					if (bfs.Count == 0)
					{
						BannerFolder bf = new BannerFolder();
						bf.PromoterK = CurrentPromoter.K;
						bf.Name = Cambro.Web.Helpers.Strip(FolderNewTextBox.Text);
						bf.DuplicateGuid = (Guid)ViewState["BannerFolderDuplicateGuid"];
						bf.DateTimeCreated = DateTime.Now;
						bf.Update();
						b.BannerFolderK = bf.K;	
					}
					else
					{
						if (bfs[0].PromoterK != CurrentPromoter.K)
							throw new DsiUserFriendlyException("Selected banner folder isn't in your promoter account!");
						b.BannerFolderK = bfs[0].K;
					}
				}
				#endregion

				#region if Copy - extra Properties to Copy from existing Banner
				if (Copy)
				{
					b.TargettingProperties0 = CopyBanner.TargettingProperties0;
					b.TargettingProperties1 = CopyBanner.TargettingProperties1;

					if (b.DesignType == Banner.DesignTypes.None)
					{
						if (!b.StatusArtwork && CopyBanner.StatusArtwork && b.FirstDay < DateTime.Today) b.FirstDay = DateTime.Today;
						b.StatusArtwork = CopyBanner.StatusArtwork;
						b.MiscK = CopyBanner.MiscK;
					}
				}
				#endregion

				b.Update();

				if (b.AutomaticTargetting)
				{
					b.IsPlaceTargetted = b.SavePlaceTargetting(CurrentEvent);
					b.IsMusicTargetted = b.SaveMusicTargetting(CurrentEvent);
					b.Update();
				}
				else if (TargettingCustomRadio.Checked)
				{
					b.IsPlaceTargetted = b.SavePlaceTargetting(new List<string>(LocationTargettingHidden.Value.Split(',')).ConvertAll(s => int.Parse(s.Trim())));
					b.IsMusicTargetted = b.SaveMusicTargetting(new List<string>(MusicTargettingHidden.Value.Split(',')).ConvertAll(s => int.Parse(s.Trim())));
					b.Update();
				}
				else
				{
					b.IsPlaceTargetted = b.SavePlaceTargetting(new List<int>(0));
					b.IsMusicTargetted = b.SaveMusicTargetting(new List<int>(1) { 1 });
					b.Update();
				}

                CurrentBanner = b;
                //if (Add || Copy)
                //{
                //    if (HasFixedCurrentEvent)
                //        Response.Redirect(CurrentPromoter.UrlEventOptions(CurrentEvent));
                //    else
                //        Response.Redirect(CurrentPromoter.UrlApp("banners"));
                //}
                //else
                //{
                //    if (HasFixedCurrentEvent)
                //        Response.Redirect(CurrentBanner.OptionsUrl("eventk", CurrentEvent.K.ToString()));
                //    else
						Response.Redirect(CurrentBanner.Url());
                //}
			}
		}
예제 #29
0
		string GetFullBody()
		{
			if (TemplateType.Equals(TemplateTypes.SpecialMail))
			{
				string body = "";

				Assembly ass = Assembly.GetExecutingAssembly();
				StreamReader sr = new StreamReader(ass.GetManifestResourceStream("Bobs.Emails.DsiEmailTemplateSpecial.htm"));
				string siteUserTemplate = sr.ReadToEnd();

				string logInUrl = "http://" + Vars.DomainName + "/";
				if (UsrRecipient != null)
				{
					logInUrl = UsrRecipient.LoginUrl;
				}
				if (RedirectUrl.Length > 0 && UsrRecipient != null)
				{
					logInUrl = UsrRecipient.LoginAndTransfer(RedirectUrl);
				}
				if (OverrideLoginLink.Length > 0)
				{
					logInUrl = OverrideLoginLink;
				}
				body = siteUserTemplate.Replace("[SUBJECT]", Subject);
				body = body.Replace("[BODY]", Body);
				body = body.Replace("[LOGIN]", logInUrl);

				body = AolCompliance(body);
				body = GenericReplacements(body);
				return body;
			}
			else if (TemplateType.Equals(TemplateTypes.AnotherSiteUser))
			{
				string body = "";

				Assembly ass = Assembly.GetExecutingAssembly();
				StreamReader sr = new StreamReader(ass.GetManifestResourceStream("Bobs.Emails.DsiEmailTemplateSiteUser.htm"));
				string siteUserTemplate = sr.ReadToEnd();
				
				RelevanceHolder rel = new RelevanceHolder();
				UsrRecipient.AddRelevant(rel);

				BannerServer.Rules.RequestRules rules = new Bobs.BannerServer.Rules.RequestRules();

				foreach (int musicTypeK in rel.RelevantMusic)
				{
					rules.MusicTypes.Add(musicTypeK);
				}
				foreach (int placeK in rel.RelevantPlaces)
				{
					rules.PlacesVisited.Add(placeK);
				}
				Bobs.BannerServer.Server server = new Bobs.BannerServer.Server();
				BannerDataHolder bdh = server.GetBanner(Banner.Positions.EmailBanner, false, new UsrIdentity(UsrRecipient), rules);
				//Banner b = null;
				string bannerHtml = "";
				if (bdh != null)
				{
					Banner b = new Banner(bdh.K);
					bannerHtml = @"<table cellpadding=""0"" cellspacing=""0"" border=""0""><tr><td rowspan=""3""><img src=""[WEB-ROOT]gfx/1pix.gif"" width=""23"" height=""90""></td><td rowspan=""3""><a href=""[LOGIN]""><img src=""[WEB-ROOT]gfx/logo-200-90.jpg"" border=""0"" width=""200"" height=""90""></a></td><td rowspan=""3""><img src=""[WEB-ROOT]gfx/1pix.gif"" width=""23"" height=""90""></td><td><img src=""[WEB-ROOT]gfx/1pix.gif"" width=""331"" height=""20""></td><td rowspan=""3""><img src=""[WEB-ROOT]gfx/1pix.gif"" width=""23"" height=""90""></td></tr><tr><td><a href=""[LOGIN(" + b.LinkUrlLive + @")]""><img src=""" + b.Misc.Url() + @""" border=""0"" width=""331"" height=""51""></a></td></tr><tr><td><img src=""[WEB-ROOT]gfx/1pix.gif"" width=""331"" height=""19""></td></tr></table>";
					b.RegisterHit(new UsrIdentity(UsrRecipient));
				}
				else
				{
					bannerHtml = @"<table cellpadding=""0"" cellspacing=""0"" border=""0""><tr><td><img src=""[WEB-ROOT]gfx/1pix.gif"" width=""23"" height=""90""></td><td><a href=""[LOGIN]""><img src=""[WEB-ROOT]gfx/logo-200-90.jpg"" border=""0"" width=""200"" height=""90""></a></td><td><img src=""[WEB-ROOT]gfx/1pix.gif"" width=""377"" height=""90""></td></tr></table>";
				}
			
				siteUserTemplate = siteUserTemplate.Replace("[BANNER]", bannerHtml);
			 
				
				
				
				#region AnotherSiteUser
				string salutation = "Hi, ";
				string logInUrl = "http://" + Vars.DomainName + "/";
				if (UsrRecipient != null)
				{
					if (UsrRecipient.NickName.Length > 0)
						salutation = "Dear " + HttpUtility.HtmlEncode(UsrRecipient.NickName) + ", ";
					logInUrl = UsrRecipient.LoginUrl;
				}
				if (RedirectUrl.Length > 0 && UsrRecipient != null)
				{
					logInUrl = UsrRecipient.LoginAndTransfer(RedirectUrl);
				}
				if (OverrideLoginLink.Length > 0)
				{
					logInUrl = OverrideLoginLink;
				}
				body = siteUserTemplate.Replace("[SUBJECT]", Subject);
				#region [QUICKLINK]
				if (ShowQuickLink)
				{
					body = body.Replace("[QUICKLINK]", @"[h1]
		Quick link
	[/h1]
	[div]
		<p align=""center"" style=""margin:8px 0px 4px 0px;""><a href=""[LOGIN]"" style=""font-size:18px;font-weight:bold;"">Click here for DontStayIn</a></p>
	[/div]");
				}
				else
					body = body.Replace("[QUICKLINK]", "");
				#endregion
				body = body.Replace("[BODY]", Body);
				body = body.Replace("[SALUTATION]", salutation);
				#endregion

				body = AolCompliance(body);
				body = body.Replace("[LOGIN]", logInUrl);
				body = GenericReplacements(body);
				return body;
			}
			else if (TemplateType.Equals(TemplateTypes.AdminNote))
			{
				Assembly ass = Assembly.GetExecutingAssembly();
				StreamReader sr = new StreamReader(ass.GetManifestResourceStream("Bobs.Emails.DsiEmailTemplateAdminNote.htm"));
				string adminNoteTemplate = sr.ReadToEnd();

				#region AdminNote
				string logInUrl = "http://" + Vars.DomainName + "/";
				if (Usr.Current != null)
				{
					logInUrl = Usr.Current.LoginAndTransfer(RedirectUrl);
				}
				if (OverrideLoginLink.Length > 0)
					logInUrl = OverrideLoginLink;

				Usr usrDave = new Usr(4);
				Usr usrJohn = new Usr(1);
				Usr usrTim = new Usr(2);

				string body = adminNoteTemplate.Replace("[SUBJECT]", Subject);

				body = body.Replace("[BODY]", Body);
				body = body.Replace("[LOGIN-URL-CURRENT]", logInUrl);
				body = body.Replace("[LOGIN-URL-DAVE]", usrDave.LoginAndTransfer(RedirectUrl));
				body = body.Replace("[LOGIN-URL-JOHN]", usrJohn.LoginAndTransfer(RedirectUrl));
				body = body.Replace("[LOGIN-URL-TIM]", usrTim.LoginAndTransfer(RedirectUrl));

				body = GenericReplacements(body);

				return body;
				#endregion
			}
			else
				return "error";
		}
예제 #30
0
		void LoadFormFromBanner(Banner b)
		{
			LinkEventRadio.Checked = b.LinkTarget.Equals(Banner.LinkTargets.Event);
			LinkBrandRadio.Checked = b.LinkTarget.Equals(Banner.LinkTargets.Brand);
			LinkVenueRadio.Checked = b.LinkTarget.Equals(Banner.LinkTargets.Venue);
			LinkTicketsRadio.Checked = b.LinkTarget.Equals(Banner.LinkTargets.TicketsBrand) || b.LinkTarget.Equals(Banner.LinkTargets.TicketsVenue);
			LinkCustomRadio.Checked = b.LinkTarget.Equals(Banner.LinkTargets.InternalUrl) || b.LinkTarget.Equals(Banner.LinkTargets.ExternalUrl);

			if (b.LinkTarget.Equals(Banner.LinkTargets.Event) && HasLinkEventDropDown)
				LinkEventDropDown.SelectedValue = GetLinkEventDropDownValue(b.Event);

			if (b.LinkTarget.Equals(Banner.LinkTargets.Brand) && HasLinkBrandDropDown)
				LinkBrandDropDown.SelectedValue = b.BrandK.ToString();

			if (b.LinkTarget.Equals(Banner.LinkTargets.Venue) && HasLinkVenueDropDown)
				LinkBrandDropDown.SelectedValue = b.VenueK.ToString();

			if (b.LinkTarget.Equals(Banner.LinkTargets.TicketsBrand) && HasLinkTicketsDropDown)
				LinkTicketsDropDown.SelectedValue = "Brand-" + b.BrandK.ToString();

			if (b.LinkTarget.Equals(Banner.LinkTargets.TicketsVenue) && HasLinkTicketsDropDown)
				LinkTicketsDropDown.SelectedValue = "Venue-" + b.VenueK.ToString();

			if (b.LinkTarget.Equals(Banner.LinkTargets.InternalUrl) || b.LinkTarget.Equals(Banner.LinkTargets.ExternalUrl))
				LinkCustomTextBox.Text = b.LinkUrl;

			PositionHotboxRadio.Checked = b.Position.Equals(Banner.Positions.Hotbox);
			PositionLeaderboardRadio.Checked = b.Position.Equals(Banner.Positions.Leaderboard);
			PositionSkyscraperRadio.Checked = b.Position.Equals(Banner.Positions.Skyscraper);
			PositionPhotoBannerRadio.Checked = b.Position.Equals(Banner.Positions.PhotoBanner);
			PositionEmailBannerRadio.Checked = b.Position.Equals(Banner.Positions.EmailBanner);

			Dates1WeekRadio.Checked = b.AutomaticDates && b.AutomaticDatesWeeks == 1 && DisplayDates1WeekSpan();
			Dates2WeekRadio.Checked = b.AutomaticDates && b.AutomaticDatesWeeks == 2 && DisplayDates2WeekSpan();
			Dates3WeekRadio.Checked = b.AutomaticDates && b.AutomaticDatesWeeks == 3 && DisplayDates3WeekSpan();
			Dates4WeekRadio.Checked = b.AutomaticDates && b.AutomaticDatesWeeks == 4 && DisplayDates4WeekSpan();
			DatesCustomRadio.Checked = !b.AutomaticDates;
			if (DatesCustomRadio.Checked)
			{
				DatesStartCal.Date = b.FirstDay;
				DatesEndCal.Date = b.LastDay;
			}

			ExposureLightRadio.Checked = b.AutomaticExposure && b.AutomaticExposureLevel.Equals(Banner.ExposureLevels.Light);
			ExposureMediumRadio.Checked = b.AutomaticExposure && b.AutomaticExposureLevel.Equals(Banner.ExposureLevels.Medium);
			ExposureHeavyRadio.Checked = b.AutomaticExposure && b.AutomaticExposureLevel.Equals(Banner.ExposureLevels.Heavy);
			ExposureCustomRadio.Checked = !b.AutomaticExposure;
			ImpressionsTextBox.Text = b.TotalRequiredImpressions.ToString("#,##0");

			

			bool placeTargetting = b.IsPlaceTargetted && b.Places.Count > 0;
			bool musicTargetting = b.IsMusicTargetted && b.MusicTypesChosen.Count > 0 && !(b.MusicTypesChosen.Count == 1 && b.MusicTypesChosen[0].K == 1);

			TargettingAutomaticRadio.Checked = b.AutomaticTargetting;
			TargettingNoneRadio.Checked = !b.AutomaticTargetting && !musicTargetting && !placeTargetting;
			TargettingCustomRadio.Checked = !b.AutomaticTargetting && (musicTargetting || placeTargetting);

			if (!b.AutomaticTargetting && !musicTargetting && !placeTargetting)
			{
				LocationTargettingHidden.Value = "";
				LocationTargettingTextBox.Text = "no towns";
				MusicTargettingHidden.Value = "";
				MusicTargettingTextBox.Text = "no music types";
			}
			else
			{
				LocationTargettingHidden.Value = placeTargetting ? string.Join(", ", b.Places.ToList().ConvertAll(p => p.K.ToString()).ToArray()) : "0";
				LocationTargettingTextBox.Text = (placeTargetting ? b.Places.Count.ToString() : "all") + " town" + (b.Places.Count == 1 ? "" : "s");

				MusicTargettingHidden.Value = musicTargetting ? String.Join(",", b.MusicTypesChosen.ToList().ConvertAll(mt => mt.K.ToString()).ToArray()) : "1";
				MusicTargettingTextBox.Text = (musicTargetting ? b.MusicTypesChosen.Count.ToString() : "all") + " music type" + (musicTargetting && b.MusicTypesChosen.Count == 1 ? "" : "s");
			}

			ArtworkUploadRadio.Checked = b.DesignType.Equals(Banner.DesignTypes.None) && (b.DisplayType.Equals(Banner.DisplayTypes.Jpg) || b.DisplayType.Equals(Banner.DisplayTypes.AnimatedGif) || b.DisplayType.Equals(Banner.DisplayTypes.FlashMovie));
			ArtworkGifRadio.Checked = b.DesignType.Equals(Banner.DesignTypes.Gif);
			ArtworkJpgRadio.Checked = b.DesignType.Equals(Banner.DesignTypes.Jpg);
			ArtworkFlashRadio.Checked = b.DesignType.Equals(Banner.DesignTypes.Flash);
			ArtworkAutomaticRadio.Checked = b.DisplayType.Equals(Banner.DisplayTypes.AutoEventBanner) || b.DisplayType.Equals(Banner.DisplayTypes.CustomAutoEventBanner);
			if (ArtworkAutomaticRadio.Checked)
			{
				AutomaticEventBannerHidden.Value = b.GetAutomaticBannerTextXml();
				if (b.DisplayType.Equals(Banner.DisplayTypes.AutoEventBanner))
					AutomaticEventBannerTextBox.Text = "automatic text from event";
				else
					AutomaticEventBannerTextBox.Text = "customised text";
			}

			NameTextBox.Text = b.Name;

			FolderActionEventRadio.Checked = b.BannerFolder.EventK == b.EventK;
			
		}