Beispiel #1
0
		public static void FinishProcessUploadedFile(Photo p, Gallery g, Usr u)
		{

			bool reEncoded = false;
			if (p.EnabledByUsrK > 0)
				reEncoded = true;

			#region Update status
			if ((u.TotalPhotoUploads > 50 && u.AbuseAccusationsPending == 0 && !u.ModeratePhotos) || reEncoded || u.IsAdmin)
			{
				p.Status = Photo.StatusEnum.Enabled;
				if (!reEncoded)
				{
					p.EnabledDateTime = DateTime.Now;
					p.EnabledByUsrK = u.K;
				}
			}
			else
			{
				p.Status = Photo.StatusEnum.Moderate;
			}
			#endregion

			#region Set tags
			string[] tagsFromClient = p.UploadTemporaryTags.Split(',', ';', '"', '\n');
			foreach (string tagText in tagsFromClient)
			{
				string s = tagText.Trim();
				if (s.Length > 0)
				{
					try
					{
						Tag.AddTag(s, p, u);
					}
					catch { }

				}
			}
			#endregion

			p.Update();

			#region Update gallery other photos in the gallery
			if (g.TotalPhotos == 0)
				g.MainPhotoK = p.K;

			g.UpdateStats(null, false);

			if (p.Status.Equals(Photo.StatusEnum.Enabled))
			{
				g.UpdatePhotoOrder(null);
				if (!reEncoded)
					g.LastLiveDateTime = DateTime.Now;

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

			g.Update();
			#endregion

			if (!reEncoded)
				u.LastPhotoUpload = DateTime.Now;

			u.UpdateTotalPhotos(null);

			if (p.Status == Photo.StatusEnum.Enabled)
			{
				p.SendPhotoChatAlerts();
			}

		}
		public void UseOfAColumnWhichDoesNotHaveCausesInvalidationInAWhereClauseSetThrowsAnException()
		{
			Caching.Instances.Main.FlushAll();
			Gallery gallery = new Gallery();
			gallery.Update();
			Photo photo = new Photo();
			photo.Status = Photo.StatusEnum.Moderate;
			photo.GalleryK = gallery.K;
			photo.Update();
			int count = gallery.ChildPhotos(new Q(Photo.Columns.ParentDateTime, DateTime.Now)).Count;
		}
		public void TestThatColumnsIncludedInWhereClausesClearTheCacheWhenTheyAreChanged()
		{
			Caching.Instances.Main.FlushAll();
			Gallery gallery = new Gallery();
			gallery.Update();
			Photo photo = new Photo();
			photo.Status = Photo.StatusEnum.Moderate;
			photo.GalleryK = gallery.K;
			photo.Update();
			Assert.AreEqual(1, gallery.ChildPhotos().Count);
			Assert.AreEqual(1, gallery.ChildPhotos(new Q(Photo.Columns.Status, Photo.StatusEnum.Moderate)).Count);
			Caching.Instances.Main.FlushAll();
			Assert.AreEqual(0, gallery.ChildPhotos(new Q(Photo.Columns.Status, Photo.StatusEnum.Enabled)).Count);
			photo.Status = Photo.StatusEnum.Enabled;
			photo.Update();
			Assert.AreEqual(0, gallery.ChildPhotos(new Q(Photo.Columns.Status, Photo.StatusEnum.Moderate)).Count);
			Assert.AreEqual(1, gallery.ChildPhotos(new Q(Photo.Columns.Status, Photo.StatusEnum.Enabled)).Count);
		}
Beispiel #4
0
		void AddGallery()
		{
			Gallery g = new Gallery();
			g.CreateDateTime = DateTime.Now;
			g.Name = Usr.Current.NickName + "'s photos";
			g.OwnerUsrK = Usr.Current.K;
			g.RunFinishedUploadingTask = false;

			if (CurrentEvent != null)
				g.EventK = EventK;
			else if (CurrentArticle != null)
				g.ArticleK = ArticleK;

			g.LivePhotos = 0;
			g.TotalPhotos = 0;
			g.UpdateUrlFragmentNoUpdate();
			g.Update();

			if (CurrentEvent != null)
			{
				Usr.Current.AttendEvent(CurrentEvent.K, true, Usr.Current.IsSpotter, null);
			}

			Response.Redirect(g.UrlApp("edit"));
		}