Beispiel #1
0
		static void ProcessGalleriesThatHaveFinishedUploading()
		{
			Query q = new Query();

			q.QueryCondition = new And(
				new Q(Gallery.Columns.RunFinishedUploadingTask, false),
				new Q(Gallery.Columns.LastLiveDateTime, QueryOperator.LessThan, DateTime.Now.AddMinutes(-20)),
				new Q(Gallery.Columns.LivePhotos, QueryOperator.GreaterThan, 0));

			GallerySet gs = new GallerySet(q);
			
			foreach (Gallery g in gs)
			{
				g.RunFinishedUploadingTask = true;
				g.Update();
				if (g.Owner.FacebookConnected && g.Owner.FacebookStoryUploadPhoto)
				{
					try
					{
						FacebookPost.CreatePhotoUpload(g.Owner, g);
					}
					catch { }
				}
			}
		}
Beispiel #2
0
		private void Page_Load(object sender, System.EventArgs e)
		{
			Usr.KickUserIfNotLoggedIn();

			if (CurrentEvent != null)
			{
				if (CurrentEvent.NoPhotos)
				{
					ChangePanel(PanelNoPhoto);
				}
				else if (!IsFuture && !HasGalleries)
				{
					AddGallery();
				}
				else if (!IsFuture && HasGalleries && ContainerPage.Url["New"] == 1)
				{
					if (!Usr.Current.IsSpotter)
					{
						ChangePanel(CantAddGallery);

						EditCurrentGalleryLink.InnerText = galleries[0].Name;
						EditCurrentGalleryLink.HRef = galleries[0].UrlApp("edit");
					}
					else
						AddGallery();
				}
				else
				{
					if (HasGalleries && !IsFuture)
						ChangePanel(EventHasGalleriesPanel);
					else if (IsFuture)
						ChangePanel(FutureEventPanel);
				}
			}
			else if (CurrentArticle != null)
			{
				if (!Usr.Current.CanEdit(CurrentArticle))
					ChangePanel(NoEditArticlePanel);
				else
				{
					//try to find gallery in this article...
					GallerySet gs = new GallerySet(new Query(new Q(Gallery.Columns.ArticleK, ArticleK)));
					if (gs.Count == 0)
						AddGallery();
					else
						Response.Redirect(gs[0].UrlApp("edit"));
				}
			}
			else
			{
				AddGallery();
			}
			//throw new Exception("Must upload to either an event or an article");
		}
		public void FixDodgey(object o, System.EventArgs e)
		{
			Query tsq = new Query();
			tsq.QueryCondition = new Q(Gallery.Columns.TotalPhotos, QueryOperator.NotEqualTo, Gallery.Columns.LivePhotos, true);
			GallerySet gs = new GallerySet(tsq);

			foreach (Gallery g in gs)
			{
				g.UpdateStats(null, true);
			}

		}
		public override void DataBind()
		{
			if (SpotterUsr != null && !SpotterUsr.IsSkeleton)
			{
				AllGalleriesLink.HRef = SpotterUsr.UrlGalleries();
				AllGalleriesLink.InnerText = "Show all " + SpotterUsr.NickName + "'s galleries";


				Query q = new Query();
	
				q.TableElement = Templates.Galleries.Default.PerformJoins(null, false);
				q.Columns = Templates.Galleries.Default.Columns;

				q.QueryCondition = new And(
					new Or(
						new Q(Gallery.Columns.ArticleK, 0),
						new Q(Gallery.Columns.ArticleK, QueryOperator.IsNull, null)
					),
					Gallery.ShowOnSiteQ,
					new Q(Gallery.Columns.OwnerUsrK, SpotterUsr.K)
				);
				q.OrderBy = new OrderBy(Event.Columns.DateTime, OrderBy.OrderDirection.Descending);

				q.TopRecords = 8;

				GallerySet gs = new GallerySet(q);

				HasContent = gs.Count > 0;

				uiGalleriesShowAllLinkPanel.Visible = gs.Count == q.TopRecords;

				if (gs.Count > 0)
				{
					this.Visible = true;
					uiGalleriesDataList.DataSource = gs;
					uiGalleriesDataList.ItemTemplate = this.LoadTemplate("/Templates/Galleries/Default.ascx");
					uiGalleriesDataList.DataBind();
					this.uiGalleriesDataList.Visible = true;
				}
				else
				{
					this.uiNoGalleriesForThisSpotterP.Visible = true;
					BindToNoRecords();
				}
			}
			else
			{
				this.Visible = false;
				BindToNoRecords();
			}
		}
		public override void DataBind()
		{
			if (ThisEvent != null)
			{
				//uiAttendedEvent.ThisEvent = ThisEvent;
				//uiAttendedEvent.DataBind();

				Query q = new Query();

				q.TableElement = Templates.Galleries.Default.PerformJoins(null, false);
				q.Columns = Templates.Galleries.Default.Columns;

				q.QueryCondition = new And(
					new Or(
						new Q(Gallery.Columns.ArticleK, 0),
						new Q(Gallery.Columns.ArticleK, QueryOperator.IsNull, null)
					),
					Gallery.ShowOnSiteQ,
					new Q(Gallery.Columns.EventK, ThisEvent.K)
				);
				q.OrderBy = new OrderBy(Event.Columns.DateTime, OrderBy.OrderDirection.Descending);

				q.TopRecords = 8;

				GallerySet gs = new GallerySet(q);

				uiGalleriesShowAllLinkPanel.Visible = gs.Count == q.TopRecords;

				this.Visible = true;
				if (gs.Count > 0)
				{
					this.uiNoGalleriesForThisEventP.Visible = false;
					this.uiGalleriesDataList.DataSource = gs;
					this.uiGalleriesDataList.ItemTemplate = this.LoadTemplate("/Templates/Galleries/Default.ascx");
					this.uiGalleriesDataList.DataBind();
					this.uiGalleriesDataList.Visible = true;
				}
				else
				{
					this.uiNoGalleriesForThisEventP.Visible = true;
					BindToNoRecords();
				}
			}
			else
			{
				this.Visible = false;
				BindToNoRecords();
			}
		}
Beispiel #6
0
		protected void Page_Load(object sender, EventArgs e)
		{
			if (Usr.Current == null)
				Response.Redirect(ContainerPage.Url.ObjectFilterEvent.Url());
			else
			{
				Query q = new Query();
				q.QueryCondition = new And(new Q(Gallery.Columns.OwnerUsrK, Usr.Current.K), new Q(Gallery.Columns.EventK, ContainerPage.Url.ObjectFilterEvent.K));
				q.OrderBy = new OrderBy(Gallery.Columns.CreateDateTime, OrderBy.OrderDirection.Ascending);
				GallerySet gs = new GallerySet(q);
				if (gs.Count > 0)
					Response.Redirect(gs[0].Url());
				else
					Response.Redirect(ContainerPage.Url.ObjectFilterEvent.Url());
			}
		}
		void BindGalleries()
		{
			Query q = new Query();
			q.QueryCondition = new Q(Gallery.Columns.OwnerUsrK, Usr.Current.K);
			//q.TableElement=Gallery.EventVenueJoin;
			q.OrderBy = new OrderBy(Gallery.Columns.CreateDateTime, OrderBy.OrderDirection.Descending);
			GallerySet gs = new GallerySet(q);
			if (gs.Count > 0)
			{
				GalleriesDataGrid.AllowPaging = (gs.Count > GalleriesDataGrid.PageSize);
				GalleriesDataGrid.DataSource = gs;
				GalleriesDataGrid.DataBind();
			}
			else
			{
				GalleriesPanel.Visible = false;
				NoGalleriesPanel.Visible = true;
			}
		}
		void Bind()
		{
			if (CurrentGallery != null)
			{
				Query q = new Query();
				q.Columns = Templates.Photos.Admin.Columns;
				q.QueryCondition = new And(
					new Q(Photo.Columns.GalleryK, CurrentGallery.K), 
					new Q(Photo.Columns.Status, Photo.StatusEnum.Moderate));
				PhotoSet ps = new PhotoSet(q);

				ArrayList al = new ArrayList();
				foreach (Photo p in ps)
					al.Add(p.K);
				this.ViewState["Photos"] = al;

				PhotoDataList.DataSource = ps;
				PhotoDataList.ItemTemplate = this.LoadTemplate("/Templates/Photos/Admin.ascx");
				PhotoDataList.DataBind();
				PhotosPanel.Visible = ps.Count > 0;


				Query tsq = new Query();
				tsq.QueryCondition = new Q(Gallery.Columns.K, CurrentGallery.K);
				GallerySet gs = new GallerySet(tsq);
				GalleriesDataGrid.DataSource = gs;
				GalleriesDataGrid.DataBind();

			}
			else
			{
				Gallery g = GetNextGallery();
				if (g != null)
					Response.Redirect(g.UrlApp("moderate"));
				else
				{
					DonePanel.Visible = true;
					InfoPanel.Visible = false;
				}
				PhotosPanel.Visible = false;
			}
		}
		public void EditArticleParaPhotoPanel_Load(object o, System.EventArgs e)
		{
			if (ContainerPage.Url["Mode"].Equals("ParaPhoto"))
			{
				if ((CurrentArticle != null && !Usr.Current.CanEdit(CurrentArticle)) || (CurrentPara != null && !Usr.Current.CanEdit(CurrentPara.Article)))
				{
					ChangePanel(CantEditPanel);
					return;
				}
				if (!Page.IsPostBack)
				{
					ChangePanel(EditArticleParaPhotoPanel);
					if (CurrentPara.HasPicPrivate)
					{
						EditArticleParaPhotoHidden.Value = CurrentPara.PhotoK.ToString();
						if (CurrentPara.Photo.Article != null)
							EditArticleParaPhotoSourceUploadedCheck.Checked = true;
						else if (CurrentPara.Photo.Event != null && CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.Event) && CurrentPara.Photo.EventK == CurrentArticle.ParentObjectK)
							EditArticleParaPhotoSourceEventCheck.Checked = true;
						else
						{
							EditArticleParaPhotoSourceMiscCheck.Checked = true;
							EditArticleParaPhotoSourceKTextBox.Text = new Photo(CurrentPara.PhotoK).Url();
						}

						if (CurrentPara.PicPhoto != null)
						{
							EditArticleParaPhotoSaveNoResizeP.Visible = CurrentPara.PicPhoto.OriginalHeight <= 450 && CurrentPara.PicPhoto.OriginalWidth <= 565
								&& CurrentPara.PicPhoto.OriginalWidth >= 100 && CurrentPara.PicPhoto.OriginalHeight >= 100;
							EditArticleParaPhotoCropperPanel.Visible = true;
							EditArticleParaPhotoCropper.ImageUrl = CurrentPara.PicPhoto.CropPath;
							EditArticleParaPhotoCropper.ImageGuid = CurrentPara.PicPhoto.Crop;
							EditArticleParaPhotoCropper.ImageStore = Storage.Stores.Pix;
							EditArticleParaPhotoCropper.CropHeight = CurrentPara.PicHeight;
							EditArticleParaPhotoCropper.CropWidth = CurrentPara.PicWidth;
							if (CurrentPara.PicState.Length > 0)
								EditArticleParaPhotoCropper.SetState(CurrentPara.PicState);
						}
						else if (CurrentPara.Photo != null)
						{
							if (CurrentPara.Photo.MediaType.Equals(Photo.MediaTypes.Image))
							{
								EditArticleParaPhotoSaveNoResizeP.Visible = CurrentPara.Photo.OriginalHeight <= 450 && CurrentPara.Photo.OriginalWidth <= 565
								&& CurrentPara.Photo.OriginalWidth >= 100 && CurrentPara.Photo.OriginalHeight >= 100;
								EditArticleParaPhotoCropperPanel.Visible = true;
								EditArticleParaPhotoCropper.ImageUrl = CurrentPara.Photo.CropPath;
								EditArticleParaPhotoCropper.ImageGuid = CurrentPara.Photo.Crop;
								EditArticleParaPhotoCropper.ImageStore = Storage.Stores.Pix;
							}
							else if (CurrentPara.Photo.MediaType.Equals(Photo.MediaTypes.Video))
							{
								EditArticleParaPhotoVideoPanel.Visible = true;
								EditArticleParaPhotoCropperPanel.Visible = false;
								EditArticleParaPhotoVideo.Width = EditArticleParaPhotoCurrent.VideoMedWidth;
								EditArticleParaPhotoVideo.Height = EditArticleParaPhotoCurrent.VideoMedHeight;
								EditArticleParaPhotoVideo.JpgUrl = EditArticleParaPhotoCurrent.WebPath;
								EditArticleParaPhotoVideo.VideoUrl = EditArticleParaPhotoCurrent.VideoMedPath;
								EditArticleParaPhotoVideo.AutoStart = false;
							}
						}

						if (CurrentPara.PhotoType == Model.Entities.Para.PhotoTypes.None)
							EditArticleParaPhotoPositionHidden.Checked = true;
						else if (CurrentPara.PhotoAlign.Equals(Para.PhotoAlignEnum.Top))
							EditArticleParaPhotoPositionTop.Checked = true;
						else if (CurrentPara.PhotoAlign.Equals(Para.PhotoAlignEnum.Left))
							EditArticleParaPhotoPositionLeft.Checked = true;
						else if (CurrentPara.PhotoAlign.Equals(Para.PhotoAlignEnum.Right))
							EditArticleParaPhotoPositionRight.Checked = true;
						else if (CurrentPara.PhotoAlign.Equals(Para.PhotoAlignEnum.Bottom))
							EditArticleParaPhotoPositionBottom.Checked = true;
						



					}
				}
				EditArticleParaPhotoUploadLink.HRef = "/pages/galleries/add/articlek-" + CurrentArticle.K;
				PhotosIFrame.Attributes["src"] = "/popup/paraphotolist/k-" + CurrentArticle.K + "#Photo" + EditArticleParaPhotoHidden.Value;
				EditArticleParaPhotoSourceIFrame.Style["padding"] = "0px";
				EditArticleParaPhotoSourceIFrame.Style["margin-left"] = "24px";
				EditArticleParaPhotoSourceEventIFrame.Style["padding"] = "0px";
				EditArticleParaPhotoSourceEventIFrame.Style["margin-left"] = "24px";

				if (CurrentArticle.ParentObjectType.Equals(Model.Entities.ObjectType.Event))
				{
					GallerySet gs = new GallerySet(new Query(new And(new Q(Gallery.Columns.EventK, CurrentArticle.ParentObjectK), new Q(Gallery.Columns.TotalPhotos, QueryOperator.GreaterThan, 0)), new OrderBy(Gallery.Columns.Name)));
					EditArticleParaPhotoSourceEventPanel.Style["display"] = gs.Count > 0 ? null : "none";
					if (gs.Count > 0)
					{
						EditArticleParaPhotoSourceEventGalleryDropDown.DataSource = gs;
						EditArticleParaPhotoSourceEventGalleryDropDown.DataTextField = "Name";
						EditArticleParaPhotoSourceEventGalleryDropDown.DataValueField = "K";
						EditArticleParaPhotoSourceEventGalleryDropDown.Attributes["onchange"] =
							"if(document.forms[0].elements['" + EditArticleParaPhotoSourceEventGalleryDropDown.ClientID + "'].selectedIndex==0)" +
							"{document.getElementById('" + EditArticleParaPhotoSourceEventIFrame.ClientID + "').style.display='none';}else" +
							"{document.getElementById('" + EditArticleParaPhotoSourceEventIFrame.ClientID + "').style.display='';" +
							"document.getElementById('" + PhotosEventIFrame.ClientID + "').src='/popup/paraphotolist/galleryk-'+" +
							"document.forms[0].elements['" + EditArticleParaPhotoSourceEventGalleryDropDown.ClientID + "'][" +
								"document.forms[0].elements['" + EditArticleParaPhotoSourceEventGalleryDropDown.ClientID + "'].selectedIndex].value;}";
						EditArticleParaPhotoSourceEventGalleryDropDown.DataBind();
						EditArticleParaPhotoSourceEventGalleryDropDown.Items.Insert(0, new ListItem("select gallery here...", "0"));
						if (!Page.IsPostBack && EditArticleParaPhotoSourceEventCheck.Checked)
							EditArticleParaPhotoSourceEventGalleryDropDown.SelectedValue = CurrentPara.Photo.GalleryK.ToString();


					}
				}
				else
					EditArticleParaPhotoSourceEventPanel.Style["display"] = "none";

				EditArticleParaPhotoSourceUploadedCheck.Attributes["onclick"] =
					"document.getElementById('" + EditArticleParaPhotoSourceEventIFrame.ClientID + "').style.display='none';" +
					"document.getElementById('" + EditArticleParaPhotoSourceMiscRefP.ClientID + "').style.display='none';" +
					"document.getElementById('" + EditArticleParaPhotoSourceEventGalleriesP.ClientID + "').style.display='none';" +
					"document.getElementById('" + EditArticleParaPhotoSourceIFrame.ClientID + "').style.display='';";
				if (EditArticleParaPhotoSourceUploadedCheck.Checked)
				{
					EditArticleParaPhotoSourceIFrame.Style["display"] = null;
				}

				EditArticleParaPhotoSourceEventCheck.Attributes["onclick"] =
					"document.getElementById('" + EditArticleParaPhotoSourceEventIFrame.ClientID + "').style.display=" +
						"(document.forms[0].elements['" + EditArticleParaPhotoSourceEventGalleryDropDown.ClientID + "'].selectedIndex=='0'?'none':'');" +
					"document.getElementById('" + EditArticleParaPhotoSourceMiscRefP.ClientID + "').style.display='none';" +
					"document.getElementById('" + EditArticleParaPhotoSourceEventGalleriesP.ClientID + "').style.display='';" +
					"document.getElementById('" + EditArticleParaPhotoSourceIFrame.ClientID + "').style.display='none';";
				if (EditArticleParaPhotoSourceEventCheck.Checked)
				{
					EditArticleParaPhotoSourceEventGalleriesP.Style["display"] = null;
					EditArticleParaPhotoSourceEventGalleriesP.Style["margin-left"] = "24px";
					if (EditArticleParaPhotoSourceEventGalleryDropDown.SelectedValue != "0")
					{
						EditArticleParaPhotoSourceEventIFrame.Style["display"] = null;
						PhotosEventIFrame.Attributes["src"] = "/popup/paraphotolist/galleryk-" + int.Parse(EditArticleParaPhotoSourceEventGalleryDropDown.SelectedValue) + "#Photo" + EditArticleParaPhotoHidden.Value;
					}
				}

				EditArticleParaPhotoSourceMiscCheck.Attributes["onclick"] = "document.getElementById('" + EditArticleParaPhotoSourceEventIFrame.ClientID + "').style.display='none';document.getElementById('" + EditArticleParaPhotoSourceMiscRefP.ClientID + "').style.display='';document.getElementById('" + EditArticleParaPhotoSourceEventGalleriesP.ClientID + "').style.display='none';document.getElementById('" + EditArticleParaPhotoSourceIFrame.ClientID + "').style.display='none';";
				if (EditArticleParaPhotoSourceMiscCheck.Checked)
				{
					EditArticleParaPhotoSourceMiscRefP.Style["display"] = null;
					EditArticleParaPhotoSourceMiscRefP.Style["margin-left"] = "24px";
				}

			}
		}
		public void GalleriesPanel_Load(object o, System.EventArgs e)
		{
			if (OnlyShowThreads)
			{
				GalleriesPanel.Visible = false;
				return;
			}
			if (Discussable != null && Discussable.UsedDiscussable is Event)
			{
				GalleriesPanel.Visible = false;
				return;
			}
			int galleryCount = ((Items / 4) + 1) * 4;
			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(Place.Columns.CountryK, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Place)
				RelevanceQ = new Q(Place.Columns.K, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Venue)
				RelevanceQ = new Q(Venue.Columns.K, Discussable.UsedDiscussable.K);
			else if (Discussable.UsedDiscussable is Brand)
			{
				RelevanceQ = new Q(Brand.Columns.K, Discussable.UsedDiscussable.K);
			}
			else if (Discussable.UsedDiscussable is Group)
				RelevanceQ = new Q(Group.Columns.K, Discussable.UsedDiscussable.K);



			if (Discussable != null && Discussable.UsedDiscussable is Brand)
				q.TableElement = new Join(
					new TableElement(TablesEnum.Gallery),
					Event.BrandJoin,
					QueryJoinType.Inner,
					Gallery.Columns.EventK,
					Event.Columns.K);
			else if (Discussable != null && Discussable.UsedDiscussable is Group)
				q.TableElement = new Join(
					new TableElement(TablesEnum.Gallery),
					Event.GroupJoin,
					QueryJoinType.Inner,
					Gallery.Columns.EventK,
					Event.Columns.K);
			else
			{
				q.TableElement = new TableElement(TablesEnum.Gallery);
			}

			q.TableElement = Templates.Galleries.Default.PerformJoins(q.TableElement, Discussable != null && (Discussable.UsedDiscussable is Group || Discussable.UsedDiscussable is Brand));
			q.Columns = Templates.Galleries.Default.Columns;

			q.QueryCondition = new And(
				new Or(
				new Q(Gallery.Columns.ArticleK, 0),
				new Q(Gallery.Columns.ArticleK, QueryOperator.IsNull, null)
				),
				Gallery.ShowOnSiteQ,
				RelevanceQ
			);
			q.OrderBy = new OrderBy(Gallery.Columns.LastLiveDateTime, OrderBy.OrderDirection.Descending);
			q.TopRecords = galleryCount;

			GallerySet gs = new GallerySet(q);

			if (gs.Count == 0)
				GalleriesPanel.Visible = false;
			else
			{
				GalleriesDataList.DataSource = gs;
				GalleriesDataList.ItemTemplate = this.LoadTemplate("/Templates/Galleries/Default.ascx");
				GalleriesDataList.DataBind();


				if (Discussable == null)
					GalleriesArchiveAnchor.HRef = Archive.GetUrl(gs[0].CreateDateTime.Year, gs[0].CreateDateTime.Month, 0, ArchiveObjectType.Gallery, new string[] { }, "");
				else if (Discussable.UsedDiscussable is IHasArchive && gs.Count == galleryCount)
					GalleriesArchiveAnchor.HRef = ((IHasArchive)Discussable.UsedDiscussable).UrlArchiveDate(gs[0].CreateDateTime.Year, gs[0].CreateDateTime.Month, 0, ArchiveObjectType.Gallery);
				else
					GalleriesArchiveDiv.Visible = false;
			}
		}
Beispiel #11
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");

		}
Beispiel #12
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");

		}
		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
			}
		}
Beispiel #14
0
		public static void DailySendNewGalleryEmails()
		{
			DateTime StartDateTime = DateTime.Now;
			int UsrCount = 0;
			int FailCount = 0;
			try
			{
				Query q = new Query();
				if (Vars.DevEnv)
					q.TopRecords=100;
				q.TableElement = new TableElement(TablesEnum.Gallery);
				q.TableElement = new Join(
					q.TableElement,
					new TableElement(TablesEnum.UsrEventAttended),
					QueryJoinType.Inner,
					new And(
						new Q(Gallery.Columns.EventK, UsrEventAttended.Columns.EventK, true),
						new Q(UsrEventAttended.Columns.SendUpdate, true)
					)
				);
				q.TableElement = new Join(
					q.TableElement,
					new TableElement(new Column(UsrEventAttended.Columns.UsrK, Usr.Columns.K)),
					QueryJoinType.Inner,
					new And(
						new Q(UsrEventAttended.Columns.UsrK, new Column(UsrEventAttended.Columns.UsrK, Usr.Columns.K), true),
						new Q(new Column(UsrEventAttended.Columns.UsrK, Usr.Columns.IsSkeleton),false),
						new Q(new Column(UsrEventAttended.Columns.UsrK, Usr.Columns.IsEmailVerified),true)
					)
				);
				q.TableElement = new Join(
					q.TableElement,
					new TableElement(TablesEnum.Event),
					QueryJoinType.Inner,
					new Q(Gallery.Columns.EventK, Event.Columns.K, true)
					);
				q.TableElement = new Join(
					q.TableElement,
					new TableElement(TablesEnum.GalleryUsr),
					QueryJoinType.Left,
					new And(
						new Q(Gallery.Columns.K, GalleryUsr.Columns.GalleryK, true),
						new Q(UsrEventAttended.Columns.UsrK, GalleryUsr.Columns.UsrK, true)
					)
				);
				q.TableElement = new Join(
					q.TableElement,
					new TableElement(TablesEnum.Usr),
					QueryJoinType.Inner,
					new Q(Gallery.Columns.OwnerUsrK, Usr.Columns.K, true)
					);
				q.TableElement = new Join(
					q.TableElement,
					new TableElement(TablesEnum.Photo),
					QueryJoinType.Left,
					new Q(Gallery.Columns.MainPhotoK, Photo.Columns.K, true)
					);
				q.Columns = new ColumnSet(
						Gallery.Columns.K,
						Gallery.Columns.Name,
						Gallery.Columns.UrlFragment,
						Gallery.Columns.ArticleK,
						Gallery.Columns.MainPhotoK,
						Gallery.Columns.LivePhotos,
						Gallery.Columns.CreateDateTime, 
						Gallery.Columns.EventK, 
						Gallery.Columns.OwnerUsrK,
						Photo.Columns.K,
						Photo.Columns.Icon,
						Photo.Columns.ContentDisabled,
						Photo.Columns.Status,
						Usr.LinkColumns,
						UsrEventAttended.Columns.UsrK
					);
				int daysPast = -3;
				if (Vars.DevEnv)
					daysPast = -30;
				q.QueryCondition=new And(
					new Q(Gallery.Columns.LastLiveDateTime,QueryOperator.GreaterThan,DateTime.Now.AddDays(daysPast)),
					Gallery.ShowOnSiteQ,
					new Or(
						new Q(GalleryUsr.Columns.ViewPhotosLatest,QueryOperator.IsNull,null),
						new Q(Gallery.Columns.LivePhotos,QueryOperator.GreaterThan,GalleryUsr.Columns.ViewPhotosLatest,true)
					)
				);
				q.OrderBy=new OrderBy(
					new OrderBy(UsrEventAttended.Columns.UsrK),
					new OrderBy(Event.Columns.DateTime, OrderBy.OrderDirection.Descending),
					new OrderBy(Event.Columns.K),
					new OrderBy(Gallery.Columns.LivePhotos, OrderBy.OrderDirection.Descending),
					new OrderBy(Gallery.Columns.K)
				);
				GallerySet gs = new GallerySet(q);
				Usr CurrentUsr = null;
				Event CurrentEvent = null;
				Mailer CurrentMail = null;
				int RowCount = 0;
				int CurrentGalleryCount = 0;
				for (int count=0; count<gs.Count; count++)
				{
					try
					{
						Gallery CurrentGallery = gs[count];

						if (CurrentUsr==null || CurrentGallery.JoinedUsrEventAttend.UsrK!=CurrentUsr.K)
						{
							if (CurrentMail!=null)
							{
								Console.WriteLine(CurrentUsr.Email+" - "+CurrentGalleryCount.ToString()+", IsSkeleton="+CurrentUsr.IsSkeleton+", IsEmailVerified="+CurrentUsr.IsEmailVerified);
								CurrentGalleryCount=0;

								CurrentMail.Body+="</tr></table>";
								CurrentMail.Send();
							}

							CurrentEvent = null;
							CurrentUsr = new Usr(CurrentGallery.JoinedUsrEventAttend.UsrK);
							UsrCount++;
							
					
							CurrentMail = new Mailer();
							CurrentMail.Subject="New DontStayIn galleries "+DateTime.Today.ToString("ddddd dd MMMM yyyy");
							CurrentMail.UsrRecipient = CurrentUsr;
							CurrentMail.Body="<p>Here are some galleries you might like to check out:</p>";
							CurrentMail.Bulk=true;

						}
						if (CurrentEvent==null || CurrentGallery.EventK!=CurrentEvent.K)
						{
							if (CurrentEvent!=null)
							{
								CurrentMail.Body+="</tr></table>";
							}
							CurrentEvent = new Event(CurrentGallery.EventK);
							CurrentMail.Body+="<p style=\"margin:15px 0px 1px 0px;\"><center><a href=\"[LOGIN("+CurrentEvent.Url()+")]\" style=\"line-height:21px;font-size:18px;font-weight:bold;\">"+CurrentEvent.Name+"</a></center></p>";
							CurrentMail.Body+="<div style=\"margin:0px 0px 3px 0px;\"><center><small><a href=\"[LOGIN("+CurrentEvent.Venue.Url()+")]\">"+CurrentEvent.Venue.Name+"</a>, "+CurrentEvent.FriendlyDate(false)+", <a href=\"[LOGIN("+CurrentEvent.Url("ignore","")+")]\">click to ignore new galleries</a></small></center></div>";
							RowCount = 0;
							CurrentMail.Body+="<table cellspacing=\"0\" cellpadding=\"7\" width=\"100%\" style=\"margin:0px 0px 3px 0px;\"><tr>";
						}
						if (RowCount==3)
						{
							RowCount = 0;
							CurrentMail.Body+="</tr><tr>";
						}
						CurrentMail.Body += "<td align=\"center\" valign=\"top\" width=\"33%\"><a href=\"[LOGIN(" + CurrentGallery.Url() + ")]\"><img src=\"" + CurrentGallery.PicPathAbsolute + "\" width=\"100\" height=\"100\" class=\"BorderBlack All\" border=\"0\"><div style=\"padding:5px 0px 0px 0px;\">" + CurrentGallery.NameSafe + "</div></a><div style=\"padding:5px 0px 0px 0px;\"><small>" + CurrentGallery.LivePhotos.ToString("#,##0") + " photo" + (CurrentGallery.LivePhotos == 1 ? "" : "s") + ". Added by <a href=\"[LOGIN(" + CurrentGallery.Owner.Url() + ")]\">" + CurrentGallery.Owner.NickName + "</a></small></div></td>";
						RowCount++;
						CurrentGalleryCount++;
					}
					catch
					{
						FailCount++;
						CurrentUsr = null;
						CurrentEvent = null;
						CurrentMail = null;
					}
					gs.Kill(count);
				}
			}
			finally
			{
				string summary = "<p>Started: "+StartDateTime.ToLongTimeString()+"</p>";
				summary += "<p>Ending: "+DateTime.Now.ToLongTimeString()+"</p>";
				TimeSpan timeTaken = (DateTime.Now - StartDateTime);
				summary += "<p>Total time: "+timeTaken.TotalMinutes.ToString("0.##")+" min</p>";
				summary += "<p><b>Users with unseen galleries: "+UsrCount.ToString("#,##0")+"</b></p>";
				summary += "<p><b>Exceptions: "+FailCount.ToString("#,##0")+"</b></p>";

				Mailer smAdmin = new Mailer();
				smAdmin.TemplateType=Mailer.TemplateTypes.AdminNote;

				smAdmin.Body += "<h1>Summary</h1>";
				smAdmin.Body += summary;
			
				smAdmin.Subject="Gallery email sent "+DateTime.Now.ToString();
				smAdmin.To="*****@*****.**";
				smAdmin.Send();
			}
			
		}
		private void PanelAbuse_Load(object sender, System.EventArgs e)
		{
			if (Mode.Equals(Modes.Abuse))
			{
				ChangePanel(PanelAbuse);
				PhotoKLabel.Text = CurrentAbuse.ObjectK.ToString();
				PhotoStringLabel.Text = CurrentAbuse.ObjectString;
				Photo p = null;
				try
				{
					p = new Photo(CurrentAbuse.ObjectK);
				}
				catch { }

				if (p != null)
				{
					ThisGalleryP.InnerHtml = "<a href=\"" + p.Gallery.PagedUrl() + "\" target=\"_blank\">" + p.Gallery.UrlNoSkip() + "</a> - <a href=\"" + p.Gallery.UrlApp("edit") + "\" target=\"_blank\">[edit]</a> - (" + p.Gallery.TotalPhotos + " photos, " + p.Gallery.LivePhotos + " live)<br>";

					PhotoAnchor.HRef = p.Url();
					PhotoImg.Src = p.WebPath;
					PhotoImg.Height = p.WebHeight;
					PhotoImg.Width = p.WebWidth;
					PhotoPanel.Visible = true;
					NoPhotoPanel.Visible = false;
				}
				else
				{
					ThisGalleryPanel.Visible = false;
					PhotoPanel.Visible = false;
					NoPhotoPanel.Visible = true;
				}

				AbuseByP.InnerHtml = CurrentAbuse.AbuseUsr.LinkNewWindow() + "<br>";
				AbuseByP.InnerHtml += "Pending abuse accusations: " + CurrentAbuse.AbuseUsr.AbuseAccusationsPending + "<br>";
				AbuseByP.InnerHtml += "Abuse in the past: " + CurrentAbuse.AbuseUsr.AbuseAccusationsAbuse + "<br>";
				AbuseByP.InnerHtml += "Accusations with no abuse: " + CurrentAbuse.AbuseUsr.AbuseAccusationsNoAbuse;

				ReportByP.InnerHtml = CurrentAbuse.ReportUsr.LinkNewWindow() + "<br>";
				ReportByP.InnerHtml += "Pending abuse reports: " + CurrentAbuse.ReportUsr.AbuseReportsPending + "<br>";
				ReportByP.InnerHtml += "Successful abuse reports: " + CurrentAbuse.ReportUsr.AbuseReportsUseful + "<br>";
				ReportByP.InnerHtml += "Overturned abuse reports: " + CurrentAbuse.ReportUsr.AbuseReportsOverturned;

				ReportDescriptionP.InnerText = CurrentAbuse.ReportDescription;



				Query q = new Query();
				q.QueryCondition = new Q(Gallery.Columns.OwnerUsrK, CurrentAbuse.AbuseUsrK);
				q.TopRecords = 20;
				q.OrderBy = new OrderBy(Gallery.Columns.LastLiveDateTime, OrderBy.OrderDirection.Descending);
				GallerySet gs = new GallerySet(q);
				GalleriesP.InnerHtml = "";
				foreach (Gallery g in gs)
				{
					GalleriesP.InnerHtml += "<a href=\"" + g.PagedUrl() + "\" target=\"_blank\">" + g.UrlNoSkip() + "</a> - <a href=\"" + g.UrlApp("edit") + "\" target=\"_blank\">[edit]</a> - (" + g.TotalPhotos + " photos, " + g.LivePhotos + " live)<br>";
				}

				if (CurrentAbuse.Status.Equals(Abuse.StatusEnum.Done))
				{
					ActionsPanel.Visible = false;
					ResolvedPanel.Visible = true;
					if (CurrentAbuse.ResolveStatus.Equals(Abuse.ResolveStatusEnum.Abuse))
						ResolvedLabel.Text = "There was abuse.";
					else if (CurrentAbuse.ResolveStatus.Equals(Abuse.ResolveStatusEnum.NoAbuse))
						ResolvedLabel.Text = "There was no abuse, but the report was helpful.";
					else if (CurrentAbuse.ResolveStatus.Equals(Abuse.ResolveStatusEnum.Overturned))
						ResolvedLabel.Text = "There was no abuse, the report was overturned.";

					ResolvedLabel.Text += " Resolved by " + CurrentAbuse.ResolveUsr.Link() + ", " + Cambro.Misc.Utility.FriendlyTime(CurrentAbuse.ResolveDateTime);
					ResolveDescriptionP.InnerText = CurrentAbuse.ResolveDescription;

				}
				else
				{
					ActionsPanel.Visible = true;
					ResolvedPanel.Visible = false;
				}
			}
		}
		public void Action_Click(object o, System.EventArgs e)
		{
			if (Mode.Equals(Modes.Abuse))
			{
				if (Page.IsValid)
				{
					if (CurrentAbuse.Status.Equals(Abuse.StatusEnum.Done))
						throw new DsiUserFriendlyException("Oops - this abuse report has already been resolved - maybe someone beat you to it...");

					if (!(OverturnRadio.Checked || NoAbuseRadio.Checked || NoAbuseDeleteRadio.Checked || AbuseDeleteRadio.Checked || AbuseDeleteWatchRadio.Checked || AbuseDeleteBanRadio.Checked || AbuseDeleteBanModerateRadio.Checked))
					{
						throw new DsiUserFriendlyException("You must choose an option!");
					}

					if (OverturnRadio.Checked)
					{
						CurrentAbuse.ResolveDateTime = DateTime.Now;
						CurrentAbuse.Status = Abuse.StatusEnum.Done;
						CurrentAbuse.ResolveStatus = Abuse.ResolveStatusEnum.Overturned;
						CurrentAbuse.ResolveDescription = ResolveDescriptionTextBox.Text;
						CurrentAbuse.ResolveUsrK = Usr.Current.K;
						CurrentAbuse.Update();

						Photo p = null;
						try
						{
							p = new Photo(CurrentAbuse.ObjectK);
						}
						catch { }

						Mailer m = new Mailer();
						m.Subject = "Your abuse report has been resolved";
						m.Body = "<p>You recently filed an abuse report about a photo</p>";
						m.Body += "<p>Our moderators have reviewed the photo, and found no abuse. Please only report photos when there is a clear abuse of the photo rules. If you mis-use this abuse report service, you will not be able to make further reports.</p>";
						m.Body += "<p>Our moderator included the following note:</p>";
						m.Body += "<p><i>" + CurrentAbuse.ResolveDescription + "</i></p>";
						if (p != null)
							m.RedirectUrl = p.Url();
						m.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
						m.UsrRecipient = CurrentAbuse.ReportUsr;
						m.Send();

						CurrentAbuse.ReportUsr.UpdateAbuseTrackers();
						CurrentAbuse.AbuseUsr.UpdateAbuseTrackers();
						Bobs.Global.UpdatePhotoAbuseReports();

					}
					else if (NoAbuseRadio.Checked || NoAbuseDeleteRadio.Checked)
					{
						CurrentAbuse.ResolveDateTime = DateTime.Now;
						CurrentAbuse.Status = Abuse.StatusEnum.Done;
						CurrentAbuse.ResolveStatus = Abuse.ResolveStatusEnum.NoAbuse;
						CurrentAbuse.ResolveDescription = ResolveDescriptionTextBox.Text;
						CurrentAbuse.ResolveUsrK = Usr.Current.K;
						CurrentAbuse.Update();

						Photo p = null;
						try
						{
							p = new Photo(CurrentAbuse.ObjectK);
							if (NoAbuseDeleteRadio.Checked)
								p.DeleteAll(null);
						}
						catch { }

						Mailer m = new Mailer();
						m.Subject = "Your abuse report has been resolved";
						m.Body = "<p>You recently filed an abuse report about a photo</p>";
						m.Body += "<p>Our moderators have reviewed the photo, and found no abuse. Your report was helpful however.</p>";
						m.Body += "<p>Our moderator included the following note:</p>";
						m.Body += "<p><i>" + CurrentAbuse.ResolveDescription + "</i></p>";
						if (p != null)
							m.RedirectUrl = p.Url();
						m.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
						m.UsrRecipient = CurrentAbuse.ReportUsr;
						m.Send();

						CurrentAbuse.ReportUsr.UpdateAbuseTrackers();
						CurrentAbuse.AbuseUsr.UpdateAbuseTrackers();
						Bobs.Global.UpdatePhotoAbuseReports();
					}
					else if (AbuseDeleteRadio.Checked || AbuseDeleteWatchRadio.Checked || AbuseDeleteBanRadio.Checked || AbuseDeleteBanModerateRadio.Checked)
					{
						try
						{
							Photo ph = new Photo(CurrentAbuse.ObjectK);
							ph.DeleteAll(null);
						}
						catch { }

						if (AbuseDeleteWatchRadio.Checked)
						{
							try
							{
								CurrentAbuse.AbuseUsr.ModeratePhotos = true;
								CurrentAbuse.AbuseUsr.Update();
							}
							catch { }
						}

						if (AbuseDeleteBanRadio.Checked)
						{
							try
							{
								CurrentAbuse.AbuseUsr.Banned = true;
								CurrentAbuse.AbuseUsr.BannedByUsrK = Usr.Current.K;
								CurrentAbuse.AbuseUsr.BannedDateTime = DateTime.Now;
								CurrentAbuse.AbuseUsr.BannedReason = ResolveDescriptionTextBox.Text;
								CurrentAbuse.AbuseUsr.Update();

								Mailer sm = new Mailer();
								sm.Body = "<p>Banned user: <a href=\"[LOGIN(" + CurrentAbuse.AbuseUsr.Url() + ")]\">" + CurrentAbuse.AbuseUsr.NickName + "</a> (" + CurrentAbuse.AbuseUsr.K + " - " + CurrentAbuse.AbuseUsr.Email + ")</p>";
								sm.Body += "<p>They were banned by: <a href=\"[LOGIN(" + Usr.Current.Url() + ")]\">" + Usr.Current.NickName + "</a> (" + Usr.Current.K + " - " + Usr.Current.Email + ")</p>";
								sm.Body += "<p>DateTime: " + DateTime.Now.ToString() + "</p>";
								sm.Body += "<p>Reason: " + ResolveDescriptionTextBox.Text + "</p>";
								sm.TemplateType = Mailer.TemplateTypes.AdminNote;
								sm.Subject = "New banned user - " + CurrentAbuse.AbuseUsr.NickName + " was banned by " + Usr.Current.NickName;
								sm.To = "*****@*****.**";
								sm.Send();

							}
							catch { }
						}

						if (AbuseDeleteBanModerateRadio.Checked)
						{
							Query q = new Query();
							q.QueryCondition = new Q(Gallery.Columns.OwnerUsrK, CurrentAbuse.AbuseUsrK);
							GallerySet gs = new GallerySet(q);
							foreach (Gallery g in gs)
							{
								Query qP = new Query();
								qP.QueryCondition = new Q(Photo.Columns.GalleryK, g.K);
								PhotoSet ps = new PhotoSet(qP);
								foreach (Photo ph in ps)
								{
									ph.Status = Photo.StatusEnum.Moderate;
									ph.Update();
								}

								g.UpdateStats(null, true);
								g.UpdatePhotoOrder(null);

								if (g.Event != null)
									g.Event.UpdateTotalPhotos(null);
							}
						}

						CurrentAbuse.ResolveDateTime = DateTime.Now;
						CurrentAbuse.Status = Abuse.StatusEnum.Done;
						CurrentAbuse.ResolveStatus = Abuse.ResolveStatusEnum.Abuse;
						CurrentAbuse.ResolveDescription = ResolveDescriptionTextBox.Text;
						CurrentAbuse.ResolveUsrK = Usr.Current.K;
						CurrentAbuse.Update();

						Mailer m = new Mailer();
						m.Subject = "Your abuse report has been resolved";
						m.Body = "<p>You recently filed an abuse report about a photo</p>";
						m.Body += "<p>Our moderators have reviewed the photo, and found it breaks our rules. It has been deleted.</p>";
						m.Body += "<p>Our moderator included the following note:</p>";
						m.Body += "<p><i>" + CurrentAbuse.ResolveDescription + "</i></p>";
						m.TemplateType = Mailer.TemplateTypes.AnotherSiteUser;
						m.UsrRecipient = CurrentAbuse.ReportUsr;
						m.Send();

						CurrentAbuse.ReportUsr.UpdateAbuseTrackers();
						CurrentAbuse.AbuseUsr.UpdateAbuseTrackers();
						Bobs.Global.UpdatePhotoAbuseReports();
					}
					PanelAbuse_Load(null, null);
				}
			}
		}
Beispiel #17
0
		public GallerySet GalleriesWithJoinedGalleryUsr(OrderBy orderBy, int currentUsrK)
		{
			if (galleries == null)
			{
				Query q = new Query();
				q.QueryCondition = new And(
					new Q(Gallery.Columns.EventK, K), 
					//new Or(
						new Q(Gallery.Columns.LivePhotos, QueryOperator.GreaterThan, 0)//,
						//new Q(Gallery.Columns.OwnerUsrK, currentUsrK)
					//)
				);
				//q.TableElement = Gallery.OwnerJoin;
				//q.OrderBy = new OrderBy(" (CASE WHEN [Usr].[SpotterK]>0 THEN 1 ELSE 0 END) DESC, [Usr].[LoginCount] DESC ");
				q.OrderBy = orderBy;
				if (currentUsrK > 0)
				{
					q.TableElement = new Join(
						new TableElement(TablesEnum.Gallery),
						new TableElement(TablesEnum.GalleryUsr),
						QueryJoinType.Left,
						new And(
							new Q(Gallery.Columns.K, GalleryUsr.Columns.GalleryK, true),
							new Q(GalleryUsr.Columns.UsrK, currentUsrK)
						)
					);
				}
				galleries = new GallerySet(q);


			}
			return galleries;
		}
		public Gallery GetNextGallery()
		{
			Query tsq = new Query();
			tsq.QueryCondition = new Q(Gallery.Columns.TotalPhotos, QueryOperator.NotEqualTo, Gallery.Columns.LivePhotos, true);
			// order by: if in Random mode, any gallery, otherwise favour Article galleries first
			if (Random)
			{
				tsq.OrderBy = new OrderBy(OrderBy.OrderDirection.Random);
			}
			else
			{
				tsq.OrderBy = new OrderBy(new OrderBy("case when [ArticleK] > 0 then 1 else 0 end desc"), new OrderBy(OrderBy.OrderDirection.Random));
			}

			tsq.TopRecords = 1;
			GallerySet gs = new GallerySet(tsq);
			if (gs.Count > 0)
				return gs[0];
			else
				return null;
		}
Beispiel #19
0
		public void DeleteAll(Transaction transaction)
		{
			if (!this.Bob.DbRecordExists)
				return;
			
			if (this.ThreadK > 0)
				this.Thread.DeleteAll(transaction);


			foreach (Thread t in this.Threads)
				t.DeleteAll(transaction);

			foreach (Para p in this.AllPara)
				p.DeleteAll(transaction);


			GallerySet gs = new GallerySet(new Query(new Q(Gallery.Columns.ArticleK,this.K)));
			foreach (Gallery g in gs)
				g.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);
			}
		}
		private void Page_Load(object sender, System.EventArgs e)
		{
			
			//Query qBrands = new Query();
			//qBrands.NoLock = true;
			//qBrands.TableElement = new Join(Brand.Columns.PromoterK, Promoter.Columns.K);
			//qBrands.QueryCondition = new And(
			//    Promoter.EnabledQ,
			//    new Q(Brand.Columns.PromoterStatus, Brand.PromoterStatusEnum.Unconfirmed)
			//);
			//BrandSet bsUnconfirmed = new BrandSet(qBrands);
			//if (bsUnconfirmed.Count > 0)
			//{
			//    PanelUnconfirmedBrands.Visible = true;
			//    BrandRepeater.DataSource = bsUnconfirmed;
			//    BrandRepeater.DataBind();
			//}
			//else
			//    PanelUnconfirmedBrands.Visible = false;

			//Query qVenues = new Query();
			//qVenues.TableElement = new Join(Venue.Columns.PromoterK, Promoter.Columns.K);
			//qVenues.QueryCondition = new And(
			//    Promoter.EnabledQ,
			//    new Q(Venue.Columns.PromoterStatus, Venue.PromoterStatusEnum.Unconfirmed)
			//);
			//VenueSet vsUnconfirmed = new VenueSet(qVenues);
			//if (vsUnconfirmed.Count > 0)
			//{
			//    PanelUnconfirmedVenues.Visible = true;
			//    VenueRepeater.DataSource = vsUnconfirmed;
			//    VenueRepeater.DataBind();
			//}
			//else
			//    PanelUnconfirmedVenues.Visible = false;
			

			//Query qGuestlists = new Query();
			//qGuestlists.NoLock = true;
			//qGuestlists.QueryCondition = new And(
			//    new Q(Event.Columns.DateTime, QueryOperator.GreaterThan, DateTime.Today.AddDays(-7)),
			//    new Q(Event.Columns.HasGuestlist, true)
			//    );
			//qGuestlists.OrderBy = Event.FutureEventOrder;
			//EventSet guestlists = new EventSet(qGuestlists);
			//GuestlistDataGrid.DataSource = guestlists;
			//GuestlistDataGrid.DataBind();




			Query qBannedUsr = new Query();
			qBannedUsr.QueryCondition = new Q(Usr.Columns.Banned, true);
			qBannedUsr.NoLock = true;
			qBannedUsr.TopRecords = 10;
			qBannedUsr.OrderBy = new OrderBy(Usr.Columns.BannedDateTime, OrderBy.OrderDirection.Descending);
			UsrSet usBanned = new UsrSet(qBannedUsr);
			BannedUsrDataGrid.DataSource = usBanned;
			BannedUsrDataGrid.DataBind();


			Query qNotBookedBanners = new Query();
			qNotBookedBanners.QueryCondition = new And(
				new NotQ(Banner.IsBookedQ),
				new Q(Banner.Columns.LastDay, QueryOperator.GreaterThanOrEqualTo, DateTime.Today),
				new Q(Banner.Columns.PromoterK, QueryOperator.GreaterThan, 1)
				);
			qNotBookedBanners.NoLock = true;
			qNotBookedBanners.OrderBy = new OrderBy(Banner.Columns.FirstDay, OrderBy.OrderDirection.Descending);
			BannerSet notBookedBanners = new BannerSet(qNotBookedBanners);
			NotPaidForBanners.Banners = notBookedBanners;

			Query qBookedBanners = new Query();
			qBookedBanners.QueryCondition = new And(
				Banner.IsBookedQ,
				new NotQ(Banner.IsLiveQ),
				new Q(Banner.Columns.LastDay, QueryOperator.GreaterThanOrEqualTo, DateTime.Today)
			);
			qBookedBanners.NoLock = true;
			qBookedBanners.OrderBy = new OrderBy(Banner.Columns.FirstDay, OrderBy.OrderDirection.Descending);
			BannerSet bookedBanners = new BannerSet(qBookedBanners);
			PaidForBanners.Banners = bookedBanners;

			Query qLeaderboards = new Query();
			qLeaderboards.QueryCondition = new And(
				Banner.IsLiveQ,
				new Q(Banner.Columns.Position, Banner.Positions.Leaderboard)
				);
			qLeaderboards.NoLock = true;
			qLeaderboards.OrderBy = new OrderBy(Banner.Columns.FirstDay, OrderBy.OrderDirection.Descending);
			BannerSet leaderboards = new BannerSet(qLeaderboards);
			LiveLeaderboards.Banners = leaderboards;

			Query qHotBoxes = new Query();
			qHotBoxes.QueryCondition = new And(
				Banner.IsLiveQ,
				new Q(Banner.Columns.Position, Banner.Positions.Hotbox)
				);
			qHotBoxes.NoLock = true;
			qHotBoxes.OrderBy = new OrderBy(Banner.Columns.FirstDay, OrderBy.OrderDirection.Descending);
			BannerSet hotBoxes = new BannerSet(qHotBoxes);
			LiveHotBoxes.Banners = hotBoxes;

			Query qSkyscrapers = new Query();
			qSkyscrapers.QueryCondition = new And(
				Banner.IsLiveQ,
				new Q(Banner.Columns.Position, Banner.Positions.Skyscraper)
				);
			qSkyscrapers.NoLock = true;
			qSkyscrapers.OrderBy = new OrderBy(Banner.Columns.FirstDay, OrderBy.OrderDirection.Descending);
			BannerSet skyscrapers = new BannerSet(qSkyscrapers);
			LiveSkyscrapers.Banners = skyscrapers;

			Query qPhotoBanners = new Query();
			qPhotoBanners.QueryCondition = new And(
				Banner.IsLiveQ,
				new Q(Banner.Columns.Position, Banner.Positions.PhotoBanner)
				);
			qPhotoBanners.NoLock = true;
			qPhotoBanners.OrderBy = new OrderBy(Banner.Columns.FirstDay, OrderBy.OrderDirection.Descending);
			BannerSet photoBanners = new BannerSet(qPhotoBanners);
			LivePhotoBanners.Banners = photoBanners;


			Query qEmailBanners = new Query();
			qEmailBanners.QueryCondition = new And(
				Banner.IsLiveQ,
				new Q(Banner.Columns.Position, Banner.Positions.EmailBanner)
				);
			qEmailBanners.NoLock = true;
			qEmailBanners.OrderBy = new OrderBy(Banner.Columns.FirstDay, OrderBy.OrderDirection.Descending);
			BannerSet emailBanners = new BannerSet(qEmailBanners);
			LiveEmailBanners.Banners = emailBanners;

			//	LinkP.Visible=(us.Count>0);
			//	LinkP1.Visible=(usReq.Count>0);

			//Query vq = new Query();
			//vq.NoLock = false;
			//vq.QueryCondition = new Or(new Q(Venue.Columns.IsNew, true), new Q(Venue.Columns.IsEdited, true));
			//vq.ReturnCountOnly = true;
			//VenueSet vs = new VenueSet(vq);

			//Query eq = new Query();
			//eq.NoLock = false;
			//eq.QueryCondition = new Or(new Q(Event.Columns.IsNew, true), new Q(Event.Columns.IsEdited, true));
			//eq.ReturnCountOnly = true;
			//EventSet es = new EventSet(eq);

			//if (vs.Count == 0 && es.Count == 0)
			//    NewEvents.Text = "No new events / venues.";
			//else
			//    NewEvents.Text = es.Count.ToString() + " new/edited event(s) and " + vs.Count.ToString() + " new/edited venue(s). <a href=\"/pages/venues/moderate\">Click here to view them</a>.";

			GallerySet gs = new GallerySet(new Query(new Q(Gallery.Columns.TotalPhotos, QueryOperator.NotEqualTo, Gallery.Columns.LivePhotos, true)));
			GalleriesDataGrid.DataSource = gs;
			GalleriesDataGrid.DataBind();

			this.DataBind();

		}