public void ThreadFinished()
 {
     _finished.Add(RunningThreadId);
     _enabled.Remove(RunningThreadId);
     _priority.RemovePriorityOf(RunningThreadId);
     if (!AllThreadsFinished)
     {
         if (_deadlock)
         {
             // If there is a deadlock, manually schedule the threads
             // in turn, so they have the opportunity to throw an exception and exit.
             // Calling MaybeSwitch() here isn't possible, because there are no
             // enabled threads to schedule.
             var unfinished = new ThreadSet(_numThreads);
             for (int i = 0; i < _numThreads; ++i)
             {
                 if (!_finished[i])
                 {
                     RunningThreadId = i;
                 }
             }
         }
         else
         {
             MaybeSwitch();
         }
     }
 }
Example #2
0
 public void GivePriorityOver(int x, ThreadSet threads)
 {
     for (int i = 0; i < _numThreads; ++i)
     {
         if (threads[i] && i != x)
         {
             _hasPriority[x, i] = true;
         }
     }
 }
 private void PrepareForScheduling()
 {
     _finished       = new ThreadSet(_numThreads);
     _enabled        = new ThreadSet(_numThreads);
     _disabledSince  = new ThreadSet[_numThreads];
     _scheduledSince = new ThreadSet[_numThreads];
     _enabledSince   = new ThreadSet[_numThreads];
     for (int i = 0; i < _numThreads; ++i)
     {
         _disabledSince[i]  = new ThreadSet(_numThreads);
         _enabledSince[i]   = new ThreadSet(_numThreads);
         _scheduledSince[i] = new ThreadSet(_numThreads);
         _enabled.Add(i);
     }
     _waitingOnLock       = new object[_numThreads];
     _priority            = new PriorityRelation(_numThreads);
     _currentYieldPenalty = 0;
     _deadlock            = false;
 }
		void Bind()
		{
			Query q = new Query();
			q.NoLock = true;
			q.QueryCondition = new Q(Usr.Columns.AdminLevel, Usr.AdminLevels.Super);
			q.OrderBy = new OrderBy(Usr.Columns.NickName);
			q.Columns = new ColumnSet(Usr.LinkColumns, Usr.Columns.DateTimeLastPageRequest, Usr.Columns.IsLoggedOn, Usr.Columns.FirstName, Usr.Columns.LastName, Usr.Columns.IsSkeleton);
			UsrSet us = new UsrSet(q);
			ModeratorsDataGrid.DataSource = us;
			ModeratorsDataGrid.DataBind();

			if (ContainerPage.Url["usrk"].IsInt)
			{
				int UsrK = ContainerPage.Url["usrk"];
				if (ContainerPage.Url["type"] == 1)
				{
					Query tsq = new Query();
					tsq.QueryCondition = new And(
						new Q(Thread.Columns.NewsStatus, Thread.NewsStatusEnum.Recommended),
						new Q(Thread.Columns.NewsModeratorUsrK, UsrK));
					tsq.TopRecords = 10;
					tsq.NoLock = true;
					ThreadSet ts = new ThreadSet(tsq);
					if (ts.Count == 0)
						ItemsPanel.Visible = false;
					else
					{
						ItemsRepeater.DataSource = ts;
						ItemsRepeater.ItemTemplate = this.LoadTemplate("/Templates/Threads/NewsAdmin.ascx");
						ItemsRepeater.DataBind();
					}
				}
				else
				{
					ItemsPanel.Visible = false;
				}
			}
			else
			{
				ItemsPanel.Visible = false;
			}
		}
Example #5
0
        public ThreadSet GetSchedulableThreads(ThreadSet enabled)
        {
            var admissable = new ThreadSet(_numThreads);

            admissable.ReplaceWith(enabled);
            for (int i = 0; i < _numThreads; ++i)
            {
                if (!admissable[i])
                {
                    continue;
                }
                for (int j = 0; j < _numThreads; ++j)
                {
                    // Thread i cannot be scheduled if an enabled thread
                    // has priority over it.
                    if (_hasPriority[i, j] && enabled[j])
                    {
                        admissable.Remove(i);
                        break;
                    }
                }
            }
            return(admissable);
        }
		public void ReviewsPanel_Load(object o, System.EventArgs e)
		{
			if (OnlyShowThreads)
			{
				ReviewsPanel.Visible = false;
				return;
			}
			Query q = new Query();
			Q RelevanceQ = new Q(false);
			if (Discussable == null)
				RelevanceQ = new Q(true);
			else if (Discussable.UsedDiscussable is Country)
				RelevanceQ = new Q(Thread.Columns.CountryK, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Place)
				RelevanceQ = new Q(Thread.Columns.PlaceK, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Venue)
				RelevanceQ = new Q(Thread.Columns.VenueK, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Event)
				RelevanceQ = new Q(Thread.Columns.EventK, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Brand)
			{
				RelevanceQ = new Q(EventBrand.Columns.BrandK, Discussable.UsedDiscussable.K);
				q.TableElement = Thread.EventBrandJoin;
			}
			else if (Discussable.UsedDiscussable is Group)
			{
				RelevanceQ = new Q(GroupEvent.Columns.GroupK, Discussable.UsedDiscussable.K);
				q.TableElement = Thread.EventGroupJoin;
			}

			

		 

			q.TableElement = Templates.Threads.ReviewLatest.PerformJoins(q.TableElement);
			q.Columns = Templates.Threads.ReviewLatest.Columns;
			q.QueryCondition = new And(
				new Q(Thread.Columns.IsReview, true),
				RelevanceQ,
				new Q(Thread.Columns.Private, false),
				new Q(Thread.Columns.GroupPrivate, false),
				new Q(Thread.Columns.PrivateGroup, false)
			);
			q.OrderBy = new OrderBy(Thread.Columns.DateTime, OrderBy.OrderDirection.Descending);
			q.TopRecords = Items;
			ThreadSet ts = new ThreadSet(q);

			if (ts.Count == 0)
				ReviewsPanel.Visible = false;
			else
			{
				ReviewsDataList.DataSource = ts;
				ReviewsDataList.ItemTemplate = this.LoadTemplate("/Templates/Threads/ReviewLatest.ascx");
				ReviewsDataList.DataBind();

				if (Discussable == null)
					ReviewsArchiveAnchor.HRef = Archive.GetUrl(ts[0].DateTime.Year, ts[0].DateTime.Month, 0, ArchiveObjectType.Review, new string[] { }, "");
				else if (Discussable.UsedDiscussable is IHasArchive && ts.Count == Items)
					ReviewsArchiveAnchor.HRef = ((IHasArchive)Discussable.UsedDiscussable).UrlArchiveDate(ts[0].DateTime.Year, ts[0].DateTime.Month, 0, ArchiveObjectType.Review);
				else
				{
					ReviewsArchiveDiv.Visible = false;
					ReviewsPanelInner.Attributes["class"] = "LatestPanel Big CleanLinks";
				}
			}
		}
Example #7
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();
		}
		private void NewsPanel_Load(object o, EventArgs e)
		{
			if (OnlyShowThreads)
			{
				NewsPanel.Visible = false;
				return;
			}


			Q RelevanceQ = null;

			if (Discussable == null)
			{
				RelevanceQ = new Q(true);
			}
			else if (Discussable.UsedDiscussable is Country)
				RelevanceQ = new Q(Thread.Columns.CountryK, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Place)
				RelevanceQ = new Q(Thread.Columns.PlaceK, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Venue)
				RelevanceQ = new Q(Thread.Columns.VenueK, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Event)
				RelevanceQ = new Q(Thread.Columns.EventK, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Brand)
				RelevanceQ = Group.ThreadsQ(((Brand)Discussable.UsedDiscussable).GroupK);
			else if (Discussable.UsedDiscussable is Group)
				RelevanceQ = Group.ThreadsQWithLinkedEvents((Group)Discussable.UsedDiscussable);

			Query q = new Query();

			if (Discussable != null && Discussable.UsedDiscussable is Group)
				q.TableElement = Thread.EventGroupLeftJoin;

			q.TableElement = Templates.Threads.NewsLatest.PerformJoins(q.TableElement);
			q.Columns = Templates.Threads.NewsLatest.Columns;
			q.QueryCondition = new And(
				RelevanceQ,
				new Q(Thread.Columns.IsNews, true),
				new Q(Thread.Columns.GroupPrivate, false),
				new Q(Thread.Columns.PrivateGroup, false));
			q.OrderBy = Thread.NewsOrder;
			q.TopRecords = Items;

			ThreadSet tsNews = new ThreadSet(q);

			if (tsNews.Count == 0)
				NewsPanel.Visible = false;
			else
			{
				NewsDataList.DataSource = tsNews;
				NewsDataList.ItemTemplate = this.LoadTemplate("/Templates/Threads/NewsLatest.ascx");
				NewsDataList.DataBind();

				if (Discussable == null)
					NewsArchiveAnchor.HRef = Archive.GetUrl(tsNews[0].DateTime.Year, tsNews[0].DateTime.Month, 0, ArchiveObjectType.News, new string[] { }, "");
				else if (Discussable.UsedDiscussable is IHasArchive && tsNews.Count == Items)
					NewsArchiveAnchor.HRef = ((IHasArchive)Discussable.UsedDiscussable).UrlArchiveDate(tsNews[0].DateTime.Year, tsNews[0].DateTime.Month, 0, ArchiveObjectType.News);
				else
				{
					NewsArchiveDiv.Visible = false;
					NewsPanelInner.Attributes["class"] = "LatestPanel Big CleanLinks";
				}
			}
		}
Example #9
0
		public void DeleteAll(Transaction transaction)
		{
			if (!this.Bob.DbRecordExists)
				return;

			this.ContentDisabled = false;
			this.Update(transaction);

			try
			{
				UsrSet usPhotoPic = new UsrSet(new Query(new Q(Usr.Columns.PicPhotoK, this.K)));
				foreach (Usr u in usPhotoPic)
				{
					try
					{
						Guid picToDelete = u.Pic;

						u.Pic = Guid.Empty;
						u.PicPhotoK = 0;
						u.PicState = "";
						u.Update(transaction);

						Storage.RemoveFromStore(Storage.Stores.Pix, picToDelete, "jpg");

					}
					catch { }
				}
			}
			catch { }


			try
			{
				if (this.Gallery.MainPhotoK == this.K)
				{
					Query q = new Query();
					q.QueryCondition = new And(
						new Q(Photo.Columns.GalleryK, this.GalleryK),
						Photo.EnabledQueryCondition
					);
					q.OrderBy = new OrderBy(Photo.Columns.DateTime);
					q.Columns = new ColumnSet(Photo.Columns.K, Photo.Columns.Status);
					PhotoSet psMain = new PhotoSet(q);
			
					int firstDisabled = 0;
					foreach (Photo p in psMain)
					{
						if (p.K != this.K)
						{
							if (p.Status == StatusEnum.Enabled)
							{
								this.Gallery.MainPhotoK = p.K;
								break;
							}
							else if (firstDisabled == 0)
								firstDisabled = p.K;
						}
					}
					if (firstDisabled > 0)
						this.Gallery.MainPhotoK = firstDisabled;
					
					this.Gallery.Update(transaction);
					
					//PhotoSet psMain = new PhotoSet(
					//                            new Query(
					//                                new And(
					//                                new Q(Photo.Columns.K, QueryOperator.NotEqualTo, this.K),
					//                                new Q(Photo.Columns.GalleryK, this.GalleryK),
					//                                Photo.EnabledQueryCondition),
					//                                new OrderBy(Photo.Columns.DateTime),
					//                                1
					//                            )
					//                        );
					//if (psMain.Count > 0)
					//{
					//    this.Gallery.MainPhotoK = psMain[0].K;
					//}
					//else
					//{
					//    PhotoSet psMain1 = new PhotoSet(
					//        new Query(
					//            new And(
					//                new Q(Photo.Columns.K, QueryOperator.NotEqualTo, this.K),
					//                new Q(Photo.Columns.GalleryK, this.GalleryK)
					//            ),
					//            new OrderBy(Photo.Columns.DateTime),
					//            1
					//        )
					//    );
					//    if (psMain1.Count > 0)
					//    {
					//        this.Gallery.MainPhotoK = psMain1[0].K;
					//    }
					//    else
					//    {
					//        this.Gallery.MainPhotoK = 0;
					//    }
					//}
					//this.Gallery.Update(transaction);
				}
			}
			catch { }

			try
			{
				Delete UsrPhotoFavouriteDelete = new Delete(
					TablesEnum.UsrPhotoFavourite,
					new Q(UsrPhotoFavourite.Columns.PhotoK, this.K)
					);
				UsrPhotoFavouriteDelete.Run(transaction);
			}
			catch { }

			try
			{
				Delete UsrPhotoMeDelete = new Delete(
					TablesEnum.UsrPhotoMe,
					new Q(UsrPhotoMe.Columns.PhotoK, this.K)
					);
				UsrPhotoMeDelete.Run(transaction);
			}
			catch { }

			try
			{
				Delete CommentAlertDelete = new Delete(
					TablesEnum.CommentAlert,
					new And(
					new Q(CommentAlert.Columns.ParentObjectK, this.K),
					new Q(CommentAlert.Columns.ParentObjectType, Model.Entities.ObjectType.Photo)
					)
				);
				CommentAlertDelete.Run(transaction);
			}
			catch { }

			try
			{
				if (this.ThreadK.HasValue && this.ThreadK.Value > 0)
					this.Thread.DeleteAll(transaction);
			}
			catch { }

			try
			{
				ThreadSet ts = new ThreadSet(new Query(new Q(Thread.Columns.PhotoK, this.K)));
				foreach (Thread t in ts)
				{
					t.DeleteAll(transaction);
				}
			}
			catch { }

			try
			{
				Delete PhotoReviewDelete = new Delete(
					TablesEnum.PhotoReview,
					new Q(PhotoReview.Columns.PhotoK, this.K)
					);
				PhotoReviewDelete.Run(transaction);
			}
			catch { }

			try
			{
				ParaSet ps = new ParaSet(new Query(new Q(Para.Columns.PhotoK, this.K)));
				foreach (Para p in ps)
				{
					if (p.Type.Equals(Para.TypeEnum.Photo))
						p.DeleteAll(transaction);
					else
					{
						Guid oldPic = p.Pic;

						p.Pic = Guid.Empty;
						p.PhotoK = 0;
						p.Update(transaction);

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

			try
			{
				foreach (var tagPhoto in this.ChildTagPhotos())
				{
					foreach (var tagPhotoHistory in tagPhoto.ChildTagPhotoHistorys())
					{
						tagPhotoHistory.Delete(transaction);
					}
					tagPhoto.Delete(transaction);
				}
			}
			catch { }

			Guid uploadTemporary = this.UploadTemporary;
			string uploadTemporaryExtention = this.UploadTemporaryExtention;
			Guid master = this.Master;
			Guid web = this.Web;
			Guid thumb = this.Thumb;
			Guid icon = this.Icon;
			bool isVideo = this.MediaType == MediaTypes.Video;
			Guid videoMaster = this.VideoMaster;
			string videoFileExtention = this.VideoFileExtention;
			Guid videoMed = this.VideoMed;
			bool hasCrop = this.HasCrop;
			Guid crop = this.HasCrop ? this.Crop : Guid.Empty;


			try
			{
				this.Delete(transaction);
			}
			catch { }

			try
			{

				Storage.RemoveFromStore(Storage.Stores.Temporary, uploadTemporary, uploadTemporaryExtention);
				Storage.RemoveFromStore(Storage.Stores.Master, master, "jpg");
				Storage.RemoveFromStore(Storage.Stores.Pix, web, "jpg");
				Storage.RemoveFromStore(Storage.Stores.Pix, thumb, "jpg");
				Storage.RemoveFromStore(Storage.Stores.Pix, icon, "jpg");
				if (isVideo)
				{
					Storage.RemoveFromStore(Storage.Stores.Master, videoMaster, videoFileExtention);
					Storage.RemoveFromStore(Storage.Stores.Pix, videoMed, "flv");
				}
				if (hasCrop)
					Storage.RemoveFromStore(Storage.Stores.Pix, crop, "jpg");
			}
			catch { }

			try
			{
				this.Usr.UpdateTotalPhotos(transaction);
			}
			catch { }

			try
			{
				this.Gallery.UpdateStats(transaction, true);
			}
			catch { }

			try
			{
				this.Gallery.UpdatePhotoOrder(transaction);
			}
			catch { }

			try
			{
				if (this.Event != null)
					this.Event.UpdateTotalPhotos(transaction);
			}
			catch { }

		}
Example #10
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");

		}
		void NewsListBind()
		{
			if (EnsureSecure)
			{
				Query q = new Query();
				q.QueryCondition = new And(new Q(Thread.Columns.EventK, CurrentEvent.K), new Q(Thread.Columns.IsNews, true), new Q(Brand.Columns.PromoterK, CurrentPromoter.K));
				q.TableElement = new Join(
					new TableElement(TablesEnum.Thread),
					new Join(Group.Columns.BrandK, Brand.Columns.K),
					QueryJoinType.Inner,
					new Q(Thread.Columns.GroupK, Group.Columns.K, true)
				);
				q.OrderBy = new OrderBy(Thread.Columns.DateTime, OrderBy.OrderDirection.Descending);
				ThreadSet ts = new ThreadSet(q);
				NewsPanel.Visible = ts.Count > 0;
				NoNewsPanel.Visible = ts.Count == 0;
				if (ts.Count > 0)
				{
					NewsDataGrid.AllowPaging = ts.Count > NewsDataGrid.PageSize;
					NewsDataGrid.DataSource = ts;
					NewsDataGrid.DataBind();
				}
			}
		}
		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
			}
		}
Example #13
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);

		}
Example #14
0
		private void NewsAdminPanel_Load(object sender, System.EventArgs e)
		{
			NewsAdminPanel.Visible = ShowNewsAdmin;
			if (ShowNewsAdmin)
			{
				NewsDisableAllLinkButton.Attributes["onclick"] = "return confirm('Are you sure?');";
				BindNewsDataGrid();
				if (NewsThreadK > 0 && NewsThread.NewsStatus.Equals(Thread.NewsStatusEnum.Recommended))
				{
					ThreadSet ts = new ThreadSet(new Query(new Q(Thread.Columns.K, NewsThreadK)));
					NewsThreadRepeater.ItemTemplate = this.LoadTemplate("/Templates/Threads/GroupNewsAdmin.ascx");
					NewsThreadRepeater.DataSource = ts;
					NewsThreadRepeater.DataBind();
				}
				else
					NewsThreadPanel.Visible = false;
			}
		}
Example #15
0
		public string PromoterHtmlNews(Promoter p)
		{
			Query q = new Query();
			q.QueryCondition = new And(new Q(Thread.Columns.EventK, this.K), new Q(Thread.Columns.IsNews, true), new Q(Brand.Columns.PromoterK, p.K));
			q.TableElement = new Join(
				new TableElement(TablesEnum.Thread),
				new Join(Group.Columns.BrandK, Brand.Columns.K),
				QueryJoinType.Inner,
				new Q(Thread.Columns.GroupK, Group.Columns.K, true)
			);
			q.ReturnCountOnly = true;
			ThreadSet ts = new ThreadSet(q);
			return TickCrossHtml(ts.Count > 0);
		}
Example #16
0
			public MakerReturn Post()
			{
				MakerReturn r = new MakerReturn();
				#region look for duplicate
				Query qDup = new Query();
				qDup.TopRecords = 1;
				qDup.Columns = new ColumnSet(Bobs.Comment.Columns.K, Bobs.Comment.Columns.ThreadK);
				qDup.QueryCondition = new Q(Bobs.Comment.Columns.DuplicateGuid, (Guid)DuplicateGuid);
				CommentSet csDup = new CommentSet(qDup);
				if (csDup.Count > 0)
				{
					r.Success = false;
					r.MessageHtml = "Duplicate thread detected";
					r.Thread = csDup[0].Thread;
					r.Duplicate = true;
					return r;
				}
				#endregion
				#region ensure two parents are different types...
				if (ParentType.Equals(Model.Entities.ObjectType.Group) && GroupK != ParentK)
				{
					r.Success = false;
					r.MessageHtml = "Posting to group, but GroupK!=ParentK";
					return r;
				}
				#endregion
				#region Make sure Group and ParentType are syncronised
				if (GroupK > 0 && ParentType.Equals(Model.Entities.ObjectType.None))
				{
					ParentType = Model.Entities.ObjectType.Group;
					ParentK = GroupK;
				}
				if (GroupK == 0 && ParentType.Equals(Model.Entities.ObjectType.Group))
				{
					GroupK = ParentK;
				}
				#endregion
				#region if we're posting in a group, make sure we are a member
				if (GroupK > 0)
				{
					GroupUsr gu = ParentGroup.GetGroupUsr(PostingUsr);
					if (!PostingUsr.CanGroupMember(gu))
					{
						r.Success = false;
						r.MessageHtml = "You have tried to post a message in the " + ParentGroup.Link() + " group, but you're not currently a member of this group. Check out the group homepage for more information.";
						return r;
					}
				}
				#endregion
				#region ensure both parents map to real objects
				if (!ParentType.Equals(Model.Entities.ObjectType.None))
				{
					if (ParentBob == null)
					{
						r.Success = false;
						r.MessageHtml = "You've tried to post a message in a non-existant chat. Maybe it's been deleted.";
						return r;
					}
				}
				if (GroupK > 0)
				{
					if (ParentGroup == null)
					{
						r.Success = false;
						r.MessageHtml = "You've tried to post a message in a non-existant group. Maybe it's been deleted.";
						return r;
					}
				}
				#endregion
				#region Private
				bool tPrivate = false;
				bool gPrivate = false;
				if (Private)
				{
					if (GroupK == 0)
						tPrivate = true;
					else
						gPrivate = true;
				}
				#endregion
				#region News
				tNews = false;
				tNewsStatus = NewsStatusEnum.None;
				int tNewsLevel = 0;
				int tNewsUsrK = 0;
				int tNewsModeratorUsrK = 0;
				if (News)
				{
					if (tPrivate)
					{
						r.Success = false;
						r.MessageHtml = "You've tried to post private news! How did this happen?";
						return r;
					}
					else if (GroupK == 0)
					{
						r.Success = false;
						r.MessageHtml = "You've tried to post public non-group news. How did this happen?";
						return r;

						//if (PostingUsr.NewsPermissionLevel >= 10 || PostingUsr.IsSuper)
						//{
						//    tNews = true;
						//    tNewsStatus = NewsStatusEnum.Recommended;
						//    tNewsModeratorUsrK = Usr.GetNewsModeratorUsrK();
						//    tNewsLevel = 10;
						//    tNewsUsrK = PostingUsr.K;
						//}
						//else
						//{
						//    tNews = false;
						//    tNewsStatus = NewsStatusEnum.Recommended;
						//    tNewsModeratorUsrK = Usr.GetNewsModeratorUsrK();
						//    tNewsLevel = 0;
						//    tNewsUsrK = PostingUsr.K;
						//}
					}
					else
					{
						GroupUsr gu = ParentGroup.GetGroupUsr(PostingUsr);

						if (PostingUsr.CanGroupNewsAdmin(gu))
						{
							tNews = true;
							tNewsStatus = NewsStatusEnum.Done;
							tNewsLevel = 10;
							tNewsUsrK = PostingUsr.K;
						}
						else
						{
							tNews = false;
							tNewsStatus = NewsStatusEnum.Recommended;
							tNewsLevel = 10;
							tNewsUsrK = PostingUsr.K;
						}
					}
				}
				#endregion
				#region Sealed
				bool tSealed = false;
				if (Sealed)
				{
					if (tPrivate)
						tSealed = true;
				}
				#endregion
				#region Closed
				bool tClosed = false;
				if (Closed)
				{
					tClosed = true;
				}
				#endregion
				#region Review
				bool tReview = false;
				if (Review)
				{
					if (ParentType.Equals(Model.Entities.ObjectType.Event) && GroupK == 0)
					{
						Query qReviews = new Query();
						qReviews.QueryCondition = new And(
							new Q(Columns.UsrK, PostingUsr.K),
							new Q(Columns.ParentObjectType, Model.Entities.ObjectType.Event),
							new Q(Columns.ParentObjectK, ParentK),
							new Q(Columns.IsReview, true)
							);
						qReviews.TopRecords = 1;
						qReviews.Columns = new ColumnSet(Thread.Columns.K);
						ThreadSet tsReviews = new ThreadSet(qReviews);
						if (tsReviews.Count > 0)
						{
							r.Success = false;
							r.MessageHtml = "You've already posted a review. You can only post one review per event.";
							r.Duplicate = true;
							r.Thread = tsReviews[0];
							return r;
						}
						else
							tReview = true;
					}
					else
					{
						r.Success = false;
						r.MessageHtml = "You must post a review in an event chat board.";
						return r;
					}
				}
				#endregion

				if (GroupK > 0)
					CurrentGroupUsr = ParentGroup.GetGroupUsr(PostingUsr);

				Transaction trans = null;//new Transaction();

				NewThread = new Thread();

				try
				{
					#region Create thread
					NewThread.DateTime = DateTime.Now;
					NewThread.Enabled = true;
					NewThread.UsrK = PostingUsr.K;
					NewThread.LastPostUsrK = PostingUsr.K;
					NewThread.Subject = Helpers.Strip(Subject, true, true, true, true);

					NewThread.ParentObjectType = ParentType;
					NewThread.ParentObjectK = ParentK;
					if (GroupK > 0)
						NewThread.GroupK = ParentGroup.K;
					else
						NewThread.GroupK = 0;

					NewThread.Private = tPrivate;
					NewThread.GroupPrivate = gPrivate;
					if (GroupK > 0)
						NewThread.PrivateGroup = ParentGroup.PrivateChat;
					else
						NewThread.PrivateGroup = false;

					NewThread.IsNews = tNews;
					NewThread.NewsStatus = tNewsStatus;
					NewThread.NewsLevel = tNewsLevel;
					NewThread.NewsModeratorUsrK = tNewsModeratorUsrK;
					NewThread.NewsUsrK = tNewsUsrK;

					NewThread.Sealed = tSealed;
					NewThread.Closed = tClosed;
					NewThread.IsReview = tReview;

					NewThread.UpdateAncestorLinksNoUpdate();
					NewThread.Update(trans);

					#endregion

					#region Add PostingUsr ThreadUsr
					CurrentThreadUsr = new ThreadUsr();
					CurrentThreadUsr.DateTime = DateTime.Now;
					CurrentThreadUsr.InvitingUsrK = PostingUsr.K;
					CurrentThreadUsr.UsrK = PostingUsr.K;
					CurrentThreadUsr.ThreadK = NewThread.K;
					CurrentThreadUsr.ChangeStatus(ThreadUsr.StatusEnum.Archived, NewThread.DateTime);
					CurrentThreadUsr.StatusChangeObjectK = PostingUsr.K;
					CurrentThreadUsr.StatusChangeObjectType = Model.Entities.ObjectType.Usr;
					CurrentThreadUsr.Update(trans);
					#endregion

					#region Make the comment
					Comment.Maker cMaker = new Comment.Maker();
					cMaker.Body = Body;
					cMaker.ParentThread = NewThread;
					cMaker.DuplicateGuid = DuplicateGuid;
					cMaker.PostingUsr = PostingUsr;
					cMaker.InviteKs = InviteKs;
					cMaker.AlertedUsrs = AlertedUsrs;
					cMaker.NewThread = true;
					cMaker.CurrentThreadUsr = CurrentThreadUsr;
					cMaker.CurrentGroupUsr = CurrentGroupUsr;
					cMaker.RunAsync = RunAsync;
					cMaker.DisableLiveChatMessage = DisableLiveChatMessage;
					Comment.MakerReturn cReturn = null;
					try
					{
						cReturn = cMaker.Post(trans);
					}
					catch (Exception ex)
					{
						NewThread.DeleteAll(null);
						throw ex;
					}
					#endregion

					

					//SendThreadAlertsJob sendThreadsAlert = new SendThreadAlertsJob(NewThread.K, AlertedUsrs, PostingUsr.K, Subject, InviteKs);
					//if (this.RunAsync)
					//{
					//    sendThreadsAlert.ExecuteAsynchronously();
					//}
					//else
					//{
					//    sendThreadsAlert.ExecuteSynchronously();
					//}

					r.Success = true;
					r.Thread = NewThread;
					r.Comment = cReturn.Comment;
					return r;
				}
				catch (Exception ex)
				{
					//trans.Rollback();
					NewThread.DeleteAll(null);
					throw ex;
				}
				finally
				{
					//trans.Close();
				}
			}
Example #17
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();

		}
Example #18
0
		public void BindNewsDataGrid()
		{
			int perPage = 10;

			Query q = new Query();

			q.Paging.RecordsPerPage = perPage;
			q.Paging.RequestedPage = NewsThreadsPage;

			q.Columns = new ColumnSet(
				Thread.Columns.K,
				Thread.Columns.Private,
				Thread.Columns.GroupPrivate,
				Thread.Columns.PrivateGroup,
				Thread.Columns.Subject,
				Thread.Columns.LastPost,
				Thread.Columns.TotalComments,
				Thread.Columns.TotalParticipants,
				Thread.Columns.TotalWatching,
				Thread.Columns.IsNews,
				Thread.Columns.IsReview,
				Thread.Columns.ParentObjectType,
				Thread.Columns.ParentObjectK,
				Thread.Columns.GroupK,
				Thread.Columns.UsrK,
				new JoinedColumnSet(Thread.Columns.UsrK, Usr.LinkColumns),
				Thread.Columns.LastPostUsrK,
				new JoinedColumnSet(Thread.Columns.LastPostUsrK, Usr.LinkColumns)
				);

			q.OrderBy = new OrderBy(Thread.Columns.DateTime);

			q.TableElement = new TableElement(TablesEnum.Thread);

			q.TableElement = new Bobs.Join(
				q.TableElement,
				new TableElement(new Column(Thread.Columns.UsrK, Usr.Columns.K)),
				QueryJoinType.Left,
				Thread.Columns.UsrK,
				new Column(Thread.Columns.UsrK, Usr.Columns.K));

			q.TableElement = new Bobs.Join(
				q.TableElement,
				new TableElement(new Column(Thread.Columns.LastPostUsrK, Usr.Columns.K)),
				QueryJoinType.Left,
				Thread.Columns.LastPostUsrK,
				new Column(Thread.Columns.LastPostUsrK, Usr.Columns.K));

			q.QueryCondition = new And(new Q(Thread.Columns.NewsStatus, Thread.NewsStatusEnum.Recommended), new Q(Thread.Columns.GroupK, CurrentGroup.K));

			ThreadSet ts = new ThreadSet(q);

			if (ts.Count > 0)
			{
				NewsThreadsPage = ts.Paging.ReturnedPage;


				NewsDataGrid.DataSource = ts;
				NewsDataGrid.DataBind();


				Query qTot = new Query();
				qTot.QueryCondition = new And(new Q(Thread.Columns.NewsStatus, Thread.NewsStatusEnum.Recommended), new Q(Thread.Columns.GroupK, CurrentGroup.K));
				qTot.ReturnCountOnly = true;
				ThreadSet tCount = new ThreadSet(qTot);


				int endLinks = 4;
				int midLinks = 4;
				PageLinkWriter p = new PageLinkWriter();
				p.SetLastPage(perPage, tCount.Count);
				p.CurrentPageForLinks = NewsThreadsPage;
				p.Zones.Add(new PageLinkWriter.Zone(1, endLinks));
				p.Zones.Add(new PageLinkWriter.Zone(p.LastPage - endLinks + 1, p.LastPage));
				p.Zones.Add(new PageLinkWriter.Zone(NewsThreadsPage - midLinks, NewsThreadsPage + midLinks));
				StringBuilder sb = new StringBuilder();
				sb.Append("Pages: ");
				p.Build(new PageLinkWriter.LinkWriter(NewsPageLinkWriter), new PageLinkWriter.SeperatorWriter(NewsPageSeperatorWriter), sb);
				NewsPageP.Controls.Clear();
				if (p.LastPage > 1)
					NewsPageP.Controls.Add(new LiteralControl(sb.ToString()));
				else
					NewsPageP.Visible = false;
			}
			else
			{
				NewsDataGrid.Visible = false;
				NewsPageP.InnerHtml = "<small>No news suggestions</small>";
			}
		}
Example #19
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);

			
		}
Example #20
0
		void BindBoards()
		{
			if (HotTopicsCountry == null)
			{
				HotTopicsHomeCountryLink.InnerText = HotTopicsHomeCountryLink.InnerText.Replace("???", Country.Current.FriendlyName);
				HotTopicsHomeCountryLink.HRef = Country.Current.UrlHotTopics();

				HotTopicsCountryPanel.Visible = false;
				HotTopicsWorldwidePanel.Visible = true;

				SetPageTitle("Hot forums worldwide");
			}
			else
			{
				HotTopicsCountryLink.InnerText = HotTopicsCountry.FriendlyName;
				HotTopicsCountryLink.HRef = HotTopicsCountry.Url();

				HotTopicsCountryPanel.Visible = true;
				HotTopicsWorldwidePanel.Visible = false;

				SetPageTitle("Hot forums in " + HotTopicsCountry.FriendlyName);
			}

			Q HotTopicsCountryPlaceFilter = new Q(true);
			Q HotTopicsCountryThreadFilter = new Q(true);
			if (HotTopicsCountry != null)
			{
				HotTopicsCountryPlaceFilter = new Q(Place.Columns.CountryK, HotTopicsCountry.K);
				HotTopicsCountryThreadFilter = new Q(Thread.Columns.CountryK, HotTopicsCountry.K);
			}

			Query qPlace = new Query();
			qPlace.TopRecords = 20;
			qPlace.QueryCondition = new And(
				new Q(Place.Columns.TotalComments, QueryOperator.GreaterThan, 0),
				HotTopicsCountryPlaceFilter
				);
			qPlace.OrderBy = new OrderBy("(TotalComments - (Population/12.0)) DESC");
			PlaceSet ts = new PlaceSet(qPlace);
			if (ts.Count > 0)
			{
				BoardPlaceDataGrid.DataSource = ts;
				BoardPlaceDataGrid.DataBind();
			}
			else
				BoardPlacePanel.Visible = false;

			Query qEvent = new Query();
			qEvent.TopRecords = 20;
			qEvent.TableElement = Event.PlaceAllJoin;
			qEvent.QueryCondition = new And(
				new Q(Event.Columns.TotalComments, QueryOperator.GreaterThan, 0),
				HotTopicsCountryPlaceFilter
				);
			qEvent.OrderBy = new OrderBy("(Event.TotalComments - (CASE SIGN(DATEDIFF(day, Event.DateTime, GetDate())*2) WHEN 1 THEN DATEDIFF(day, Event.DateTime, GetDate())*2 WHEN 0 THEN 0 ELSE 0 END)) DESC");
			EventSet es = new EventSet(qEvent);
			if (es.Count > 0)
			{
				BoardEventDataGrid.DataSource = es;
				BoardEventDataGrid.DataBind();
			}
			else
				BoardEventPanel.Visible = false;

			Query qThread = new Query();
			qThread.TopRecords = 20;
			qThread.QueryCondition = new And(
				new Q(Thread.Columns.TotalComments, QueryOperator.GreaterThan, 2),
				new Q(Thread.Columns.Enabled, true),
				new Q(Thread.Columns.Private, false),
				new Q(Thread.Columns.GroupPrivate, false),
				new Q(Thread.Columns.PrivateGroup, false),
				HotTopicsCountryThreadFilter,
				new Q(Thread.Columns.HideFromHighlights, false)
				);
			qThread.OrderBy = Thread.HotTopicsOrderBy;
			ThreadSet threadSet = new ThreadSet(qThread);
			if (threadSet.Count > 0)
			{
				BoardThreadDataGrid.DataSource = threadSet;
				BoardThreadDataGrid.DataBind();
			}
			else
				BoardThreadPanel.Visible = false;
		}
Example #21
0
		public void DeleteAll(Transaction transaction)
		{
			
			if (!this.Bob.DbRecordExists)
				return;

			//GroupUsrs
			Delete GroupUsrDelete = new Delete(
				TablesEnum.GroupUsr,
				new Q(GroupUsr.Columns.GroupK, this.K)
				);
			GroupUsrDelete.Run(transaction);

			//GroupUsrs
			Delete GroupPhotoDelete = new Delete(
				TablesEnum.GroupPhoto,
				new Q(GroupPhoto.Columns.GroupK, this.K)
				);
			GroupPhotoDelete.Run(transaction);

			//GroupEvents
			Delete GroupEventDelete = new Delete(
				TablesEnum.GroupEvent,
				new Q(GroupEvent.Columns.GroupK, this.K)
			);
			GroupEventDelete.Run(transaction);

			ThreadSet ts = new ThreadSet(new Query(new Q(Thread.Columns.GroupK,this.K)));
			foreach (Thread t in ts)
				t.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);
			}
		}