Пример #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();
			}

		}
Пример #2
0
		public void Enable(object o, System.EventArgs e)
		{
			//			bool galleryEmptyBefore = false;
			//			if (CurrentGallery.LivePhotos==0)
			//				galleryEmptyBefore = true;
			bool sentChatAlert = false;

			ArrayList al = (ArrayList)this.ViewState["Photos"];
			foreach (int photoK in al)
			{
				try
				{
					Photo p = new Photo(photoK);
					if (p.GalleryK == CurrentGallery.K && p.Status.Equals(Photo.StatusEnum.Moderate))
					{
						p.Status = Photo.StatusEnum.Enabled;
						p.EnabledByUsrK = Usr.Current.K;
						p.EnabledDateTime = DateTime.Now;
						p.Update();
						if (!sentChatAlert)
						{
							p.SendPhotoChatAlerts();
							sentChatAlert = true;
						}
					}
				}
				catch
				{
				}
			}
			CurrentGallery.LastLiveDateTime = DateTime.Now;
			CurrentGallery.UpdateStats(null, true);
			CurrentGallery.UpdatePhotoOrder(null);

			CurrentGallery.Owner.UpdateTotalPhotos(null);

			if (CurrentGallery.Event != null)
			{
				CurrentGallery.Event.UpdateTotalPhotos(null);
				CurrentGallery.Event.UpdateTotalComments(null);
			}
			if (CurrentGallery.Article != null)
				CurrentGallery.Article.UpdateTotalComments(null);

			//			if (galleryEmptyBefore && CurrentGallery.LivePhotos>0)
			//			{
			//				//Send emails...
			//				new System.Threading.Thread(new ThreadStart(CurrentGallery.SendNewGalleryEmails)).Start();
			//			}

			Gallery g = GetNextGallery();
			if (g != null)
				Response.Redirect(g.UrlApp("moderate"));
			else
			{
				DonePanel.Visible = true;
				InfoPanel.Visible = false;
			}
		}
		public void EnableSelected(object o, System.EventArgs e)
		{
			int enabled = 0;
			bool sentChatAlert = false;

			//			bool galleryEmptyBefore = false;
			//			if (CurrentGallery.LivePhotos==0)
			//				galleryEmptyBefore = true;


			SelectedOutputP.InnerHtml = "";
			foreach (string str in Request.Form.Keys)
			{
				if (str.StartsWith("ucEditGalleryPhotoSelectK") && Request.Form[str].Equals("1"))
				{
					enabled++;
					string str1 = str.Substring(25);
					SelectedOutputP.InnerHtml += "Enabling photo " + str1 + "...";
					try
					{
						int photoK = int.Parse(str1);
						Photo p = new Photo(photoK);
						if (p.GalleryK != CurrentGallery.K)
						{
							SelectedOutputP.InnerHtml += " <b>FAILED</b> - photo is not in current gallery. Please contact admin with details.";
						}
						else if (!p.Status.Equals(Photo.StatusEnum.Moderate))
						{
							SelectedOutputP.InnerHtml += " <b>FAILED</b> - photo is not new. Maybe someone already enabled it?";
						}
						else
						{
							p.Status = Photo.StatusEnum.Enabled;
							p.EnabledByUsrK = Usr.Current.K;
							p.EnabledDateTime = DateTime.Now;
							p.Update();
							if (!sentChatAlert)
							{
								p.SendPhotoChatAlerts();
								sentChatAlert = true;
							}
							SelectedOutputP.InnerHtml += " Done.";
						}

					}
					catch
					{
						SelectedOutputP.InnerHtml += " <b>FAILED</b> - exception while deleting photo. Maybe someone already deleted it?";
					}
					SelectedOutputP.InnerHtml += "<br>";
				}
			}

			if (enabled == 0)
				SelectedOutputP.InnerHtml += "<b>NO PHOTOS ENABLED</b> - You didn't select any photos.";

			SelectedOutputP.Visible = true;

			if (enabled > 0)
			{
				CurrentGallery.LastLiveDateTime = DateTime.Now;
				CurrentGallery.UpdateStats(null, true);
				CurrentGallery.UpdatePhotoOrder(null);

				CurrentGallery.Owner.UpdateTotalPhotos(null);

				if (CurrentGallery.Event != null)
				{
					CurrentGallery.Event.UpdateTotalPhotos(null);
					CurrentGallery.Event.UpdateTotalComments(null);
				}
				if (CurrentGallery.Article != null)
					CurrentGallery.Article.UpdateTotalComments(null);

				//	if (galleryEmptyBefore && CurrentGallery.LivePhotos>0)
				//	{
				//		//Send emails...
				//		new System.Threading.Thread(new ThreadStart(CurrentGallery.SendNewGalleryEmails)).Start();
				//	}
			}

			Bind();
			ContainerPage.AnchorSkip("ActionsPanel");
		}
Пример #4
0
		public static void SendNow(Photo p, Random r)
		{
			try
			{
				p.SendPhotoChatAlerts();
				//Guid roomGuidAll = new Chat.RoomSpec(RoomType.NewPhotosAll, ObjectType.None, 0, ObjectType.None, 0).Guid;
				//Guid roomGuidSpotters = new Chat.RoomSpec(RoomType.NewPhotosSpotters, ObjectType.None, 0, ObjectType.None, 0).Guid;
				//Guid roomGuidPro = new Chat.RoomSpec(RoomType.NewPhotosProSpotters, ObjectType.None, 0, ObjectType.None, 0).Guid;

				//PhotoStub ps = new PhotoStub(
				//        Guid.NewGuid().Pack(),
				//        ItemType.PhotoAlert,
				//        DateTime.Now.Ticks.ToString(),
				//        roomGuidSpotters.Pack(),
				//        p.WebWidth,
				//        p.WebHeight,
				//        p.Url(),
				//        p.Web.ToString(),
				//        p.Icon.ToString(),
				//        false);

				//Chat.SendJsonChatItem(ps);
				//ps.guid = Guid.NewGuid().Pack();
				//ps.roomGuid = roomGuidAll.Pack();
				//Chat.SendJsonChatItem(ps);

				//if (p.Usr.IsProSpotter)
				//{
				//    PhotoStub ps1 = new PhotoStub(
				//        Guid.NewGuid().Pack(),
				//        ItemType.PhotoAlert,
				//        DateTime.Now.Ticks.ToString(),
				//        roomGuidPro.Pack(),
				//        p.WebWidth,
				//        p.WebHeight,
				//        p.Url(),
				//        p.Web.ToString(),
				//        p.Icon.ToString(),
				//        false);

				//    Chat.SendJsonChatItem(ps1);
				//    ps1.guid = Guid.NewGuid().Pack();
				//    ps1.roomGuid = roomGuidAll.Pack();
				//    Chat.SendJsonChatItem(ps1);
				//}
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex.ToString());
			}
		}