internal bool UsrHasBeenSpotted(int photoK, int usrK)
		{		
			try
			{
				UsrPhotoMe u = new UsrPhotoMe(usrK, photoK);
				return true;
			}
			catch
			{
				return false;
			}
		}
Beispiel #2
0
		public void PhotoMe(Photo p, bool MeOrNot, Transaction transaction)
		{
			try
			{
				UsrPhotoMe u = new UsrPhotoMe(this.K, p.K);
				if (!MeOrNot)
				{
					u.Delete(transaction);
					p.UpdateUsrCount(transaction);
					this.UpdatePhotosMeCount(true, transaction);
					p.Usr.UpdateSpottings(transaction);
				}
			}
			catch
			{
				if (MeOrNot)
				{
					if (p.EventK > 0)
						this.AttendEvent(p.EventK, true, null, transaction);

					UsrPhotoMe newU = new UsrPhotoMe();
					newU.UsrK = this.K;
					newU.PhotoK = p.K;
					newU.Update(transaction);

					p.UpdateUsrCount(transaction);
					this.UpdatePhotosMeCount(true, transaction);
					p.Usr.UpdateSpottings(transaction);
					
					if (FacebookConnected && FacebookStorySpotted)
					{
						FacebookPost.CreateSpotted(this, p);
					}
				}
			}
		}
Beispiel #3
0
		protected void Page_Load(object sender, EventArgs e)
		{
			HttpContext.Current.Items["VisitPhotos"] = 1;
			Response.ContentType="text/xml";
			string photoKString = "0";
			bool currentUsrInPhoto = false;
			bool currentUsrFavourite = false;
			string message = null;
			string exceptionMessage = null;
			try
			{
				XmlDocument requestXml = new XmlDocument();
				requestXml.Load(Request.InputStream);
				photoKString = requestXml.DocumentElement.Attributes["k"].Value;
				Photo currentPhoto = new Photo(int.Parse(photoKString));
				currentPhoto.IncrementViews();

				try
				{
					if (currentPhoto.Overlay.Equals(Photo.Overlays.DsiLogoBottomRightThinkBottomLeft) || currentPhoto.Overlay.Equals(Photo.Overlays.DsiLogoBottomRightThinkTextBottomLeft))
					{
						//int bannerK, Banner.Positions position, DateTime date, int hits, int uniqueHits, int clicks
						Bobs.BannerStat.Log(currentPhoto.Overlay.Equals(Photo.Overlays.DsiLogoBottomRightThinkBottomLeft) ? 9295 : 9296, Banner.Positions.Hotbox, DateTime.Now, 1, 0, 0);
					}
				}
				catch { }

				if (Usr.Current != null)
				{
					try
					{
						UsrPhotoMe upm = new UsrPhotoMe(Usr.Current.K, currentPhoto.K);
						currentUsrInPhoto = true;
					}
					catch { }
					try
					{
						UsrPhotoFavourite upf = new UsrPhotoFavourite(Usr.Current.K, currentPhoto.K);
						currentUsrFavourite = true;
					}
					catch { }
				}
				message = currentPhoto.UsrHtml;
			}
			catch(Exception ex)
			{
				currentUsrInPhoto = false;
				currentUsrFavourite = false;
				exceptionMessage = ex.Message;
				message = "Error!";
			}


			XmlTextWriter x = new XmlTextWriter(Response.OutputStream, System.Text.Encoding.UTF8);
			try
			{
				x.WriteStartElement("doc");
				x.WriteAttributeString("k", photoKString);
				x.WriteAttributeString("me", currentUsrInPhoto ? "1" : "0");
				x.WriteAttributeString("fav", currentUsrFavourite ? "1" : "0");
				if (exceptionMessage != null) { x.WriteAttributeString("ex", exceptionMessage); }
				x.WriteString(message);
			}
			finally
			{
				x.WriteEndElement();//doc
				x.Close();
			}
		}
		private void Page_Load(object sender, System.EventArgs e)
		{
			Usr.KickUserIfNotLoggedIn();

			if (Usr.Current.HasPic)
			{
				PicImg.Src = Usr.Current.PicPath;
				if (Usr.Current.PicPhotoK > 0)
					PicAnchor.HRef = ContainerPage.Url.CurrentUrl("type", "pic", "k", Usr.Current.PicPhotoK);

				
			}
			else
			{
				PanelUsrPic.Visible = false;
			}

			if (Usr.Current.HasChatPic)
			{
				
				ChatPicImg.Src = Usr.Current.ChatPicPath;
				if (Usr.Current.ChatPicPhotoK > 0)
					ChatPicAnchor.HRef = ContainerPage.Url.CurrentUrl("type", "chat", "k", Usr.Current.PicPhotoK);
			}
			else
			{
				PanelChatPic.Visible = false;
			}


			if (CurrentPhoto != null)
			{
				ChangePanel(PanelCrop);
				try
				{
					UsrPhotoMe pm = new UsrPhotoMe(Usr.Current.K, CurrentPhoto.K);
				}
				catch
				{
					throw new DsiUserFriendlyException("You're not in this photo!");
				}

				if (CurrentPhoto.K == Usr.Current.PicPhotoK && !Page.IsPostBack)
				{
					if (ContainerPage.Url["type"] == "pic")
						Cropper.SetState(Usr.Current.PicState);
					else
						Cropper.SetState(Usr.Current.ChatPicState);
				}

				if (UseMasterImageForCropping)
				{
					Cropper.ImageUrl = CurrentPhoto.MasterPath;
					Cropper.ImageGuid = CurrentPhoto.Master;
					Cropper.ImageStore = Storage.Stores.Master;
				}
				else
				{
					Cropper.ImageUrl = CurrentPhoto.CropPath;
					Cropper.ImageGuid = CurrentPhoto.Crop;
					Cropper.ImageStore = Storage.Stores.Pix;
				}

				if (ContainerPage.Url["type"] == "pic")
				{
					Cropper.CropWidth = 100;
					Cropper.CropHeight = 100;
				}
				else
				{
					Cropper.CropWidth = 300;
					Cropper.CropHeight = 100;
				}

				this.ViewState["PhotoK"] = CurrentPhoto.K;
			}
			else if (Usr.Current.PhotosMeCount == 0)
			{
				ChangePanel(PanelNoPhotosMe);
			}
			//else if (Usr.Current.PhotosMeCount == 1)
			//{
			//    ChangePanel(PanelCrop);
			//    CancelButton.Visible = false;
			//    if (!Page.IsPostBack)
			//        Cropper.SetState(Usr.Current.PicState);
			//    PanelUsrPic.Visible = true;
			//    PhotoSet photosMe = Usr.Current.PhotosMe(new ColumnSet(Photo.Columns.K, Photo.Columns.Crop, Photo.Columns.ContentDisabled, Photo.Columns.Master, Photo.Columns.Original), 2);
			//    if (photosMe.Count == 1)
			//    {
			//        if (UseMasterImageForCropping)
			//        {
			//            Cropper.ImageUrl = photosMe[0].MasterPath;
			//            Cropper.ImageGuid = photosMe[0].Master;
			//            Cropper.ImageStore = Storage.Stores.Master;
			//        }
			//        else
			//        {
			//            Cropper.ImageUrl = photosMe[0].CropPath;
			//            Cropper.ImageGuid = photosMe[0].Crop;
			//            Cropper.ImageStore = Storage.Stores.Pix;
			//        }
			//        this.ViewState["PhotoK"] = photosMe[0].K;
			//    }
			//    else
			//    {
			//        ChangePanel(PanelNoPhotosMe);
			//        Usr.Current.UpdatePhotosMeCount(true, null);
			//    }
			//}
			else
			{
				ChangePanel(PanelImages);
				BindImages();
			}

			if (Usr.Current.PicPhotoK == 0)
				ReCropButton.Visible = false;

			if (Usr.Current.ChatPicPhotoK == 0)
				ChatReCropButton.Visible = false;
		}
		public void Save_Click(object o, System.EventArgs e)
		{
			try
			{
				UsrPhotoMe pm = new UsrPhotoMe(Usr.Current.K, (int)this.ViewState["PhotoK"]);
			}
			catch
			{
				throw new DsiUserFriendlyException("You're not in this photo!");
			}

			if (Cropper.ClientDataIsCorrupt)
			{
				Response.Redirect(ContainerPage.Url.CurrentUrl());
				return;
			}

			if (ContainerPage.Url["type"] == "pic")
			{
				
				bool hasOldPic = Usr.Current.HasPic;
				Guid oldPic = Usr.Current.HasPic ? Usr.Current.Pic : Guid.Empty;

				bool hasOldChatPic = Usr.Current.HasChatPic;
				Guid oldChatPic = Usr.Current.HasChatPic ? Usr.Current.ChatPic.Value : Guid.Empty;

				Usr.Current.Pic = Guid.NewGuid();
				Usr.Current.PicPhotoK = (int)this.ViewState["PhotoK"];
				Usr.Current.PicState = Cropper.GetState();

				Cropper.Store(Usr.Current.Pic, Usr.Current, "Pic");

				Cropper.CropHeight = 100;
				Cropper.CropWidth = 300;
				Cropper.ResetStateToEnsureImageIsWithinCropArea();

				Usr.Current.ChatPic = Guid.NewGuid();
				Usr.Current.ChatPicPhotoK = (int)this.ViewState["PhotoK"];
				Usr.Current.ChatPicState = Cropper.GetState();

				Cropper.Store(Usr.Current.ChatPic.Value, Usr.Current, "ChatPic");

				Usr.Current.Update();

				if (hasOldPic)
					Storage.RemoveFromStore(Storage.Stores.Pix, oldPic, "jpg");

				if (hasOldChatPic)
					Storage.RemoveFromStore(Storage.Stores.Pix, oldChatPic, "jpg");

				Response.Redirect(ContainerPage.Url.CurrentUrl("type", "chat", "k", Usr.Current.ChatPicPhotoK));

			}
			else if (ContainerPage.Url["type"] == "chat")
			{
				if (Usr.Current.PicPhotoK != (int)this.ViewState["PhotoK"])
					throw new Exception("You must use the same photo for your profile picture as your chat picture.");

				bool hasOldChatPic = Usr.Current.HasChatPic;
				Guid oldChatPic = Usr.Current.HasChatPic ? Usr.Current.ChatPic.Value : Guid.Empty;

				Usr.Current.ChatPic = Guid.NewGuid();
				Usr.Current.ChatPicPhotoK = (int)this.ViewState["PhotoK"];
				Usr.Current.ChatPicState = Cropper.GetState();

				Cropper.Store(Usr.Current.ChatPic.Value, Usr.Current, "ChatPic");

				Usr.Current.Update();

				if (hasOldChatPic)
					Storage.RemoveFromStore(Storage.Stores.Pix, oldChatPic, "jpg");

				Response.Redirect(ContainerPage.Url.CurrentUrl("k", null));
			}
			
		}