Пример #1
0
		void ArticlesDataGrid_Bind()
		{
			Query q = new Query();
			if (Usr.Current.IsAdmin)
				q.QueryCondition = new Or(new Q(Article.Columns.OwnerUsrK, Usr.Current.K), new Q(Article.Columns.Status, Article.StatusEnum.Edit), new Q(Article.Columns.Status, Article.StatusEnum.Enabled));
			else if (Usr.Current.IsSuper)
				q.QueryCondition = new Or(new Q(Article.Columns.OwnerUsrK, Usr.Current.K), new Q(Article.Columns.Status, Article.StatusEnum.Edit));
			else
				q.QueryCondition = new Q(Article.Columns.OwnerUsrK, Usr.Current.K);

			q.OrderBy = new OrderBy(Article.Columns.AddedDateTime, OrderBy.OrderDirection.Descending);

			ArticleSet ars = new ArticleSet(q);

			if (ars.Count == 0)
			{
				NoArticlesDataGridPanel.Visible = true;
				ArticlesDataGridPanel.Visible = false;

			}
			else
			{
				ArticlesDataGrid.Columns[3].Visible = Usr.Current.IsSuper;
				NoArticlesDataGridPanel.Visible = false;
				ArticlesDataGridPanel.Visible = true;
				ArticlesDataGrid.AllowPaging = (ars.Count > ArticlesDataGrid.PageSize);
				ArticlesDataGrid.DataSource = ars;
				ArticlesDataGrid.DataBind();
			}
		}
Пример #2
0
		void ArticleListBind()
		{
			if (EnsureSecure)
			{
				Query q = new Query();

				q.TableElement = new TableElement(TablesEnum.Article);
				q.TableElement = new Join(q.TableElement, new TableElement(TablesEnum.Event), QueryJoinType.Left, Article.Columns.EventK, Event.Columns.K);
				q.TableElement = new Join(q.TableElement, new TableElement(TablesEnum.Venue), QueryJoinType.Left, Article.Columns.VenueK, Venue.Columns.K);
				q.TableElement = new Join(q.TableElement, new TableElement(TablesEnum.EventBrand), QueryJoinType.Left, Event.Columns.K, EventBrand.Columns.EventK);
				q.TableElement = new Join(q.TableElement, new TableElement(TablesEnum.Brand), QueryJoinType.Left, EventBrand.Columns.BrandK, Brand.Columns.K);

				//q.TableElement = new Join(new Join(Article.Columns.EventK, EventBrand.Columns.EventK), Brand.Columns.K, EventBrand.Columns.BrandK);

				q.QueryCondition = 
					new Or(
						new And(
							new Q(Brand.Columns.PromoterStatus, Brand.PromoterStatusEnum.Confirmed),
							new Q(Brand.Columns.PromoterK, CurrentPromoter.K)
						),
						new And(
							new Q(Venue.Columns.PromoterStatus, Venue.PromoterStatusEnum.Confirmed),
							new Q(Venue.Columns.PromoterK, CurrentPromoter.K)
						)
					);

				q.Distinct = true;
				q.DistinctColumn = Article.Columns.K;
	
				q.OrderBy = new OrderBy(Article.Columns.AddedDateTime, OrderBy.OrderDirection.Descending);

				ArticleSet ars = new ArticleSet(q);
				ArticlePanel.Visible = ars.Count > 0;
				NoArticlePanel.Visible = ars.Count == 0;
				if (ars.Count > 0)
				{
					ArticleDataGrid.AllowPaging = ars.Count > ArticleDataGrid.PageSize;
					ArticleDataGrid.DataSource = ars;
					ArticleDataGrid.DataBind();
				}
			}
		}
Пример #3
0
		public void SortArticleThreadK(object o, System.EventArgs e)
		{
			Cambro.Web.Helpers.WriteAlertHeader();

			Cambro.Web.Helpers.WriteAlert("Selecting articles...", 1);
			Query q = new Query();
			ArticleSet bs = new ArticleSet(q);
			for (int count = 0; count < bs.Count; count++)
			{
				Article c = bs[count];

				try
				{
					Query q1 = new Query();
					q1.TopRecords=1;
					q1.OrderBy=new OrderBy(Thread.Columns.TotalComments, OrderBy.OrderDirection.Descending);
					q1.QueryCondition=new And(
						new Q(Thread.Columns.ArticleK, c.K), 
						new Q(Thread.Columns.Private, false),
						new Q(Thread.Columns.GroupK, 0));

					ThreadSet ts = new ThreadSet(q1);
					if (ts.Count == 0)
					{
						c.ThreadK = 0;
					}
					else
					{
						c.ThreadK = ts[0].K;
					}
					// Do work here!
					c.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();
		}
Пример #4
0
		protected void Page_Load(object sender, EventArgs e)
		{

			Q sectionQ = new Q(true);
			if (Request.QueryString["section"] != null)
			{
				sectionQ = new StringQueryCondition(
					"[Article].[MixmagSections] & " + 
					((int)Math.Pow(2.0, (double)int.Parse(Request.QueryString["section"]))).ToString() + 
					" > 0 ");
			}

			Query q = new Query();
			q.TopRecords = 20;
			q.OrderBy = new OrderBy(Article.Columns.EnabledDateTime, OrderBy.OrderDirection.Descending);
			q.QueryCondition = new And(
				new Q(Article.Columns.Status, Article.StatusEnum.Enabled),
				new Q(Article.Columns.IsWorldwide, true),
				new Q(Article.Columns.IsMixmagNews, true),
				sectionQ
				);
			ArticleSet arts = new ArticleSet(q);
			

			// set the content type
			Page.Response.ContentType = "text/xml";
			// create a RSS feed generator for the output
			RSSFeedGenerator gen = new RSSFeedGenerator(Page.Response.Output);
			gen.WriteStartDocument();
			gen.WriteStartChannel("Mixmag articles RSS Feed",
				"http://www.dontstayin.com/",
				"Summary of the latest Mixmag articles published on Don't Stay In",
				"Copyright © Development Hell Ltd, 2007-2009", "DaveB");
			// generate the items here
			foreach (Article a in arts)
			{
				
				Templates.Articles.ParaTemplate para = (Templates.Articles.ParaTemplate)this.LoadControl("/Templates/Articles/ParaTemplate.ascx");
				para.OverridePara = a.FirstPara;
				para.ForceLinksToArticle = true;
				para.IncludeDomainNameInLinks = true;
				para.InlineScript = true;
				para.DisableParagraphTagsRoundContent = true;
				para.RenderAllFlashTags = true;
				para.RenderFlashTagsRaw = ContainerPage.Url[0] == "Raw";
				para.Initialise();

				System.IO.StringWriter stringWrite = new System.IO.StringWriter();
				System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
				para.RenderControl(htmlWrite);
				string html = stringWrite.ToString();
				html += "<p><a href=\"http://" + Vars.DomainName + a.Url() + "\">" + a.TotalComments.ToString() + " comment" + (a.TotalComments == 1 ? "" : "s") + " at Don't Stay In</a></p>";
				html += "<div class=\"submitted\">Submitted by <a href=\"http://www.mixmag.net/users/" + a.Owner.FirstName.ToLower() + "-" + a.Owner.LastName.ToLower() + "\">" + a.Owner.FirstName + " " + a.Owner.LastName + "</a> on " + a.EnabledDateTime.ToString("dd MMMM yyyy - hh:mm") + "</div>";

				gen.WriteItem(
					a.Title,
					"http://" + Vars.DomainName + a.Url(),
					html,
					a.Owner.NickName,
					a.EnabledDateTime,
					a.Title);
			}
			// clear up
			gen.WriteEndChannel();
			gen.WriteEndDocument();
			gen.Close();
			Response.End();
		}
Пример #5
0
		public void StripAll()
		{
			Query qUsrEventGuestlist = new Query();
			qUsrEventGuestlist.QueryCondition = new Q(UsrEventGuestlist.Columns.UsrK, this.K);
			UsrEventGuestlistSet uegs = new UsrEventGuestlistSet(qUsrEventGuestlist);
			foreach (UsrEventGuestlist ueg in uegs)
			{
				ueg.Delete();
				ueg.Update();
				ueg.Event.UpdateGuestlistCount();
			}

			//UsrPlaceVisit
			Delete UsrPlaceVisitDelete = new Delete(
				TablesEnum.UsrPlaceVisit,
				new Q(UsrPlaceVisit.Columns.UsrK, this.K)
				);
			UsrPlaceVisitDelete.Run();

			//UsrEventAttended
			Delete UsrEventAttendedDelete = new Delete(
				TablesEnum.UsrEventAttended,
				new Q(UsrEventAttended.Columns.UsrK, this.K)
				);
			UsrEventAttendedDelete.Run();

			//UsrPhotoFavourite
			Delete UsrPhotoFavouriteDelete = new Delete(
				TablesEnum.UsrPhotoFavourite,
				new Q(UsrPhotoFavourite.Columns.UsrK, this.K)
				);
			UsrPhotoFavouriteDelete.Run();

			//UsrPhotoMe
			Delete UsrPhotoMeDelete = new Delete(
				TablesEnum.UsrPhotoMe,
				new Q(UsrPhotoMe.Columns.UsrK, this.K)
				);
			UsrPhotoMeDelete.Run();

			//UsrMusicTypeFavourite
			Delete UsrMusicTypeFavouriteDelete = new Delete(
				TablesEnum.UsrMusicTypeFavourite,
				new Q(UsrMusicTypeFavourite.Columns.UsrK, this.K)
				);
			UsrMusicTypeFavouriteDelete.Run();

			//Buddy / Buddy reverse;
			BuddySet bs = new BuddySet(new Query(new Or(new Q(Buddy.Columns.UsrK, this.K), new Q(Buddy.Columns.BuddyUsrK, this.K))));
			foreach (Buddy b in bs)
				b.DeleteAll(null);

			//UsrDate
			Delete UsrDateDelete = new Delete(
				TablesEnum.UsrDate,
				new Or(new Q(UsrDate.Columns.UsrK, this.K), new Q(UsrDate.Columns.DateUsrK, this.K))
				);
			UsrDateDelete.Run();

			//Owners - Event
			EventSet esOwner = new EventSet(new Query(new Q(Event.Columns.OwnerUsrK, this.K)));
			foreach (Event e in esOwner)
			{
				e.DeleteAllUsr(Usr.Current);
				//e.OwnerUsrK=4;
				//e.Update();
			}

			BrandSet bsOwner = new BrandSet(new Query(new Q(Brand.Columns.OwnerUsrK, this.K)));
			foreach (Brand b in bsOwner)
			{
				b.DeleteAll(null);
				//b.OwnerUsrK=4;
				//b.Update();
			}

			//Owners - Venue
			VenueSet vsOwner = new VenueSet(new Query(new Q(Venue.Columns.OwnerUsrK, this.K)));
			foreach (Venue v in vsOwner)
			{
				v.DeleteAllUsr(Usr.Current);
				//v.OwnerUsrK=4;
				//v.Update();
			}

			//PhotoReview ???
			PhotoReviewSet prs = new PhotoReviewSet(new Query(new Q(PhotoReview.Columns.UsrK, this.K)));
			foreach (PhotoReview pr in prs)
			{
				pr.Delete();
				pr.Update();
				pr.Photo.UpdateStats(null);
			}

			//Galleries
			GallerySet gs = new GallerySet(new Query(new Q(Gallery.Columns.OwnerUsrK, this.K)));
			foreach (Gallery g in gs)
				g.DeleteAll(null);

			//Photos
			PhotoSet ps = new PhotoSet(new Query(new Q(Photo.Columns.UsrK, this.K)));
			foreach (Photo p in ps)
				p.DeleteAll(null);

			//Aticles
			ArticleSet ars = new ArticleSet(new Query(new Q(Article.Columns.OwnerUsrK, this.K)));
			foreach (Article a in ars)
				a.DeleteAll(null);

			Guid oldPic = Pic;

			this.PicPhotoK = 0;
			this.PicState = "";
			this.Pic = Guid.Empty;
			this.PicOriginal = Guid.Empty;
			//this.NickName=Usr.GetCompliantNickName("user-"+this.K.ToString());
			this.PersonalStatement = "";
			this.IsSingle = false;
			this.EnhancedSecurity = true;
			this.IsSpotter = false;
			Random r = new Random();
			this.LoginString = Cambro.Misc.Utility.GenRandomText(6, r);
			this.SetPassword(Cambro.Misc.Utility.GenRandomText(10, r), false);

			int k = this.K;

			//Usr
			this.Update();

			if (oldPic != Guid.Empty)
				Storage.RemoveFromStore(Storage.Stores.Pix, oldPic, "jpg");

		}
Пример #6
0
		public void DeleteAll(Transaction transaction)
		{
			if (!this.Bob.DbRecordExists)
				return;


			Query qUsrEventGuestlist = new Query();
			qUsrEventGuestlist.QueryCondition = new Q(UsrEventGuestlist.Columns.UsrK, this.K);
			UsrEventGuestlistSet uegs = new UsrEventGuestlistSet(qUsrEventGuestlist);
			foreach (UsrEventGuestlist ueg in uegs)
			{
				ueg.Delete(transaction);
				ueg.Event.UpdateGuestlistCount(transaction);
			}

			//Promoters
			Query PromoterQ = new Query();
			PromoterQ.TableElement = Promoter.UsrJoin;
			PromoterQ.QueryCondition = new Q(Usr.Columns.K, this.K);
			PromoterSet promoters = new PromoterSet(PromoterQ);

			Delete PromoterUsrDelete = new Delete(
				TablesEnum.PromoterUsr,
				new Q(PromoterUsr.Columns.UsrK, this.K)
			);
			PromoterUsrDelete.CommandTimeout = 3600;
			PromoterUsrDelete.Run(transaction);

			foreach (Promoter p in promoters)
			{
				p.AdminUsrs = null;
				if (p.AdminUsrs.Count == 0)
				{
					p.DeleteAll(transaction);
				}
				else if (p.PrimaryUsrK == this.K)
				{
					p.PrimaryUsrK = p.AdminUsrs[0].K;
					p.Update(transaction);
				}
			}

			//UsrPlaceVisit
			Delete UsrPlaceVisitDelete = new Delete(
				TablesEnum.UsrPlaceVisit,
				new Q(UsrPlaceVisit.Columns.UsrK, this.K)
				);
			UsrPlaceVisitDelete.CommandTimeout = 3600;
			UsrPlaceVisitDelete.Run(transaction);

			//UsrEventAttended
			Delete UsrEventAttendedDelete = new Delete(
				TablesEnum.UsrEventAttended,
				new Q(UsrEventAttended.Columns.UsrK, this.K)
				);
			UsrEventAttendedDelete.CommandTimeout = 3600;
			UsrEventAttendedDelete.Run(transaction);

			//UsrPhotoFavourite
			Delete UsrPhotoFavouriteDelete = new Delete(
				TablesEnum.UsrPhotoFavourite,
				new Q(UsrPhotoFavourite.Columns.UsrK, this.K)
				);
			UsrPhotoFavouriteDelete.CommandTimeout = 3600;
			UsrPhotoFavouriteDelete.Run(transaction);

			//UsrPhotoMe
			PhotoSet psMe = this.PhotosMe(new ColumnSet(Photo.Columns.K, Photo.Columns.EventK, Photo.Columns.FirstUsrK, Photo.Columns.UsrCount), 0);
			foreach (Photo p in psMe)
			{
				this.PhotoMe(p, false, transaction);
			}

			//UsrMusicTypeFavourite
			Delete UsrMusicTypeFavouriteDelete = new Delete(
				TablesEnum.UsrMusicTypeFavourite,
				new Q(UsrMusicTypeFavourite.Columns.UsrK, this.K)
				);
			UsrMusicTypeFavouriteDelete.CommandTimeout = 3600;
			UsrMusicTypeFavouriteDelete.Run(transaction);

			//Buddy / Buddy reverse;
			BuddySet bs = new BuddySet(new Query(new Or(new Q(Buddy.Columns.UsrK, this.K), new Q(Buddy.Columns.BuddyUsrK, this.K))));
			foreach (Buddy b in bs)
				b.DeleteAll(transaction);

			//ChatMessageFrom
			//	Delete ChatMessageFromDelete = new Delete(
			//		TablesEnum.ChatMessage,
			//		new Q(ChatMessage.Columns.FromUsrK,this.K)
			//	);
			//	ChatMessageFromDelete.Run(transaction);

			//ChatMessageTo
			//	Delete ChatMessageToDelete = new Delete(
			//		TablesEnum.ChatMessage,
			//		new Q(ChatMessage.Columns.ToUsrK, this.K)
			//	);
			//	ChatMessageToDelete.Run(transaction);

			//UsrDate
			Delete UsrDateDelete = new Delete(
				TablesEnum.UsrDate,
				new Or(new Q(UsrDate.Columns.UsrK, this.K), new Q(UsrDate.Columns.DateUsrK, this.K))
				);
			UsrDateDelete.CommandTimeout = 3600;
			UsrDateDelete.Run(transaction);

			//Owners - Event
			EventSet esOwner = new EventSet(new Query(new Q(Event.Columns.OwnerUsrK, this.K)));
			foreach (Event e in esOwner)
			{
				e.OwnerUsrK = 8;
				e.Update(transaction);
			}

			BrandSet bsOwner = new BrandSet(new Query(new Q(Brand.Columns.OwnerUsrK, this.K)));
			foreach (Brand b in bsOwner)
			{
				b.OwnerUsrK = 8;
				b.Update(transaction);
			}

			//Owners - Venue
			VenueSet vsOwner = new VenueSet(new Query(new Q(Venue.Columns.OwnerUsrK, this.K)));
			foreach (Venue v in vsOwner)
			{
				v.OwnerUsrK = 8;
				v.Update(transaction);
			}

			//Remove EnabledByUsrK in Photos that this usr has enabled
			PhotoSet pEnableds = new PhotoSet(new Query(new Q(Photo.Columns.EnabledByUsrK, this.K)));
			foreach (Photo p in pEnableds)
			{
				p.EnabledByUsrK = 0;
				p.Update(transaction);
			}

			//ThreadUsr
			Delete ThreadUsrDelete = new Delete(
				TablesEnum.ThreadUsr,
				new Or(new Q(ThreadUsr.Columns.UsrK, this.K), new Q(ThreadUsr.Columns.InvitingUsrK, this.K))
				);
			ThreadUsrDelete.CommandTimeout = 3600;
			ThreadUsrDelete.Run(transaction);

			//CommentAlert
			Delete CommentAlertDelete = new Delete(
				TablesEnum.CommentAlert,
				new Q(CommentAlert.Columns.UsrK, this.K)
			);
			CommentAlertDelete.CommandTimeout = 3600;
			CommentAlertDelete.Run(transaction);


			//GroupUsr
			Delete GroupUsrDelete = new Delete(
				TablesEnum.GroupUsr,
				new Q(GroupUsr.Columns.UsrK, this.K)
				);
			GroupUsrDelete.CommandTimeout = 3600;
			GroupUsrDelete.Run(transaction);


			//Threads?
			ThreadSet ts = new ThreadSet(new Query(new Q(Thread.Columns.UsrK, this.K)));
			foreach (Thread t in ts)
				t.DeleteAll(transaction);

			Bobs.Update uLastPostUsrK = new Bobs.Update();
			uLastPostUsrK.Changes.Add(new Assign(Thread.Columns.LastPostUsrK, 0));
			uLastPostUsrK.Table = TablesEnum.Thread;
			uLastPostUsrK.Where = new Q(Thread.Columns.LastPostUsrK, this.K);
			uLastPostUsrK.CommandTimeout = 3600;
			uLastPostUsrK.Run(transaction);

			Bobs.Update uFirstParticipantUsrK = new Bobs.Update();
			uFirstParticipantUsrK.Changes.Add(new Assign(Thread.Columns.FirstParticipantUsrK, 0));
			uFirstParticipantUsrK.Table = TablesEnum.Thread;
			uFirstParticipantUsrK.Where = new Q(Thread.Columns.FirstParticipantUsrK, this.K);
			uFirstParticipantUsrK.CommandTimeout = 3600;
			uFirstParticipantUsrK.Run();

			//Comments?
			CommentSet cs = new CommentSet(new Query(new Q(Comment.Columns.UsrK, this.K)));
			foreach (Comment c in cs)
				c.DeleteAll(transaction);

			//PhotoReview ???
			PhotoReviewSet prs = new PhotoReviewSet(new Query(new Q(PhotoReview.Columns.UsrK, this.K)));
			foreach (PhotoReview pr in prs)
			{
				pr.Delete(transaction);
				pr.Photo.UpdateStats(transaction);
			}

			//Galleries
			GallerySet gs = new GallerySet(new Query(new Q(Gallery.Columns.OwnerUsrK, this.K)));
			foreach (Gallery g in gs)
				g.DeleteAll(transaction);

			//Photos
			PhotoSet ps = new PhotoSet(new Query(new Q(Photo.Columns.UsrK, this.K)));
			foreach (Photo p in ps)
				p.DeleteAll(transaction);

			//Aticles
			ArticleSet ars = new ArticleSet(new Query(new Q(Article.Columns.OwnerUsrK, this.K)));
			foreach (Article a in ars)
				a.DeleteAll(transaction);

			int k = this.K;

			//Usr-AddedByUsrK
			UsrSet usrsAddedByUsr = new UsrSet(new Query(new Q(Usr.Columns.AddedByUsrK, this.K)));
			foreach (Usr u in usrsAddedByUsr)
			{
				u.AddedByUsrK = 0;
				u.Update(transaction);
			}

			Guid oldPic = this.Pic;

			//Usr
			this.Delete(transaction);

			if (oldPic != Guid.Empty)
				Storage.RemoveFromStore(Storage.Stores.Pix, oldPic, "jpg");

		}
Пример #7
0
		public void MergeAndDelete(Venue merge)
		{
			if (this.K == merge.K)
				throw new DsiUserFriendlyException("Can't merge a venue into itself!");

			Cambro.Web.Helpers.WriteAlertHeader();

			//throw new Exception("This function isn't finished yet!");

			Cambro.Web.Helpers.WriteAlert("Starting merge...", true);

			#region Promoter
			Cambro.Web.Helpers.WriteAlert("Merging promoter...", true);
			if (merge.PromoterK > 0 && merge.PromoterStatus.Equals(Venue.PromoterStatusEnum.Confirmed) && merge.Promoter.IsEnabled)
			{
				this.PromoterK = merge.PromoterK;
				this.PromoterStatus = Venue.PromoterStatusEnum.Confirmed;
			}
			else if (this.PromoterK == 0 && merge.PromoterK > 0)
			{
				this.PromoterK = merge.PromoterK;
				this.PromoterStatus = merge.PromoterStatus;
			}
			Cambro.Web.Helpers.WriteAlert("Done merging promoter...");
			#endregion

			#region Articles
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Moving articles...", true);
				Query q = new Query();
				q.QueryCondition = new And(new Q(Article.Columns.ParentObjectType, Model.Entities.ObjectType.Venue),new Q(Article.Columns.ParentObjectK, merge.K));
				ArticleSet ars = new ArticleSet(q);
				foreach (Article a in ars)
				{
					Cambro.Web.Helpers.WriteAlert("Moving article " + a.K + "...");
					a.ParentObjectK = this.K;
					a.VenueK = this.K;

					if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Place)
						a.PlaceK = this.PlaceK;
					else
						a.PlaceK = 0;

					if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Country)
						a.CountryK = this.Place.CountryK;
					else
						a.CountryK = 0;

					a.UrlFragment = this.UrlFilterPart;
					a.Update();

					#region Threads
					if (true)
					{
						Update u = new Update();
						u.Table = TablesEnum.Thread;
						u.Where = new Q(Thread.Columns.ArticleK, a.K);
						u.Changes.Add(new Assign(Thread.Columns.UrlFragment, a.UrlFilterPart));
						u.Changes.Add(new Assign(Thread.Columns.VenueK, this.K));
						u.Changes.Add(new Assign(Thread.Columns.PlaceK, this.PlaceK));
						u.Changes.Add(new Assign(Thread.Columns.CountryK, this.Place.CountryK));
						u.Run();
					}
					#endregion
					#region Galleries
					if (true)
					{
						Update u = new Update();
						u.Table = TablesEnum.Gallery;
						u.Where = new Q(Gallery.Columns.ArticleK, a.K);
						u.Changes.Add(new Assign(Gallery.Columns.UrlFragment, a.UrlFilterPart));
						u.Run();
					}
					#endregion
					#region Photos
					if (true)
					{
						Update u = new Update();
						u.Table = TablesEnum.Photo;
						u.Where = new Q(Photo.Columns.ArticleK, a.K);
						u.Changes.Add(new Assign(Photo.Columns.UrlFragment, a.UrlFilterPart));
						u.Run();
					}
					#endregion
				}
				Cambro.Web.Helpers.WriteAlert("Done moving articles...", true);
			}
			#endregion

			#region Events
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Moving events...", true);
				EventSet es = new EventSet(new Query(new Q(Event.Columns.VenueK, merge.K)));
				int count = 0;
				foreach (Event ev in es)
				{
					count++;
					Cambro.Web.Helpers.WriteAlert("Moving event "+ev.K+" ("+count+" / "+es.Count+")...");
					ev.ChangeVenue(this.K, true);
				}
				Cambro.Web.Helpers.WriteAlert("Done moving events...");
			}
			#endregion

			#region Thread ParentObjects
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging topics (1/2)...", true);
				Update u = new Update();
				u.Table = TablesEnum.Thread;
				u.Where = new And(
					new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Venue),
					new Q(Thread.Columns.ParentObjectK, merge.K));
				u.Changes.Add(new Assign(Thread.Columns.ParentObjectK, this.K));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging topics (1/2)...");
			}
			#endregion

			#region Thread
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging topics (2/2)...", true);
				Update u = new Update();
				u.Table = TablesEnum.Thread;
				u.Where = new And(
					new Q(Thread.Columns.VenueK, merge.K),
					new Q(Thread.Columns.EventK, 0),
					new Q(Thread.Columns.ArticleK, 0));
				u.Changes.Add(new Assign(Thread.Columns.VenueK, this.K));
				u.Changes.Add(new Assign(Thread.Columns.UrlFragment, this.UrlFilterPart));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging topics (2/2)...");
			}
			#endregion

			#region Pic
			if (!this.HasPic)
			{
				Cambro.Web.Helpers.WriteAlert("Merging picture...", true);
				this.Pic = merge.Pic;
				this.PicMiscK = merge.PicMiscK;
				this.PicPhotoK = merge.PicPhotoK;
				this.PicState = merge.PicState;
				merge.Pic = Guid.Empty;
				merge.PicMiscK = 0;
				merge.PicPhotoK = 0;
				merge.PicState = "";
				merge.Update();
				Cambro.Web.Helpers.WriteAlert("Done merging picture...");
			}
			#endregion

			this.AdminNote += "Venue " + merge.K + " was merged with this one " + DateTime.Now.ToString() + ". The admin note from venue " + merge.K + " is:\n********************\n" + merge.AdminNote + "\n********************\n";

			this.Update();

			int mergePlaceK = merge.PlaceK;

			Cambro.Web.Helpers.WriteAlert("Deleting old venue...", true);
			merge.DeleteAll(null);
			Cambro.Web.Helpers.WriteAlert("Done deleting old venue...");

			if (mergePlaceK != this.PlaceK)
			{
				Place mergePlace = new Place(mergePlaceK);
				Cambro.Web.Helpers.WriteAlert("Updating stats for old place...", true);
				mergePlace.UpdateTotalComments(null);
				mergePlace.UpdateTotalEvents(null);
				Cambro.Web.Helpers.WriteAlert("Done updating stats for old place...");
			}

			Cambro.Web.Helpers.WriteAlert("Updating stats for new venue...", true);
			this.UpdateTotalComments(null);
			this.UpdateTotalEvents(null);
			Cambro.Web.Helpers.WriteAlert("Done updating stats for new venue...");

			this.Update();
			Cambro.Web.Helpers.WriteAlert("Done merging venues!", true);


		}
Пример #8
0
		private void Page_Load(object sender, System.EventArgs e)
		{
			if (this.Visible)
			{
				string name = "";
				if (Type.Equals(ArchiveObjectType.Gallery))
				{
					name = "Galleries";
					TitleSpan.InnerHtml = "galleries";
				}
				else if (Type.Equals(ArchiveObjectType.Article))
				{
					if (IsMixmagArchive)
					{
						name = "Mixmag articles";
						TitleSpan.InnerHtml = " <a href=\"/pages/mixmag\"><img src=\"/gfx/logo-mixmag-small.png\" border=\"0\" align=\"absmiddle\" width=\"100\" height=\"22\"></a> articles";
					}
					else
					{
						name = "Articles";
						TitleSpan.InnerHtml = "articles";
					}
				}
				else if (Type.Equals(ArchiveObjectType.Comp))
				{
					name = "Competitions";
					TitleSpan.InnerHtml = "competitions";
				}
				else if (Type.Equals(ArchiveObjectType.News))
				{
					name = "News";
					TitleSpan.InnerHtml = "news";
				}
				else if (Type.Equals(ArchiveObjectType.Review))
				{
					name = "Reviews";
					TitleSpan.InnerHtml = "reviews";
				}
				else if (Type.Equals(ArchiveObjectType.Guestlist))
				{
					name = "Guestlists";
					TitleSpan.InnerHtml = "guestlists";
				}

				name += " archive";
				TitleSpan.InnerHtml += " archive";

				if (ContainerPage.Url.HasObjectFilter && ContainerPage.Url.ObjectFilterBob is IHasArchive)
					name += " for " + ((IName)ContainerPage.Url.ObjectFilterBob).FriendlyName;

				if (ContainerPage.Url.HasCountryObjectFilter)
				{
					TitleSpan.InnerHtml += " for <a href=\"" + ContainerPage.Url.ObjectFilterCountry.Url() + "\">" + ContainerPage.Url.ObjectFilterCountry.FriendlyName + "</a>";
				}
				else if (ContainerPage.Url.HasPlaceObjectFilter)
				{
					TitleSpan.InnerHtml += " for <a href=\"" + ContainerPage.Url.ObjectFilterPlace.Url() + "\">" + ContainerPage.Url.ObjectFilterPlace.Name + "</a>";
				}
				else if (ContainerPage.Url.HasVenueObjectFilter)
				{
					TitleSpan.InnerHtml += " for <a href=\"" + ContainerPage.Url.ObjectFilterVenue.Url() + "\">" + ContainerPage.Url.ObjectFilterVenue.Name + "</a> in <a href=\"" + ContainerPage.Url.ObjectFilterVenue.Place.Url() + "\">" + ContainerPage.Url.ObjectFilterVenue.Place.Name + "</a>";
				}
				else if (ContainerPage.Url.HasObjectFilter && ContainerPage.Url.ObjectFilterBob is IPage && ContainerPage.Url.ObjectFilterBob is IName)
				{
					TitleSpan.InnerHtml += " for <a href=\"" + ((IPage)ContainerPage.Url.ObjectFilterBob).Url() + "\">" + ((IName)ContainerPage.Url.ObjectFilterBob).Name + "</a>";
				}

				name += " - " + ContainerPage.Url.DateFilter.ToString("MMMM") + " " + ContainerPage.Url.DateFilter.Year.ToString();

				Header.InnerText = name;
				ContainerPage.SetPageTitle(name);

				#region firstCellDate, lastCellDate
				DateTime firstOfMonth = new DateTime(ContainerPage.Url.DateFilter.Year, ContainerPage.Url.DateFilter.Month, 1);
				DateTime firstCellDate = firstOfMonth.AddDays(-(int)firstOfMonth.DayOfWeek + 1);
				if (firstOfMonth.DayOfWeek.Equals(DayOfWeek.Sunday))
					firstCellDate = firstOfMonth.AddDays(-6);

				DateTime lastOfMonth = firstOfMonth.AddDays(System.DateTime.DaysInMonth(ContainerPage.Url.DateFilter.Year, ContainerPage.Url.DateFilter.Month) - 1);
				int daysToAdd = 7 - (int)lastOfMonth.DayOfWeek;
				if (daysToAdd == 7)
					daysToAdd = 0;
				DateTime lastCellDate = lastOfMonth.AddDays(daysToAdd);
				if (lastOfMonth.DayOfWeek.Equals(DayOfWeek.Sunday))
					lastCellDate = lastOfMonth;
				#endregion

				Query queryAll = new Query();
				queryAll.QueryCondition = new And(
					ObjectFilter,
					GeneralFilter,
					new Q(DateColumn, QueryOperator.GreaterThanOrEqualTo, firstCellDate),
					new Q(DateColumn, QueryOperator.LessThan, lastCellDate.AddDays(1))
				);
				queryAll.OrderBy = OrderBy;
				queryAll.TableElement = TableElement;

				BobSet bs = null;
				if (Type.Equals(ArchiveObjectType.Gallery))
					bs = new GallerySet(queryAll);
				else if (Type.Equals(ArchiveObjectType.Article))
					bs = new ArticleSet(queryAll);
				else if (Type.Equals(ArchiveObjectType.Comp))
					bs = new CompSet(queryAll);
				else if (Type.Equals(ArchiveObjectType.News) || Type.Equals(ArchiveObjectType.Review))
					bs = new ThreadSet(queryAll);
				else if (Type.Equals(ArchiveObjectType.Guestlist))
					bs = new EventSet(queryAll);

				ItemsHiddenP.Visible = bs.Count > 150;

				if (ContainerPage.Url.HasDayFilter)
				{
					Query queryDay = new Query();
					queryDay.QueryCondition = new And(
						ObjectFilter,
						GeneralFilter,
						new Q(DateColumn, QueryOperator.GreaterThanOrEqualTo, ContainerPage.Url.DateFilter),
						new Q(DateColumn, QueryOperator.LessThan, ContainerPage.Url.DateFilter.AddDays(1))
					);
					queryDay.OrderBy = OrderBy;
					queryDay.TableElement = TableElement;

					if (Type.Equals(ArchiveObjectType.Gallery))
						DayRepeater.DataSource = new GallerySet(queryDay);
					else if (Type.Equals(ArchiveObjectType.Article))
						DayRepeater.DataSource = new ArticleSet(queryDay);
					else if (Type.Equals(ArchiveObjectType.Comp))
						DayRepeater.DataSource = new CompSet(queryDay);
					else if (Type.Equals(ArchiveObjectType.News) || Type.Equals(ArchiveObjectType.Review))
						DayRepeater.DataSource = new ThreadSet(queryDay);
					else if (Type.Equals(ArchiveObjectType.Guestlist))
						DayRepeater.DataSource = new EventSet(queryDay);

					DayRepeater.DataBind();
				}
				else
					DayItemsP.Visible = false;


				Arch.ShowCountry = ShowCountry;
				Arch.ShowPlace = ShowPlace;
				Arch.ShowVenue = ShowVenue;
				Arch.ShowEvent = ShowEvent;
				Arch.Objects = bs;
				Arch.Type = Type;
				Arch.Month = ContainerPage.Url.DateFilter.Month;
				Arch.StartDate = firstCellDate;
				Arch.EndDate = lastCellDate;

				MonthNameLabel.Text = firstOfMonth.ToString("MMMM") + " " + ContainerPage.Url.DateFilter.Year.ToString();
				MonthNameLabel1.Text = firstOfMonth.ToString("MMMM") + " " + ContainerPage.Url.DateFilter.Year.ToString();

				BackLink.InnerHtml = "&lt; " + firstOfMonth.AddDays(-1).ToString("MMMM");
				BackLink1.InnerHtml = "&lt; " + firstOfMonth.AddDays(-1).ToString("MMMM");
				BackLink.HRef = Link(firstOfMonth.AddDays(-1).Year, firstOfMonth.AddDays(-1).Month, 0, Type);
				BackLink1.HRef = Link(firstOfMonth.AddDays(-1).Year, firstOfMonth.AddDays(-1).Month, 0, Type);

				NextLink.InnerHtml = lastOfMonth.AddDays(1).ToString("MMMM") + " &gt;";
				NextLink1.InnerHtml = lastOfMonth.AddDays(1).ToString("MMMM") + " &gt;";
				NextLink.HRef = Link(lastOfMonth.AddDays(1).Year, lastOfMonth.AddDays(1).Month, 0, Type);
				NextLink1.HRef = Link(lastOfMonth.AddDays(1).Year, lastOfMonth.AddDays(1).Month, 0, Type);

				#region Set up back / next buttons
				if (bs.Count == 0)
				{
					#region moreFutureBs
					Query moreFutureQuery = new Query();
					moreFutureQuery.QueryCondition = new And(
						ObjectFilter,
						GeneralFilter,
						new Q(DateColumn, QueryOperator.GreaterThanOrEqualTo, new DateTime(lastOfMonth.AddDays(1).Year, lastOfMonth.AddDays(1).Month, 1))
						);
					moreFutureQuery.TopRecords = 1;
					moreFutureQuery.OrderBy = new OrderBy(DateColumn, OrderBy.OrderDirection.Ascending);
					moreFutureQuery.TableElement = TableElement;
					BobSet moreFutureBs = null;
					if (Type.Equals(ArchiveObjectType.Gallery))
						moreFutureBs = new GallerySet(moreFutureQuery);
					else if (Type.Equals(ArchiveObjectType.Article))
						moreFutureBs = new ArticleSet(moreFutureQuery);
					else if (Type.Equals(ArchiveObjectType.Comp))
						moreFutureBs = new CompSet(moreFutureQuery);
					else if (Type.Equals(ArchiveObjectType.News) || Type.Equals(ArchiveObjectType.Review))
						moreFutureBs = new ThreadSet(moreFutureQuery);
					else if (Type.Equals(ArchiveObjectType.Guestlist))
						moreFutureBs = new EventSet(moreFutureQuery);
					#endregion
					#region morePastBs
					Query morePastQuery = new Query();
					morePastQuery.QueryCondition = new And(
						ObjectFilter,
						GeneralFilter,
						new Q(DateColumn, QueryOperator.LessThan, new DateTime(ContainerPage.Url.DateFilter.Year, ContainerPage.Url.DateFilter.Month, 1))
					);
					morePastQuery.TopRecords = 1;
					morePastQuery.OrderBy = new OrderBy(DateColumn, OrderBy.OrderDirection.Descending);
					morePastQuery.TableElement = TableElement;
					BobSet morePastBs = null;
					if (Type.Equals(ArchiveObjectType.Gallery))
						morePastBs = new GallerySet(morePastQuery);
					else if (Type.Equals(ArchiveObjectType.Article))
						morePastBs = new ArticleSet(morePastQuery);
					else if (Type.Equals(ArchiveObjectType.Comp))
						morePastBs = new CompSet(morePastQuery);
					else if (Type.Equals(ArchiveObjectType.News) || Type.Equals(ArchiveObjectType.Review))
						morePastBs = new ThreadSet(morePastQuery);
					else if (Type.Equals(ArchiveObjectType.Guestlist))
						morePastBs = new EventSet(morePastQuery);
					#endregion

					if (morePastBs.Count == 0)
					{
						BackLink.HRef = "";
						BackLink1.HRef = "";
						BackLink.Disabled = true;
						BackLink1.Disabled = true;
					}
					else
					{
						IArchive latest = (IArchive)morePastBs.GetFromIndex(0);
						BackLink.HRef = Link(latest.ArchiveDateTime.Year, latest.ArchiveDateTime.Month, 0, Type);
						BackLink1.HRef = Link(latest.ArchiveDateTime.Year, latest.ArchiveDateTime.Month, 0, Type);
						BackLink.InnerHtml = "&lt; " + latest.ArchiveDateTime.ToString("MMMM");
						BackLink1.InnerHtml = "&lt; " + latest.ArchiveDateTime.ToString("MMMM");
						if (latest.ArchiveDateTime.Year != ContainerPage.Url.DateFilter.Year)
						{
							BackLink.InnerHtml = "&lt; " + latest.ArchiveDateTime.ToString("MMMM") + " " + latest.ArchiveDateTime.Year.ToString();
							BackLink1.InnerHtml = "&lt; " + latest.ArchiveDateTime.ToString("MMMM") + " " + latest.ArchiveDateTime.Year.ToString();
						}
					}

					if (moreFutureBs.Count == 0)
					{
						NextLink.HRef = "";
						NextLink1.HRef = "";
						NextLink.Disabled = true;
						NextLink1.Disabled = true;
					}
					else
					{
						IArchive first = (IArchive)moreFutureBs.GetFromIndex(0);
						NextLink.HRef = Link(first.ArchiveDateTime.Year, first.ArchiveDateTime.Month, 0, Type);
						NextLink1.HRef = Link(first.ArchiveDateTime.Year, first.ArchiveDateTime.Month, 0, Type);
						NextLink.InnerHtml = first.ArchiveDateTime.ToString("MMMM") + " &gt;";
						NextLink1.InnerHtml = first.ArchiveDateTime.ToString("MMMM") + " &gt;";
						if (first.ArchiveDateTime.Year != ContainerPage.Url.DateFilter.Year)
						{
							NextLink.InnerHtml = first.ArchiveDateTime.ToString("MMMM") + " " + first.ArchiveDateTime.Year.ToString() + " &gt;";
							NextLink1.InnerHtml = first.ArchiveDateTime.ToString("MMMM") + " " + first.ArchiveDateTime.Year.ToString() + " &gt;";
						}
					}
					if (BackLink.Disabled)
						BackLink.Attributes["class"] = "DisabledAnchor";
					if (BackLink1.Disabled)
						BackLink1.Attributes["class"] = "DisabledAnchor";
					if (NextLink.Disabled)
						NextLink.Attributes["class"] = "DisabledAnchor";
					if (NextLink1.Disabled)
						NextLink1.Attributes["class"] = "DisabledAnchor";
				}
				#endregion
			}
		}
Пример #9
0
		void ArticleListBind()
		{
			if (EnsureSecure)
			{
				Query q = new Query();
				q.QueryCondition = new Q(Article.Columns.EventK, CurrentEvent.K);
				q.OrderBy = new OrderBy(Article.Columns.AddedDateTime, OrderBy.OrderDirection.Descending);
				ArticleSet ars = new ArticleSet(q);
				ArticlePanel.Visible = ars.Count > 0;
				NoArticlePanel.Visible = ars.Count == 0;
				if (ars.Count > 0)
				{
					ArticleDataGrid.AllowPaging = ars.Count > ArticleDataGrid.PageSize;
					ArticleDataGrid.DataSource = ars;
					ArticleDataGrid.DataBind();
				}
			}
		}
Пример #10
0
		public void DeleteAll(Transaction transaction)
		{
			if (!this.Bob.DbRecordExists)
				return;

			// TicketRuns and Tickets
			this.ticketRuns = null;
			if (this.TicketRuns != null && this.TicketRuns.Count > 0)
			{
				foreach (TicketRun tr in this.TicketRuns)
				{
					if (tr.Status != TicketRun.TicketRunStatus.Ended)
						throw new DsiUserFriendlyException("Cannot delete an event that has ticket runs that have not ended.");

					if (tr.SoldTickets > 0 || tr.Tickets.Count > 0)
						throw new DsiUserFriendlyException("Cannot delete an event that has ticket runs that have sold tickets.");
				}

				Delete TicketRunDelete = new Delete(TablesEnum.TicketRun, new Q(TicketRun.Columns.EventK, this.K));
				TicketRunDelete.Run(transaction);
			}
			//EventBrands
			Delete BrandDelete = new Delete(
				TablesEnum.EventBrand,
				new Q(EventBrand.Columns.EventK, this.K)
				);
			BrandDelete.Run(transaction);

			//UsrEventAttended
			Delete UsrEventAttendedDelete = new Delete(
				TablesEnum.UsrEventAttended,
				new Q(UsrEventAttended.Columns.EventK, this.K)
				);
			UsrEventAttendedDelete.Run(transaction);

			//Galleries
			foreach (Gallery g in this.AllGalleries)
				g.DeleteAll(transaction);

			//Threads
			ThreadSet ts = new ThreadSet(new Query(new And(new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Event), new Q(Thread.Columns.ParentObjectK, this.K))));
			foreach (Thread t in ts)
				t.DeleteAll(transaction);

			//EventMusicType
			Delete EventMusicTypeDelete = new Delete(
				TablesEnum.EventMusicType,
				new Q(EventMusicType.Columns.EventK, this.K)
			);
			EventMusicTypeDelete.Run(transaction);

			
			//delete CommentAlerts
			Delete CommentAlertDelete = new Delete(
				TablesEnum.CommentAlert,
				new And(
					new Q(CommentAlert.Columns.ParentObjectK, this.K),
					new Q(CommentAlert.Columns.ParentObjectType, Model.Entities.ObjectType.Event)
				)
			);
			CommentAlertDelete.Run(transaction);

			//Articles
			ArticleSet ars = new ArticleSet(new Query(new Q(Article.Columns.EventK, this.K)));
			foreach (Article a in ars)
				a.DeleteAll(transaction);

			Guid oldPic = this.HasPic ? this.Pic : Guid.Empty;
			int oldPicMiscK = this.PicMisc != null ? this.PicMiscK : 0;

			this.Delete(transaction);

			if (oldPic != Guid.Empty)
				Storage.RemoveFromStore(Storage.Stores.Pix, oldPic, "jpg");

			if (oldPicMiscK > 0)
			{
				Misc m = new Misc(oldPicMiscK);
				m.DeleteAll(transaction);
			}

			this.Venue.UpdateTotalEvents(transaction);
			this.Owner.UpdateEventCount(transaction);

		}
Пример #11
0
		private void Page_Load(object sender, System.EventArgs e)
		{
			Response.ContentType = "text/xml";
			Response.Clear();
			Response.Buffer = false;

			XmlTextWriter x = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
			x.Formatting = Formatting.Indented;
			x.WriteRaw("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");

			string dateFormat = "yyyy-MM-ddTHH:mm:sszzz";

			if (Request.QueryString[0].Equals("index"))
			{
				#region sitemapindex
				x.WriteStartElement("sitemapindex");
				x.WriteAttributeString("xmlns", "http://www.google.com/schemas/sitemap/0.84");

				if (true)
				{
					#region sitemap - countries
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?country");
					Query q = new Query();
					q.QueryCondition = new And(
						new Q(Thread.Columns.Private, false),
						new Q(Thread.Columns.PrivateGroup, false),
						new Q(Thread.Columns.GroupPrivate, false)
						);
					q.OrderBy = new OrderBy(Thread.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					ThreadSet bobset = new ThreadSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat));
					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - place
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?place");

					Query q = new Query();
					q.OrderBy = new OrderBy(Place.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					PlaceSet bobset = new PlaceSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat));

					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - venue
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?venue");

					Query q = new Query();
					q.OrderBy = new OrderBy(Venue.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					VenueSet bobset = new VenueSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat));

					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - event
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?event");

					Query q = new Query();
					q.OrderBy = new OrderBy(Event.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					EventSet bobset = new EventSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat));

					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - thread
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?thread");

					Query q = new Query();
					q.QueryCondition = new And(
						new Q(Thread.Columns.Private, false),
						new Q(Thread.Columns.PrivateGroup, false),
						new Q(Thread.Columns.GroupPrivate, false)
						);
					q.OrderBy = new OrderBy(Thread.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					ThreadSet bobset = new ThreadSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat));

					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - photo
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?photo");

					Query q = new Query();
					q.QueryCondition = Photo.EnabledQueryCondition;
					q.OrderBy = new OrderBy(Photo.Columns.EnabledDateTime, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					PhotoSet bobset = new PhotoSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].EnabledDateTime.ToString(dateFormat));

					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - usr
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?usr");
					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - article
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?article");

					Query q = new Query();
					q.QueryCondition = Article.EnabledQueryCondition;
					q.OrderBy = new OrderBy(Article.Columns.EnabledDateTime, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					ArticleSet bobset = new ArticleSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].EnabledDateTime.ToString(dateFormat));

					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - comp
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?comp");
					x.WriteEndElement();	//sitemap
					#endregion
				}

				if (true)
				{
					#region sitemap - brand
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?brand");

					Query q = new Query();
					q.OrderBy = new OrderBy(Brand.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					BrandSet bobset = new BrandSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat));

					x.WriteEndElement();	//sitemap
					#endregion
				}


				if (true)
				{
					#region sitemap - group
					x.WriteStartElement("sitemap");
					x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?group");

					Query q = new Query();
					q.QueryCondition = new And(
						new Q(Group.Columns.BrandK, 0),
						new Q(Group.Columns.PrivateGroupPage, false));
					q.OrderBy = new OrderBy(Group.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.TopRecords = 1;
					GroupSet bobset = new GroupSet(q);
					if (bobset.Count > 0)
						x.WriteElementString("lastmod", bobset[0].LastPost.Value.ToString(dateFormat));

					x.WriteEndElement();	//sitemap
					#endregion
				}

				x.WriteEndElement();	//sitemapindex
				#endregion
			}
			else
			{
				#region urlset
				x.WriteStartElement("urlset");
				x.WriteAttributeString("xmlns", "http://www.google.com/schemas/sitemap/0.84");

				#region Countries
				if (Request.QueryString[0].Equals("country"))
				{
					if (true)
					{
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com/");
						Query q = new Query();
						q.QueryCondition = new And(
							new Q(Thread.Columns.Private, false),
							new Q(Thread.Columns.PrivateGroup, false),
							new Q(Thread.Columns.GroupPrivate, false)
							);
						q.OrderBy = new OrderBy(Thread.Columns.LastPost, OrderBy.OrderDirection.Descending);
						q.TopRecords = 1;
						ThreadSet bobset = new ThreadSet(q);
						if (bobset.Count > 0)
							x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat));
						x.WriteElementString("changefreq", "hourly");
						x.WriteEndElement();	//url
						#endregion
					}

					if (true)
					{
						Query q = new Query();
						q.QueryCondition = new Q(Country.Columns.TotalEvents, QueryOperator.GreaterThan, 0);
						q.OrderBy = new OrderBy(Country.Columns.TotalEvents, OrderBy.OrderDirection.Descending);
						q.Columns = new ColumnSet(Country.LinkColumns, Country.Columns.TotalEvents);
						if (Vars.DevEnv)
							q.TopRecords = 10;
						CountrySet bobset = new CountrySet(q);
						for (int i = 0; i < bobset.Count; i++)
						{
							Country p = bobset[i];
							#region url
							x.WriteStartElement("url");
							x.WriteElementString("loc", "http://www.dontstayin.com" + p.Url());
							if (p.TotalEvents > 100)
								x.WriteElementString("changefreq", "hourly");
							else if (p.TotalEvents > 20)
								x.WriteElementString("changefreq", "daily");
							else if (p.TotalEvents > 10)
								x.WriteElementString("changefreq", "weekly");
							else
								x.WriteElementString("changefreq", "monthly");
							x.WriteEndElement();	//url
							#endregion
							bobset.Kill(i);
						}
					}
				}
				#endregion

				#region Places
				if (Request.QueryString[0].Equals("place"))
				{
					Query q = new Query();
					q.QueryCondition = new Or(
						new Q(Place.Columns.TotalComments, QueryOperator.GreaterThan, 0),
						new Q(Place.Columns.TotalEvents, QueryOperator.GreaterThan, 0));
					q.OrderBy = new OrderBy(Place.Columns.TotalComments, OrderBy.OrderDirection.Descending);
					q.Columns = new ColumnSet(Place.LinkColumns, Place.Columns.LastPost);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 40000;
					PlaceSet bobset = new PlaceSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Place p = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + p.Url());
						if (p.LastPost != DateTime.MinValue)
						{
							x.WriteElementString("lastmod", p.LastPost.ToString(dateFormat));
							TimeSpan ts = DateTime.Now.Subtract(p.LastPost);
							if (ts.TotalHours < 24)
								x.WriteElementString("changefreq", "hourly");
							else if (ts.TotalDays < 7)
								x.WriteElementString("changefreq", "daily");
							else if (ts.TotalDays < 30)
								x.WriteElementString("changefreq", "weekly");
							else
								x.WriteElementString("changefreq", "monthly");
						}
						else
							x.WriteElementString("changefreq", "monthly");
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Venues
				if (Request.QueryString[0].Equals("venue"))
				{
					Query q = new Query();
					q.OrderBy = new OrderBy(Venue.Columns.TotalEvents, OrderBy.OrderDirection.Descending);
					q.Columns = new ColumnSet(Venue.LinkColumns, Venue.Columns.LastPost, Venue.Columns.TotalEvents);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 40000;
					VenueSet bobset = new VenueSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Venue v = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + v.Url());
						if (v.LastPost != DateTime.MinValue)
						{
							x.WriteElementString("lastmod", v.LastPost.ToString(dateFormat));
							TimeSpan ts = DateTime.Now.Subtract(v.LastPost);
							if (ts.TotalHours < 24)
								x.WriteElementString("changefreq", "hourly");
							else if (ts.TotalDays < 7)
								x.WriteElementString("changefreq", "daily");
							else if (ts.TotalDays < 30)
								x.WriteElementString("changefreq", "weekly");
							else
								x.WriteElementString("changefreq", "monthly");
						}
						else if (v.TotalEvents > 10)
							x.WriteElementString("changefreq", "weekly");
						else
							x.WriteElementString("changefreq", "monthly");

						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Events
				if (Request.QueryString[0].Equals("event"))
				{
					Query q = new Query();
					q.OrderBy = new OrderBy(Event.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.Columns = new ColumnSet(Event.LinkColumns, Event.Columns.LastPost, Event.Columns.DateTime);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 40000;
					EventSet bobset = new EventSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Event ev = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + ev.Url());
						if (ev.LastPost != DateTime.MinValue)
						{
							x.WriteElementString("lastmod", ev.LastPost.ToString(dateFormat));
							TimeSpan ts = DateTime.Now.Subtract(ev.LastPost);
							if (ts.TotalHours < 24)
								x.WriteElementString("changefreq", "hourly");
							else if (ts.TotalDays < 7)
								x.WriteElementString("changefreq", "daily");
							else if (ts.TotalDays < 30)
								x.WriteElementString("changefreq", "weekly");
							else
								x.WriteElementString("changefreq", "monthly");
						}
						else
							x.WriteElementString("changefreq", "monthly");
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Threads
				if (Request.QueryString[0].Equals("thread"))
				{
					Query q = new Query();
					q.QueryCondition = new And(
						new Q(Thread.Columns.Private, false),
						new Q(Thread.Columns.PrivateGroup, false),
						new Q(Thread.Columns.GroupPrivate, false)
					);
					q.Columns = new ColumnSet(Thread.Columns.K, Thread.Columns.UrlFragment, Thread.Columns.TotalComments, Thread.Columns.LastPost);
					q.OrderBy = new OrderBy(Thread.Columns.LastPost, OrderBy.OrderDirection.Descending);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 40000;
					ThreadSet bobset = new ThreadSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Thread t = bobset[i];
						#region url
						x.WriteStartElement("url");
						if (t.LastPage == 1)
							x.WriteElementString("loc", "http://www.dontstayin.com" + t.Url());
						else
							x.WriteElementString("loc", "http://www.dontstayin.com" + t.Url("c", t.LastPage.ToString()));
						x.WriteElementString("lastmod", t.LastPost.ToString(dateFormat));
						TimeSpan ts = DateTime.Now.Subtract(t.LastPost);
						if (ts.TotalHours < 24)
							x.WriteElementString("changefreq", "hourly");
						else if (ts.TotalDays < 7)
							x.WriteElementString("changefreq", "daily");
						else if (ts.TotalDays < 30)
							x.WriteElementString("changefreq", "weekly");
						else
							x.WriteElementString("changefreq", "monthly");
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Photos
				if (Request.QueryString[0].Equals("photo"))
				{
					Query q = new Query();
					q.QueryCondition = Photo.EnabledQueryCondition;
					q.Columns = new ColumnSet(Photo.Columns.K, Photo.Columns.UrlFragment, Photo.Columns.EventK, Photo.Columns.ArticleK);
					q.OrderBy = new OrderBy(Photo.Columns.EnabledDateTime, OrderBy.OrderDirection.Descending);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 50000;
					PhotoSet bobset = new PhotoSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Photo p = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + p.Url());
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Usrs
				if (Request.QueryString[0].Equals("usr"))
				{
					Query q = new Query();
					q.QueryCondition = new And(
						new Q(Usr.Columns.IsSkeleton, false),
						new Q(Usr.Columns.IsEmailVerified, true),
						new Or(
						new Q(Usr.Columns.Pic, QueryOperator.NotEqualTo, Guid.Empty),
						new Q(Usr.Columns.CommentCount, QueryOperator.NotEqualTo, 0)
						)
					);
					q.Columns = new ColumnSet(Usr.Columns.NickName);
					q.OrderBy = new OrderBy(Usr.Columns.DateTimeLastPageRequest, OrderBy.OrderDirection.Descending);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 50000;
					UsrSet bobset = new UsrSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Usr u = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + u.Url());
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Articles
				if (Request.QueryString[0].Equals("article"))
				{
					Query q = new Query();
					q.QueryCondition = Article.EnabledQueryCondition;
					q.Columns = new ColumnSet(Article.Columns.UrlFragment,
					Article.Columns.ParentObjectK,
					Article.Columns.ParentObjectType, Article.Columns.K);
					q.OrderBy = new OrderBy(Article.Columns.EnabledDateTime, OrderBy.OrderDirection.Descending);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 50000;
					ArticleSet bobset = new ArticleSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Article a = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + a.Url());
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Competitions
				if (Request.QueryString[0].Equals("comp"))
				{
					Query q = new Query();
					q.QueryCondition = new Q(Comp.Columns.Status, Comp.StatusEnum.Enabled);
					q.Columns = new ColumnSet(Comp.Columns.K);
					q.OrderBy = new OrderBy(Comp.Columns.DateTimeClose, OrderBy.OrderDirection.Descending);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 50000;
					CompSet bobset = new CompSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Comp c = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + c.Url());
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Brands
				if (Request.QueryString[0].Equals("brand"))
				{
					Query q = new Query();
					q.OrderBy = new OrderBy(Brand.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.Columns = new ColumnSet(Brand.LinkColumns, Brand.Columns.LastPost);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 40000;
					BrandSet bobset = new BrandSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Brand b = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + b.Url());
						if (b.LastPost > DateTime.MinValue)
						{
							x.WriteElementString("lastmod", b.LastPost.ToString(dateFormat));
							TimeSpan ts = DateTime.Now.Subtract(b.LastPost);
							if (ts.TotalHours < 24)
								x.WriteElementString("changefreq", "hourly");
							else if (ts.TotalDays < 7)
								x.WriteElementString("changefreq", "daily");
							else if (ts.TotalDays < 30)
								x.WriteElementString("changefreq", "weekly");
							else
								x.WriteElementString("changefreq", "monthly");
						}
						else
							x.WriteElementString("changefreq", "monthly");
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				#region Groups
				if (Request.QueryString[0].Equals("group"))
				{
					Query q = new Query();
					q.QueryCondition = new And(
						new Q(Group.Columns.BrandK, 0),
						new Q(Group.Columns.PrivateGroupPage, false));
					q.OrderBy = new OrderBy(Group.Columns.LastPost, OrderBy.OrderDirection.Descending);
					q.Columns = new ColumnSet(Group.Columns.BrandK, Group.Columns.UrlName, Group.Columns.LastPost);
					if (Vars.DevEnv)
						q.TopRecords = 10;
					else
						q.TopRecords = 40000;
					GroupSet bobset = new GroupSet(q);
					for (int i = 0; i < bobset.Count; i++)
					{
						Group g = bobset[i];
						#region url
						x.WriteStartElement("url");
						x.WriteElementString("loc", "http://www.dontstayin.com" + g.Url());
						if (g.LastPost.HasValue && g.LastPost > DateTime.MinValue)
						{
							x.WriteElementString("lastmod", g.LastPost.Value.ToString(dateFormat));
							TimeSpan ts = DateTime.Now.Subtract(g.LastPost.Value);
							if (ts.TotalHours < 24)
								x.WriteElementString("changefreq", "hourly");
							else if (ts.TotalDays < 7)
								x.WriteElementString("changefreq", "daily");
							else if (ts.TotalDays < 30)
								x.WriteElementString("changefreq", "weekly");
							else
								x.WriteElementString("changefreq", "monthly");
						}
						else
							x.WriteElementString("changefreq", "monthly");
						x.WriteEndElement();	//url
						#endregion
						bobset.Kill(i);
					}
				}
				#endregion

				x.WriteEndElement();	//urlset
				#endregion
			}
			x.Flush();
			x.Close();
			Response.End();

		}
Пример #12
0
		public void UpdateChildUrlFragments(bool Cascade)
		{
			Update uPlaces = new Update();
			uPlaces.Table=TablesEnum.Place;
			uPlaces.Changes.Add(new Assign(Place.Columns.UrlFragment,UrlFilterPart));
			uPlaces.Where=new Q(Place.Columns.CountryK,this.K);
			uPlaces.Run();

			if (Cascade)
			{
				Query q = new Query();
				q.NoLock=true;
				q.QueryCondition=new And(new Q(Place.Columns.CountryK,this.K),new Q(Place.Columns.Enabled,true));
				q.Columns=new ColumnSet(
					Place.Columns.K, 
					Place.Columns.UrlFragment, 
					Place.Columns.UrlName, 
					Place.Columns.RegionAbbreviation);
				PlaceSet ps = new PlaceSet(q);
				foreach (Place p in ps)
				{
					try
					{
						Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Place, p.K, true);
						job.ExecuteAsynchronously();
					}
					catch(Exception ex)
					{
						if (Vars.DevEnv)
							throw ex;
					}
				}
			}

			Update uThreads = new Update();
			uThreads.Table=TablesEnum.Thread;
			uThreads.Changes.Add(new Assign(Thread.Columns.UrlFragment,UrlFilterPart));
			uThreads.Where=new And(
				new Q(Thread.Columns.ParentObjectType,Model.Entities.ObjectType.Country),
				new Q(Thread.Columns.ParentObjectK,this.K));
			uThreads.Run();

			Update uArticles = new Update();
			uArticles.Table=TablesEnum.Article;
			uArticles.Changes.Add(new Assign(Article.Columns.UrlFragment,UrlFilterPart));
			uArticles.Where=new And(
				new Q(Article.Columns.ParentObjectType,Model.Entities.ObjectType.Country),
				new Q(Article.Columns.ParentObjectK,this.K));
			uArticles.Run();

			if (Cascade)
			{
				Query q = new Query();
				q.NoLock=true;
				q.QueryCondition=new And(
					new Q(Article.Columns.ParentObjectType,Model.Entities.ObjectType.Country),
					new Q(Article.Columns.ParentObjectK,this.K));
				q.Columns=new ColumnSet(
					Article.Columns.K, 
					Article.Columns.UrlFragment,
					Article.Columns.ParentObjectK,
					Article.Columns.ParentObjectType);
				ArticleSet aSet = new ArticleSet(q);
				foreach (Article a in aSet)
				{
					try
					{
						Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Article, a.K, true);
						job.ExecuteAsynchronously();
					}
					catch(Exception ex)
					{
						if (Vars.DevEnv)
							throw ex;
					}
				}
			}
		}
Пример #13
0
		public void MergeAndDelete(Event merge)
		{
			if (this.K == merge.K)
				throw new DsiUserFriendlyException("Can't merge event into itself!");

			Cambro.Web.Helpers.WriteAlertHeader();

			//throw new Exception("This function isn't finished yet!");

			Cambro.Web.Helpers.WriteAlert("Starting merge...", 1);

			#region Articles
			if (true)
			{

				Query q = new Query();
				q.QueryCondition = new Q(Article.Columns.EventK, merge.K);
				ArticleSet ars = new ArticleSet(q);
				foreach (Article a in ars)
				{
					Cambro.Web.Helpers.WriteAlert("Merging article " + a.K + "...", 2);
					a.ParentObjectK = this.K;
					a.EventK = this.K;

					if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Venue)
						a.VenueK = this.VenueK;
					else
						a.VenueK = 0;

					if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Place)
						a.PlaceK = this.Venue.PlaceK;
					else
						a.PlaceK = 0;

					if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Country)
						a.CountryK = this.Venue.Place.CountryK;
					else
						a.CountryK = 0;

					a.UrlFragment = this.UrlFilterPartVenueDate;
					a.Update();


					#region Threads
					if (true)
					{
						Update u = new Update();
						u.Table = TablesEnum.Thread;
						u.Where = new Q(Thread.Columns.ArticleK, a.K);
						u.Changes.Add(new Assign(Thread.Columns.UrlFragment, a.UrlFilterPart));
						u.Changes.Add(new Assign(Thread.Columns.EventK, this.K));
						u.Changes.Add(new Assign(Thread.Columns.VenueK, this.VenueK));
						u.Changes.Add(new Assign(Thread.Columns.PlaceK, this.Venue.PlaceK));
						u.Changes.Add(new Assign(Thread.Columns.CountryK, this.Venue.Place.CountryK));
						u.Run();
					}
					#endregion
					#region Galleries
					if (true)
					{
						Update u = new Update();
						u.Table = TablesEnum.Gallery;
						u.Where = new Q(Gallery.Columns.ArticleK, a.K);
						u.Changes.Add(new Assign(Gallery.Columns.UrlFragment, a.UrlFilterPart));
						u.Run();
					}
					#endregion
					#region Photos
					if (true)
					{
						Update u = new Update();
						u.Table = TablesEnum.Photo;
						u.Where = new Q(Photo.Columns.ArticleK, a.K);
						u.Changes.Add(new Assign(Photo.Columns.UrlFragment, a.UrlFilterPart));
						u.Run();
					}
					#endregion
				}
				Cambro.Web.Helpers.WriteAlert("Done merging articles...", 2);
			}
			#endregion
			#region Banners
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging banners...", 4);
				Update u = new Update();
				u.Table = TablesEnum.Banner;
				u.Where = new Q(Banner.Columns.EventK, merge.K);
				u.Changes.Add(new Assign(Banner.Columns.EventK, this.K));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging banners...", 4);
			}
			#endregion
			#region Comp
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging competitions...", 5);
				Update u = new Update();
				u.Table = TablesEnum.Comp;
				u.Where = new Q(Comp.Columns.EventK, merge.K);
				u.Changes.Add(new Assign(Comp.Columns.EventK, this.K));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging competitions...", 5);
			}
			#endregion
			#region EventMusicType
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging music types...", 6);
				Query q1 = new Query();
				q1.TableElement = MusicType.EventJoin;
				q1.QueryCondition = new Q(Event.Columns.K, merge.K);
				MusicTypeSet ems1 = new MusicTypeSet(q1);

				Query q2 = new Query();
				q2.TableElement = MusicType.EventJoin;
				q2.QueryCondition = new Q(Event.Columns.K, this.K);
				MusicTypeSet ems2 = new MusicTypeSet(q2);

				bool hasAllMuisc = false;
				ArrayList majorTypes = new ArrayList();
				ArrayList relevantTypes = new ArrayList();

				#region find major types
				foreach (MusicType mt in ems1)
				{
					if (mt.K == 1)
					{
						hasAllMuisc = true;
						break;
					}
					if (mt.ParentK == 1 && !majorTypes.Contains(mt.K))
						majorTypes.Add(mt.K);
				}
				if (!hasAllMuisc)
				{
					foreach (MusicType mt in ems2)
					{
						if (mt.K == 1)
						{
							hasAllMuisc = true;
							break;
						}
						if (mt.ParentK == 1 && !majorTypes.Contains(mt.K))
							majorTypes.Add(mt.K);
					}
				}
				#endregion
				if (!hasAllMuisc)
				{
					foreach (MusicType mt in ems1)
					{
						if (!majorTypes.Contains(mt.ParentK) && !relevantTypes.Contains(mt.K))
							relevantTypes.Add(mt.K);
					}
					foreach (MusicType mt in ems2)
					{
						if (!majorTypes.Contains(mt.ParentK) && !relevantTypes.Contains(mt.K))
							relevantTypes.Add(mt.K);
					}
				}
				if (hasAllMuisc || relevantTypes.Count == 0)
				{
					Delete d = new Delete(TablesEnum.EventMusicType, new Q(EventMusicType.Columns.EventK, this.K));
					d.Run();
					EventMusicType emt = new EventMusicType();
					emt.EventK = this.K;
					emt.MusicTypeK = 1;
					emt.Update();
				}
				else
				{
					Delete d = new Delete(TablesEnum.EventMusicType, new Q(EventMusicType.Columns.EventK, this.K));
					d.Run();
					foreach (int mtK in relevantTypes)
					{
						EventMusicType emt = new EventMusicType();
						emt.EventK = this.K;
						emt.MusicTypeK = mtK;
						emt.Update();
					}
				}
				Cambro.Web.Helpers.WriteAlert("Done merging music types...", 6);
			}
			#endregion
			#region EventBrand
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging brands...", 7);
				EventBrandSet ebs = new EventBrandSet(new Query(new Q(EventBrand.Columns.EventK, merge.K)));
				foreach (EventBrand eb in ebs)
				{
					try
					{
						EventBrand ebThis = new EventBrand(this.K, eb.BrandK);
					}
					catch
					{
						EventBrand ebThis = new EventBrand();
						ebThis.EventK = this.K;
						ebThis.BrandK = eb.BrandK;
						ebThis.Update();
					}
				}
				Cambro.Web.Helpers.WriteAlert("Done merging brands...", 7);
			}
			#endregion
			 
			#region Gallery
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging galleries...", 9);
				Update u = new Update();
				u.Table = TablesEnum.Gallery;
				u.Where = new Q(Gallery.Columns.EventK, merge.K);
				u.Changes.Add(new Assign(Gallery.Columns.EventK, this.K));
				u.Changes.Add(new Assign(Gallery.Columns.UrlFragment, this.UrlFilterPartVenueDate));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging galleries...", 9);
			}
			#endregion
			#region Photo
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging photos...", 10);
				Update u = new Update();
				u.Table = TablesEnum.Photo;
				u.Where = new Q(Photo.Columns.EventK, merge.K);
				u.Changes.Add(new Assign(Photo.Columns.EventK, this.K));
				u.Changes.Add(new Assign(Photo.Columns.UrlFragment, this.UrlFilterPartVenueDate));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging photos...", 10);
			}
			#endregion
			#region GroupEvent
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging group-event links...", 11);
				GroupEventSet ges = new GroupEventSet(new Query(new Q(GroupEvent.Columns.EventK, merge.K)));
				foreach (GroupEvent ge in ges)
				{
					try
					{
						GroupEvent geThis = new GroupEvent(ge.GroupK, this.K);
					}
					catch
					{
						GroupEvent geThis = new GroupEvent();
						geThis.EventK = this.K;
						geThis.GroupK = ge.GroupK;
						geThis.Update();
					}
				}
				Cambro.Web.Helpers.WriteAlert("Done merging group-event links...", 11);
			}
			#endregion
			#region Thread ParentObjects
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging topics (1/2)...", 12);
				Update u = new Update();
				u.Table = TablesEnum.Thread;
				u.Where = new And(
					new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Event),
					new Q(Thread.Columns.ParentObjectK, merge.K));
				u.Changes.Add(new Assign(Thread.Columns.ParentObjectK, this.K));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging topics (1/2)...", 12);
			}
			#endregion
			#region Thread
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging topics (2/2)...", 13);
				Update u = new Update();
				u.Table = TablesEnum.Thread;
				u.Where = new And(
					new Q(Thread.Columns.EventK, merge.K),
					new Q(Thread.Columns.ArticleK, 0));
				u.Changes.Add(new Assign(Thread.Columns.EventK, this.K));
				u.Changes.Add(new Assign(Thread.Columns.UrlFragment, this.UrlFilterPartVenueDate));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging topics (2/2)...", 13);
			}
			#endregion
			#region UsrEventAttended
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging members...", 14);
				UsrEventAttendedSet ueas = new UsrEventAttendedSet(new Query(new Q(UsrEventAttended.Columns.EventK, merge.K)));
				foreach (UsrEventAttended uea in ueas)
				{
					try
					{
						UsrEventAttended ueaThis = new UsrEventAttended(uea.UsrK, this.K);
						bool changed = false;
						if (!uea.SendUpdate && ueaThis.SendUpdate)
						{
							ueaThis.SendUpdate = false;
							changed = true;
						}
						if (uea.Spotter && !ueaThis.Spotter)
						{
							ueaThis.Spotter = true;
							changed = true;
						}
						if (changed)
							ueaThis.Update();
					}
					catch
					{
						UsrEventAttended ueaThis = new UsrEventAttended();
						ueaThis.EventK = this.K;
						ueaThis.UsrK = uea.UsrK;
						ueaThis.SendUpdate = uea.SendUpdate;
						ueaThis.Spotter = uea.Spotter;
						ueaThis.Update();
					}
				}
				Cambro.Web.Helpers.WriteAlert("Done merging members...", 14);
			}
			#endregion

			if (!this.HasPic)
			{
				Cambro.Web.Helpers.WriteAlert("Merging picture...", 15);
				this.Pic = merge.Pic;
				this.PicMiscK = merge.PicMiscK;
				this.PicPhotoK = merge.PicPhotoK;
				this.PicState = merge.PicState;
				merge.Pic = Guid.Empty;
				merge.PicMiscK = 0;
				merge.PicPhotoK = 0;
				merge.PicState = "";
				merge.Update();
				Cambro.Web.Helpers.WriteAlert("Done merging picture...", 15);
			}

			this.AdminNote += "Event " + merge.K + " was merged with this one " + DateTime.Now.ToString() + ". The admin note from event " + merge.K + " is:\n********************\n" + merge.AdminNote + "\n********************\n";

			if (!this.HasGuestlist && merge.HasGuestlist)
			{
				Cambro.Web.Helpers.WriteAlert("Merging guestlist...", 16);
				this.HasGuestlist = true;
				this.GuestlistOpen = merge.GuestlistOpen;
				this.GuestlistFinished = merge.GuestlistOpen;
				this.GuestlistLimit = merge.GuestlistLimit;
				this.GuestlistCount = merge.GuestlistCount;
				this.GuestlistDetails = merge.GuestlistDetails;
				this.GuestlistPromoterK = merge.GuestlistPromoterK;
				this.GuestlistRegularPrice = merge.GuestlistRegularPrice;
				this.GuestlistPrice = merge.GuestlistPrice;
				this.GuestlistPromotion = merge.GuestlistPromotion;

				Delete d = new Delete(TablesEnum.UsrEventGuestlist, new Q(UsrEventGuestlist.Columns.EventK, this.K));
				d.Run();

				Update u = new Update();
				u.Table = TablesEnum.UsrEventGuestlist;
				u.Where = new Q(UsrEventGuestlist.Columns.EventK, merge.K);
				u.Changes.Add(new Assign(UsrEventGuestlist.Columns.EventK, this.K));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging guestlist...", 16);
			}

			if (merge.Donated)
				this.Donated = true;

			if (merge.HasHilight)
				this.HasHilight = true;

			this.UpdateUsrAttendCount(false);

			this.Update();

			int mergeVenueK = merge.VenueK;

			Cambro.Web.Helpers.WriteAlert("Deleting old event...", 17);
			merge.DeleteAll(null);
			Cambro.Web.Helpers.WriteAlert("Done deleting old event...", 17);

			if (mergeVenueK != this.VenueK)
			{
				Venue mergeVenue = new Venue(mergeVenueK);
				Cambro.Web.Helpers.WriteAlert("Updating stats for old venue...", 18);
				mergeVenue.UpdateTotalComments(null);
				mergeVenue.UpdateTotalEvents(null);
				Cambro.Web.Helpers.WriteAlert("Done updating stats for old venue...", 18);
			}

			Cambro.Web.Helpers.WriteAlert("Updating stats for new event...", 19);
			this.UpdateMusicTypesStringNoUpdate();
			this.UpdateTotalComments(null);
			this.UpdateHasSpotter(null);
			this.UpdateTotalPhotos(null);
			this.Venue.UpdateTotalEvents(null);
			Cambro.Web.Helpers.WriteAlert("Done updating stats for new event...", 19);

			this.Update();
			Cambro.Web.Helpers.WriteAlert("Done merging events!", 20);


		}
Пример #14
0
		public string PromoterHtmlArticle(Promoter p)
		{
			Query q = new Query();
			q.QueryCondition = new And(new Q(Article.Columns.EventK, this.K), Article.EnabledQueryCondition);
			q.ReturnCountOnly = true;
			ArticleSet ars = new ArticleSet(q);
			return TickCrossHtml(ars.Count > 0);
		}
Пример #15
0
		public void UpdateChildUrlFragments(bool Cascade)
		{
			Update uGalleries = new Update();
			uGalleries.Table = TablesEnum.Gallery;
			uGalleries.Changes.Add(new Assign(Gallery.Columns.UrlFragment, UrlFilterPartVenueDate));
			uGalleries.Where = new Q(Gallery.Columns.EventK, this.K);
			uGalleries.Run();

			Update uPhotos = new Update();
			uPhotos.Table = TablesEnum.Photo;
			uPhotos.Changes.Add(new Assign(Photo.Columns.UrlFragment, UrlFilterPartVenueDate));
			uPhotos.Where = new Q(Photo.Columns.EventK, this.K);
			uPhotos.Run();

			Update uThreads = new Update();
			uThreads.Table = TablesEnum.Thread;
			uThreads.From = new Join(
				new TableElement(TablesEnum.Thread),
				new TableElement(TablesEnum.Photo),
				QueryJoinType.Left,
				Thread.Columns.PhotoK,
				Photo.Columns.K
			);
			uThreads.Changes.Add(new Assign(Thread.Columns.UrlFragment, UrlFilterPart));
			uThreads.Where = new Or(
				new Q(Photo.Columns.EventK, this.K),
				new And(
					new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Event),
					new Q(Thread.Columns.ParentObjectK, this.K)
				)
			);
			uThreads.Run();

			Update uArticles = new Update();
			uArticles.Table = TablesEnum.Article;
			uArticles.Changes.Add(new Assign(Article.Columns.UrlFragment, UrlFilterPartVenueDate));
			uArticles.Where = new And(
				new Q(Article.Columns.ParentObjectType, Model.Entities.ObjectType.Event),
				new Q(Article.Columns.ParentObjectK, this.K));
			uArticles.Run();

			if (Cascade)
			{
				Query q = new Query();
				q.NoLock = true;
				q.QueryCondition = new And(
					new Q(Article.Columns.ParentObjectType, Model.Entities.ObjectType.Event),
					new Q(Article.Columns.ParentObjectK, this.K));
				q.Columns = new ColumnSet(
					Article.Columns.K,
					Article.Columns.UrlFragment,
					Article.Columns.ParentObjectK,
					Article.Columns.ParentObjectType);
				ArticleSet aSet = new ArticleSet(q);
				foreach (Article a in aSet)
				{
					try
					{
						Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Article, a.K, true);
						job.ExecuteAsynchronously();
					}
					catch (Exception ex)
					{
						if (Vars.DevEnv)
							throw ex;
					}
				}
			}
		}
Пример #16
0
		private void ArticlesPanel_Load(object o, EventArgs e)
		{
			if (OnlyShowThreads)
			{
				ArticlesPanel.Visible = false;
				return;
			}
			Query q = new Query();
			Q RelevanceQ = null;
			Q NewArticlesQ = new Q(true);
			if (Discussable == null)
			{
				RelevanceQ = new Q(Article.Columns.Relevance, Article.RelevanceEnum.Worldwide);
				NewArticlesQ = new NotQ(new And(new Q(Article.Columns.ShowAboveFoldOnFrontPage, true), new Q(Article.Columns.EnabledDateTime, QueryOperator.GreaterThan, DateTime.Now.AddHours(-48))));//new Q(Article.Columns.ShowAboveFoldOnFrontPage, false);
				
			}
			else if (Discussable.UsedDiscussable is Country)
				RelevanceQ = new Q(Article.Columns.CountryK, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Place)
				RelevanceQ = new Q(Article.Columns.PlaceK, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Venue)
				RelevanceQ = new Q(Article.Columns.VenueK, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Event)
				RelevanceQ = new Q(Article.Columns.EventK, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Brand)
			{
				RelevanceQ = new Q(Brand.Columns.K, Discussable.UsedDiscussable.K);
				q.TableElement = new Join(
						new TableElement(TablesEnum.Article),
						Event.BrandJoin,
						QueryJoinType.Inner,
						Article.Columns.EventK,
						Event.Columns.K);
			}
			else if (Discussable.UsedDiscussable is Group)
			{

				RelevanceQ = new Q(Group.Columns.K, Discussable.UsedDiscussable.K);
				q.TableElement = new Join(
					new TableElement(TablesEnum.Article),
					Event.GroupJoin,
					QueryJoinType.Inner,
					Article.Columns.EventK,
					Event.Columns.K);
			}

			q.Columns = Templates.Articles.LatestNew.Columns;
			q.TableElement = Templates.Articles.LatestNew.PerformJoins(q.TableElement);

			q.QueryCondition = new And(
				Article.EnabledQueryCondition,
				RelevanceQ,
				NewArticlesQ
				);
			q.OrderBy = new OrderBy(Article.Columns.EnabledDateTime, OrderBy.OrderDirection.Descending);
			q.TopRecords = ArticleCount;
			ArticleSet ars = new ArticleSet(q);

			if (ars.Count == 0)
			{
				ArticlesPanel.Visible = false;
			}
			else
			{
				if (Discussable == null)
				{
					ArticlesArchiveUrl = Archive.GetUrl(ars[0].EnabledDateTime.Year, ars[0].EnabledDateTime.Month, 0, ArchiveObjectType.Article, new string[] { }, "");
				}
				else if (Discussable.UsedDiscussable is IHasArchive && ars.Count == ArticleCount)
				{
					ArticlesArchiveUrl = ((IHasArchive)Discussable.UsedDiscussable).UrlArchiveDate(ars[0].EnabledDateTime.Year, ars[0].EnabledDateTime.Month, 0, ArchiveObjectType.Article);
				}
				else
				{
					ArticlesArchiveVisible = false;
				}

				ArticlesDataList.DataSource = ars;
				ArticlesDataList.ItemTemplate = this.LoadTemplate("/Templates/Articles/LatestNew.ascx");
				ArticlesDataList.DataBind();

			}
		}
Пример #17
0
		public void UpdateChildUrlFragments(bool Cascade)
		{
			Update uEvents = new Update();
			uEvents.Table=TablesEnum.Event;
			uEvents.Changes.Add(new Assign(Event.Columns.UrlFragment,UrlFilterPart));
			uEvents.Where=new Q(Event.Columns.VenueK,this.K);
			uEvents.Run();

			if (Cascade)
			{
				Query q = new Query();
				q.NoLock=true;
				q.QueryCondition=new Q(Event.Columns.VenueK,this.K);
				q.Columns=new ColumnSet(
					Event.Columns.K, 
					Event.Columns.UrlFragment,
					Event.Columns.VenueK,
					Event.Columns.DateTime);
				EventSet es = new EventSet(q);
				foreach (Event e in es)
				{
					try
					{
						Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Event, e.K, true);
						job.ExecuteAsynchronously();
					}
					catch(Exception ex)
					{
						if (Vars.DevEnv)
							throw ex;
					}
				}
			}

			Update uThreads = new Update();
			uThreads.Table=TablesEnum.Thread;
			uThreads.Changes.Add(new Assign(Thread.Columns.UrlFragment,UrlFilterPart));
			uThreads.Where=new And(
				new Q(Thread.Columns.ParentObjectType,Model.Entities.ObjectType.Venue),
				new Q(Thread.Columns.ParentObjectK,this.K));
			uThreads.Run();

			Update uArticles = new Update();
			uArticles.Table=TablesEnum.Article;
			uArticles.Changes.Add(new Assign(Article.Columns.UrlFragment,UrlFilterPart));
			uArticles.Where=new And(
				new Q(Article.Columns.ParentObjectType,Model.Entities.ObjectType.Venue),
				new Q(Article.Columns.ParentObjectK,this.K));
			uArticles.Run();

			if (Cascade)
			{
				Query q = new Query();
				q.NoLock=true;
				q.QueryCondition=new And(
					new Q(Article.Columns.ParentObjectType,Model.Entities.ObjectType.Venue),
					new Q(Article.Columns.ParentObjectK,this.K));
				q.Columns=new ColumnSet(
					Article.Columns.K,
					Article.Columns.UrlFragment,
					Article.Columns.ParentObjectK,
					Article.Columns.ParentObjectType);
				ArticleSet aSet = new ArticleSet(q);
				foreach (Article a in aSet)
				{
					try
					{
						Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Article, a.K, true);
						job.ExecuteAsynchronously();
					}
					catch(Exception ex)
					{
						if (Vars.DevEnv)
							throw ex;
					}
				}
			}
		}
Пример #18
0
		public void DeleteAll(Transaction transaction)
		{
			if (!this.Bob.DbRecordExists)
				return;

			//Events
			EventSet es = new EventSet(new Query(new Q(Event.Columns.VenueK,this.K)));
			foreach(Event e in es)
				e.DeleteAll(transaction);

			
			Delete CommentAlertDelete = new Delete(
				TablesEnum.CommentAlert,
				new And(
				new Q(CommentAlert.Columns.ParentObjectK,this.K),
				new Q(CommentAlert.Columns.ParentObjectType,Model.Entities.ObjectType.Venue)
				)
				);
			CommentAlertDelete.Run(transaction);
			
			//Threads
			ThreadSet ts = new ThreadSet(
				new Query(
					new And(
						new Q(Thread.Columns.ParentObjectType,Model.Entities.ObjectType.Venue),
						new Q(Thread.Columns.ParentObjectK,this.K)
					)
				)
			);
			foreach (Thread t in ts)
				t.DeleteAll(transaction);

			//Articles
			ArticleSet ars = new ArticleSet(new Query(new Q(Article.Columns.VenueK, this.K)));
			foreach (Article a in ars)
				a.DeleteAll(transaction);


			Guid oldPic = this.HasPic ? this.Pic : Guid.Empty;
			int oldPicMiscK = this.PicMisc != null ? this.PicMiscK : 0;

			this.Delete(transaction);

			if (oldPic != Guid.Empty)
				Storage.RemoveFromStore(Storage.Stores.Pix, oldPic, "jpg");

			if (oldPicMiscK > 0)
			{
				Misc m = new Misc(oldPicMiscK);
				m.DeleteAll(transaction);
			}

			this.Place.UpdateTotalEvents(transaction);

			
		}
Пример #19
0
		private void Page_Load(object sender, System.EventArgs e)
		{
			
			ContainerPage.SetPageTitle("Home");
			ContainerPage.ContentHasNoTitleAtTop = true;


			Query q = new Query();
			q.Columns = Templates.Articles.LatestNew.Columns;
			q.TableElement = Templates.Articles.LatestNew.PerformJoins(q.TableElement);
			q.QueryCondition = new And(
				Article.EnabledQueryCondition,
				new Q(Article.Columns.Relevance, Article.RelevanceEnum.Worldwide),
				new And(new Q(Article.Columns.ShowAboveFoldOnFrontPage, true), new Q(Article.Columns.EnabledDateTime, QueryOperator.GreaterThan, DateTime.Now.AddHours(-48)))
			);
			q.OrderBy = new OrderBy(Article.Columns.EnabledDateTime, OrderBy.OrderDirection.Descending);
			ArticleSet ars = new ArticleSet(q);

			if (ars.Count == 0)
			{
				NewArticlesPanel.Visible = false;
			}
			else
			{
			
				NewArticlesDataList.DataSource = ars;
				NewArticlesDataList.ItemTemplate = this.LoadTemplate("/Templates/Articles/LatestNew.ascx");
				NewArticlesDataList.DataBind();

			}


			Cambro.Web.Helpers.TieButton(SpotterCode, SpotterCodeButton);
			if (Vars.IE)
			{
				SpotterCodeButton.Style["height"] = "23px";
				SpotterCodeButton.Style["font-size"] = "12px";
				SpotterCodeButton.Style["margin-left"] = "4px";
			}
			else
			{
				SpotterCodeButton.Style["height"] = "24px";
				SpotterCodeButton.Style["font-size"] = "14px";
				SpotterCodeButton.Style["margin-left"] = "0px";
			}



			
            bool allowTakeoverAfterAgeCheck = true;
			if (Common.Settings.TakeoverRequiresDrinkingAgeVerificationStatus == Common.Settings.TakeoverRequiresDrinkingAgeVerificationStatusOption.On)
			{
				if (Prefs.Current["Drink"] != 1)
				{
					allowTakeoverAfterAgeCheck = false;
				}
			}
			if (allowTakeoverAfterAgeCheck)
			{
				FrontPageBannerPh.Controls.Clear();
				FrontPageBannerPh.Controls.Add(new LiteralControl(Common.Settings.FrontPageBannerHtmlHtml));
			}

			try
			{
				bool rb1 = Common.Settings.FrontPageRoadblock1Status == Common.Settings.FrontPageRoadblock1StatusOption.On;
				bool rb2 = Common.Settings.FrontPageRoadblock2Status == Common.Settings.FrontPageRoadblock2StatusOption.On;
				bool rb3 = Common.Settings.FrontPageRoadblock3Status == Common.Settings.FrontPageRoadblock3StatusOption.On;
				int w1 = Common.Settings.FrontPageRoadblock1Weight;
				int w2 = Common.Settings.FrontPageRoadblock2Weight;
				int w3 = Common.Settings.FrontPageRoadblock3Weight;
				
				//we have a roadblock to show...
				List<string> alwaysOn = new List<string>();
				Dictionary<string, int> roadblocks = new Dictionary<string, int>();
				int totalWeight = 0;

				if (rb1 && w1 == 0)
					alwaysOn.Add(Common.Settings.FrontPageRoadblock1Html);
				else if (rb1)
				{
					roadblocks.Add(Common.Settings.FrontPageRoadblock1Html, w1);
					totalWeight += w1;
				}

				if (rb2 && w2 == 0)
					alwaysOn.Add(Common.Settings.FrontPageRoadblock2Html);
				else if (rb2)
				{
					roadblocks.Add(Common.Settings.FrontPageRoadblock2Html, w2);
					totalWeight += w2;
				}

				if (rb3 && w3 == 0)
					alwaysOn.Add(Common.Settings.FrontPageRoadblock3Html);
				else if (rb3)
				{
					roadblocks.Add(Common.Settings.FrontPageRoadblock3Html, w3);
					totalWeight += w3;
				}

				Random r = new Random();

				if (alwaysOn.Count > 1)
				{
					int index = r.Next(alwaysOn.Count);
					renderRoadblock(alwaysOn[index]);
				}
				else if (alwaysOn.Count == 1)
				{
					renderRoadblock(alwaysOn[0]);
				}
				else
				{
					int chosenRnd = r.Next(10 + totalWeight);

					if (chosenRnd < 10)
					{
						Photo p = FrontPagePhotos[chosenRnd];
						PhotoAnchor.HRef = p.Url();
						PhotoImg.Src = Storage.Path(p.FrontPagePic.Value);
						PhotoCaption.InnerHtml = p.PhotoOfWeekCaption;
						PhotoCaption.Attributes["class"] = "PhotoOverlay " + p.FrontPageCaptionClass;
						PhotoSpotterLink.InnerHtml = p.Usr.NickName;
						PhotoSpotterLink.HRef = p.Usr.Url();

						string color = p.FrontPageCaptionClass.StartsWith("White") ? "White" : "Black";
						string topBottom = p.FrontPageCaptionClass.Contains("Bottom") ? "Bottom" : "Top";
						string topBottomOpposite = p.FrontPageCaptionClass.Contains("Bottom") ? "Top" : "Bottom";
						string leftRight = p.FrontPageCaptionClass.Contains("Left") ? "Left" : "Right";
						string leftRightOpposite = p.FrontPageCaptionClass.Contains("Left") ? "Right" : "Left";

						PhotoSoptterHolder.Attributes["class"] = "PhotoOverlay " + color + " " + topBottom + " " + leftRightOpposite;
						PhotoLinksHolder.Attributes["class"] = "PhotoOverlay " + color + " " + topBottomOpposite + " Left";
						TopPhotoArchiveHolder.Attributes["class"] = "PhotoOverlay " + color + " " + topBottomOpposite + " Right";

					}
					else
					{

						chosenRnd = chosenRnd - 10;
						for (int i = 0; i < roadblocks.Count; i++)
						{
							chosenRnd = chosenRnd - roadblocks.ToArray()[i].Value;
							if (chosenRnd <= 0)
							{
								renderRoadblock(roadblocks.ToArray()[i].Key);
								break;
							}
						}
					}
				}

				
			}
			catch { }

			try
			{
				StringBuilder sb = new StringBuilder();
				foreach (Photo p in FrontPagePhotos)
				{
					string s = "";
					string s1 = "";
					if (Usr.Current != null && Usr.Current.IsAdmin)
					{
						s = "stt('" + Cambro.Misc.Utility.FriendlyDate(p.PhotoOfWeekDateTime) + "');";
						s1 = "onmouseout=\"htm();\"";
					}
					sb.Append(@"
<div style=""float:left; margin-top:3px; margin-bottom:3px;" + (sb.Length == 0 ? "" : " margin-left:5px;") + @""">
	<img src=""" + p.IconPath + @""" width=""30"" height=""30"" class=""Block"" onmouseover=""" + s + @"TopPhotoChangeImage('" + Storage.Path(p.FrontPagePic.Value) + @"', '" + p.Url() + @"', '" + Cambro.Misc.Utility.JsStringEncode(p.PhotoOfWeekCaption) + @"', '" + p.Usr.NickName + @"');return false;"" " + s1 + @" />
</div>
");
				}
				PhotoLinksPh.Controls.Clear();
				PhotoLinksPh.Controls.Add(new LiteralControl(sb.ToString()));
			}
			catch { }
			
		}