Esempio n. 1
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"));
		}
		void view_SelectedGalleryChanged(object sender, EventArgs<int> e)
		{
			if (e.Value == -1)
			{
				view.Redirect(view.EventFromUrl.UrlApp("photos"));
			}
			else
			{
				Gallery g = new Gallery(e.Value);
				view.Redirect(g.Url());
			}
		}
Esempio n. 3
0
		public void DeleteNow(object o, System.EventArgs e)
		{
			if (ObjectTypeDropDown.SelectedValue.Equals("Photo"))
			{
				Photo c = new Photo(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Gallery"))
			{
				Gallery c = new Gallery(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Venue"))
			{
				Venue c = new Venue(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Event"))
			{
				Event c = new Event(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Comment"))
			{
				Comment c = new Comment(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Thread"))
			{
				Thread c = new Thread(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Usr"))
			{
				Usr c = new Usr(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			else if (ObjectTypeDropDown.SelectedValue.Equals("Article"))
			{
				Article c = new Article(int.Parse(ObjectKTextBox.Text));
				SendEmail(c);
				Delete.DeleteAll(c);
			}
			DoneLabel.Visible = true;
		}
Esempio n. 4
0
		public bool CanUploadTo(Gallery g)
		{

		//	int totalPhotosIncludingProcessing = g.GetTotalPhotosIncludingProcessing();

		//	if (totalPhotosIncludingProcessing >= 100)
		//		return false;

			if (this.IsSuper)
				return true;

			if (this.K != g.OwnerUsrK)
				return false;

		//	if (!this.IsSpotter && totalPhotosIncludingProcessing >= 10)
			//	return false;

			return true;
		}
Esempio n. 5
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();
			}

		}
Esempio n. 6
0
		public static void ProcessUploadedFile(HttpPostedFile httpPostedFile, Gallery gallery, Random random, Usr usr, int rotate, string tags)
		{
			if (usr.CanUploadTo(gallery))
			{

				Photo photo = new Photo();
				try
				{

					#region Set general stuff
					photo.UsrK = usr.K;
					photo.RandomNumber = random.NextDouble();
					photo.WeightedCoolRating = 5.0;
					photo.WeightedSexyRating = 5.0;
					photo.Order = 5.0;
					if (tags.Length > 512)
						tags = tags.Substring(0, 512);
					photo.UploadTemporaryTags = tags;
					photo.Status = Photo.StatusEnum.Processing;
					#endregion
					#region Set gallery / event / article / url fragment stuff
					photo.GalleryK = gallery.K;
					if (gallery.Event != null)
					{
						photo.EventK = gallery.EventK;
						photo.DateTime = gallery.Event.DateTime;
						photo.ParentDateTime = gallery.Event.DateTime;
					}
					else if (gallery.Article != null)
					{
						photo.ArticleK = gallery.ArticleK;
						photo.DateTime = gallery.Article.AddedDateTime;
						photo.ParentDateTime = gallery.Article.AddedDateTime;
					}
					else
					{
						photo.DateTime = DateTime.Now;
						photo.ParentDateTime = gallery.CreateDateTime;
					}
					photo.UpdateUrlFragmentNoUpdate();
					#endregion

					photo.MediaType = Photo.GetMediaType(httpPostedFile.FileName);

					if (photo.MediaType.Equals(Photo.MediaTypes.Image))
					{
						#region Initialise Guids
						photo.UploadTemporary = Guid.NewGuid();
						photo.Master = Guid.NewGuid();
						photo.Web = Guid.NewGuid();
						photo.Thumb = Guid.NewGuid();
						photo.Icon = Guid.NewGuid();
						#endregion

						photo.Rotate = rotate;
						#region Extention
						try
						{
							string s = httpPostedFile.FileName.Substring(httpPostedFile.FileName.LastIndexOf(".") + 1).ToLower();
							if (s.Length < 10)
							{
								if (s == "jpeg" || s == "jpe")
									photo.UploadTemporaryExtention = "jpg";
								else
									photo.UploadTemporaryExtention = s;
							}
							else
								photo.UploadTemporaryExtention = "jpg";
						}
						catch
						{
							photo.UploadTemporaryExtention = "jpg";
						}
						#endregion
						
					}
					else if (photo.MediaType.Equals(Photo.MediaTypes.Video))
					{
						#region Initialise Guids
						photo.UploadTemporary = Guid.NewGuid();
						photo.VideoMaster = Guid.NewGuid();
						photo.VideoMed = Guid.NewGuid();
						photo.Master = Guid.NewGuid();
						photo.Web = Guid.NewGuid();
						photo.Thumb = Guid.NewGuid();
						photo.Icon = Guid.NewGuid();
						#endregion

						#region Extention
						photo.VideoFileExtention = httpPostedFile.FileName.Substring(httpPostedFile.FileName.LastIndexOf(".") + 1).ToLower();
						photo.UploadTemporaryExtention = photo.VideoFileExtention;
						#endregion

					}

					httpPostedFile.SaveAs(Storage.TemporaryFilesystemPath(photo.UploadTemporary, photo.UploadTemporaryExtention));

					photo.Status = Photo.StatusEnum.Processing;
					photo.Update();

					if (!gallery.WatchUploads.HasValue || gallery.WatchUploads.Value)
					{
						CommentAlert.Enable(usr, photo.K, Model.Entities.ObjectType.Photo);
					}


				}
				catch (Exception exc)
				{
					#region Send an email to admin
					try
					{
					    Mailer m = new Mailer();
					    m.Subject = "Exception uploading photo from " + System.Environment.MachineName + "...";
					    m.Body = "<p>" + exc.ToString() + "</p>";
					    try
					    {
					        m.Body += "<p>The content length was " + httpPostedFile.ContentLength.ToString("#,##0") + " bytes</p>";
					    }
					    catch { }
					    m.UsrRecipient = new Usr(4);
					    m.To = "*****@*****.**";
					    m.Send();
					}
					catch { }
					#endregion

					#region Delete file
					try
					{
						Storage.RemoveFromStore(Storage.Stores.Temporary, photo.UploadTemporary, photo.UploadTemporaryExtention);
					}
					catch { }
					#endregion

					photo.Delete();

					//try
					//{
					//    if (httpPostedFile.FileName.LastIndexOf(".") > -1)
					//        httpPostedFile.SaveAs(@"C:\FailedPix\" + Guid.NewGuid() + httpPostedFile.FileName.Substring(httpPostedFile.FileName.LastIndexOf(".")));
					//    else
					//        httpPostedFile.SaveAs(@"C:\FailedPix\" + Guid.NewGuid());
					//}
					//catch (Exception ex)
					//{
					//    Utilities.AdminEmailAlert("Error writing failed photo file to disk", "Error writing failed photo file to disk", ex);
					//}

				}
				//finally
				//{
				//    CurrentGallery.UpdateStats(null, true);
				//    CurrentGallery.UpdatePhotoOrder(null);
				//    if (CurrentGallery.Event != null) CurrentGallery.Event.UpdateTotalPhotos(null);
				//}
			}
		}
Esempio n. 7
0
		public PhotoResult GetPhotosByGalleryAndPage(int galleryK, int pageNumber)
		{
			Gallery g = new Gallery(galleryK);
			g.SetGalleryUsr(g.LivePhotos);
			return GetPhotos(g, pageNumber, false);
		}
Esempio n. 8
0
		public static IBob Get(Model.Entities.ObjectType type, int k)
		{
			IBob b = null;
			bool wrongType = false;
			try
			{
				switch (type)
				{
					case Model.Entities.ObjectType.Photo:
						b = new Photo(k);
						break;
					case Model.Entities.ObjectType.Event:
						b = new Event(k);
						break;
					case Model.Entities.ObjectType.Venue:
						b = new Venue(k);
						break;
					case Model.Entities.ObjectType.Place:
						b = new Place(k);
						break;
					case Model.Entities.ObjectType.Thread:
						b = new Thread(k);
						break;
					case Model.Entities.ObjectType.Country:
						b = new Country(k);
						break;
					case Model.Entities.ObjectType.Article:
						b = new Article(k);
						break;
					case Model.Entities.ObjectType.Para:
						b = new Para(k);
						break;
					case Model.Entities.ObjectType.Brand:
						b = new Brand(k);
						break;
					case Model.Entities.ObjectType.Promoter:
						b = new Promoter(k);
						break;
					case Model.Entities.ObjectType.Usr:
						b = new Usr(k);
						break;
					case Model.Entities.ObjectType.Region:
						b = new Region(k);
						break;
					case Model.Entities.ObjectType.Gallery:
						b = new Gallery(k);
						break;
					case Model.Entities.ObjectType.Group:
						b = new Group(k);
						break;
					case Model.Entities.ObjectType.Banner:
						b = new Banner(k);
						break;
					case Model.Entities.ObjectType.GuestlistCredit:
						b = new GuestlistCredit(k);
						break;
					case Model.Entities.ObjectType.Ticket:
						b = new Ticket(k);
						break;
					case Model.Entities.ObjectType.Invoice:
						b = new Invoice(k);
						break;
					case Model.Entities.ObjectType.InsertionOrder:
						b = new InsertionOrder(k);
						break;
					case Model.Entities.ObjectType.CampaignCredit:
						b = new CampaignCredit(k);
						break;
					case Model.Entities.ObjectType.UsrDonationIcon:
						b = new UsrDonationIcon(k);
						break;
					default:
						wrongType = true;
						b = null;
						break;
				}
			}
			catch { }
			if (wrongType)
				throw new Exception("Bob.Get attempted to get " + type.ToString() + " - can't do it!!! DUH!");
			return b;
		}
		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);
		}
		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;
		}
Esempio n. 11
0
		private void Page_Load(object sender, System.EventArgs e)
		{
			Gallery g = new Gallery(int.Parse(Request.QueryString["K"]));
			int photos = int.Parse(Request.QueryString["P"]);
			g.SetGalleryUsr(photos);
		}
Esempio n. 12
0
		public UrlPartTypes ProcessFilterPart(ref int currentIndex, string[] urlParts)
		{
			if (HasYearFilter && urlParts[currentIndex].Equals("tickets"))
			{
				#region tickets calendar
				PageType = PageTypes.Pages;
				PageName = "CalendarTickets";
				CurrentApplication = "tickets";
				currentIndex++;
				return UrlPartTypes.Application;
				#endregion
			}
			else if (HasYearFilter && urlParts[currentIndex].Equals("free"))
			{
				#region Free Guestlist calendar
				PageType = PageTypes.Pages;
				PageName = "CalendarFreeGuestlist";
				CurrentApplication = "free";
				currentIndex++;
				return UrlPartTypes.Application;
				#endregion
			}
			else if (urlParts[currentIndex].Equals("tags"))
			{
				#region tags
				PageType = PageTypes.Pages;
				PageName = "TagSearch";
				CurrentApplication = "tags";
				HasTagFilter = true;

				currentIndex++;
				if (urlParts.Length > currentIndex)
				{

					CurrentApplication = "tags/" + urlParts[currentIndex];

					foreach (string s in urlParts[currentIndex].Split('-'))
					{
						if (!s.Equals("all"))
							TagFilter.Add(Cambro.Web.Helpers.UrlTextDeSerialize(s));
					}

					currentIndex++;
				}
				return UrlPartTypes.Application;
				#endregion
			}
			else if ((HasBrandObjectFilter || HasVenueObjectFilter) && (urlParts[currentIndex].Equals("tickets") || urlParts[currentIndex].Equals("photos")))
			{
				#region Styled page
				currentIndex++;
				PageType = PageTypes.Styled;
				PageName = "Home";
				if (urlParts.Length > currentIndex &&
					YearRegex.IsMatch(urlParts[currentIndex]))
				{
					#region //year and month
					int year = int.Parse(urlParts[currentIndex]);
					if (year > 1990 && year < 2030)
					{
						HasYearFilter = true;
						DateFilter = new DateTime(year, 1, 1);
						PageName = "Calendar";
						currentIndex++;
						if (urlParts.Length > currentIndex &&
							MonthRegex.IsMatch(urlParts[currentIndex]))
						{
							int month = MonthNumber(urlParts[currentIndex]);
							HasMonthFilter = true;
							DateFilter = new DateTime(year, month, 1);
							currentIndex++;
						}
						return UrlPartTypes.Application;
					}
					#endregion
				}
				else if (urlParts.Length > currentIndex &&
					MonthRegex.IsMatch(urlParts[currentIndex]))
				{
					#region //month only - infer the year
					int requestedMonth = MonthNumber(urlParts[currentIndex]);
					HasYearFilter = true;
					HasMonthFilter = true;
					int requestedMonthIndex = (DateTime.Today.Year * 12) + requestedMonth;
					int currentMonthIndex = (DateTime.Today.Year * 12) + DateTime.Today.Month;
					DateTime d = new DateTime(DateTime.Today.Year, requestedMonth, 1);

					if (currentMonthIndex - requestedMonthIndex > 4)
					{
						d = new DateTime(DateTime.Today.Year + 1, requestedMonth, 1);
					}
					else if (currentMonthIndex - requestedMonthIndex < -7)
					{
						d = new DateTime(DateTime.Today.Year - 1, requestedMonth, 1);
					}

					DateFilter = d;
					PageName = "Calendar";
					currentIndex++;
					return UrlPartTypes.Application;
					#endregion
				}
				else if (urlParts.Length > currentIndex &&
					urlParts[currentIndex].ToLower().Equals("calendar"))
				{
					#region //todays month
					DateFilter = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
					PageName = "Calendar";
					currentIndex++;
					return UrlPartTypes.Application;
					#endregion
				}
				else if (urlParts.Length > currentIndex &&
					NumericRegex.IsMatch(urlParts[currentIndex]))
				{
					#region //event id
					PageName = "EventDetail";
					return UrlPartTypes.Application;
					#endregion
				}
				return UrlPartTypes.ObjectFilter;
				#endregion
			}
			else if (urlParts[currentIndex].Equals("parties"))
			{
				#region brand
				currentIndex++;
				Query brandQuery = new Query();
				brandQuery.NoLock = true;
				brandQuery.Columns = new ColumnSet(Brand.Columns.K);
				brandQuery.QueryCondition = new Q(Brand.Columns.UrlName, urlParts[currentIndex]);
				BrandSet bs = new BrandSet(brandQuery);
				if (bs.Count > 0)
				{
					HasObjectFilter = true;
					ObjectFilterType = Model.Entities.ObjectType.Brand;
					ObjectFilterK = bs[0].K;
					PageType = PageTypes.Application;
					PageName = "Home";
					CurrentFilter += "/parties/" + urlParts[currentIndex];
					currentIndex++;
					return UrlPartTypes.ObjectFilter;
				}
				return UrlPartTypes.Null;
				#endregion
			}
			else if (urlParts[currentIndex].Equals("groups"))
			{
				#region group
				currentIndex++;
				if (urlParts.Length > currentIndex)
				{
					string groupUrlName = urlParts[currentIndex];
					if (urlParts[currentIndex].Equals("parties"))
					{
						currentIndex++;
						groupUrlName = "parties/" + urlParts[currentIndex];
					}
					Query groupQuery = new Query();
					groupQuery.NoLock = true;
					groupQuery.Columns = new ColumnSet(Bobs.Group.Columns.K);
					groupQuery.QueryCondition = new Q(Bobs.Group.Columns.UrlName, groupUrlName);
					GroupSet gs = new GroupSet(groupQuery);
					if (gs.Count > 0)
					{
						HasObjectFilter = true;
						ObjectFilterType = Model.Entities.ObjectType.Group;
						ObjectFilterK = gs[0].K;
						PageType = PageTypes.Application;
						PageName = "Home";
						CurrentFilter += "/groups/" + groupUrlName;
						currentIndex++;
						return UrlPartTypes.ObjectFilter;
					}
				}
				PageType = PageTypes.Pages;
				PageName = "GroupBrowser";
				CurrentApplication = "groups";
				return UrlPartTypes.Application;
				#endregion
			}
			else if (!HasObjectFilter && urlParts[currentIndex].Equals("promoters"))
			{
				#region promoter
				currentIndex++;
				Query promoterQuery = new Query();
				promoterQuery.NoLock = true;
				promoterQuery.Columns = new ColumnSet(Promoter.Columns.K);
				promoterQuery.QueryCondition = new Q(Promoter.Columns.UrlName, urlParts[currentIndex]);
				PromoterSet ps = new PromoterSet(promoterQuery);
				if (ps.Count > 0)
				{
					HasObjectFilter = true;
					ObjectFilterType = Model.Entities.ObjectType.Promoter;
					ObjectFilterK = ps[0].K;
					PageType = PageTypes.Application;
					PageName = "Home";
					CurrentFilter += "/promoters/" + urlParts[currentIndex];
					currentIndex++;
					return UrlPartTypes.ObjectFilter;
				}
				return UrlPartTypes.Null;
				#endregion
			}
			else if (!HasObjectFilter && urlParts[currentIndex].Equals("members"))
			{
				#region members - usr
				currentIndex++;
				if (urlParts[currentIndex].Length > 0)
				{
					Usr usr = Usr.GetFromNickName(urlParts[currentIndex]);
					if (usr != null)
					{
						HasObjectFilter = true;
						ObjectFilterType = Model.Entities.ObjectType.Usr;
						ObjectFilterK = usr.K;
						PageType = PageTypes.Application;
						PageName = "Home";
						CurrentFilter += "/members/" + urlParts[currentIndex];
						currentIndex++;
						return UrlPartTypes.ObjectFilter;
					}
					//Query usrQuery = new Query();
					//usrQuery.NoLock = true;
					//usrQuery.Columns = new ColumnSet(Usr.Columns.K);
					//usrQuery.QueryCondition = new Q(Usr.Columns.NickName, urlParts[currentIndex]);
					//UsrSet us = new UsrSet(usrQuery);
					//if (us.Count > 0)
					//{
					//    HasObjectFilter = true;
					//    ObjectFilterType = Model.Entities.ObjectType.Usr;
					//    ObjectFilterK = us[0].K;
					//    PageType = PageTypes.Application;
					//    PageName = "Home";
					//    CurrentFilter += "/members/" + urlParts[currentIndex];
					//    currentIndex++;
					//    return UrlPartTypes.ObjectFilter;
					//}
				}
				return UrlPartTypes.Null;
				#endregion
			}
			else if (urlParts[currentIndex].StartsWith("event-"))
			{
				#region event
				try
				{
					Event ev = new Event(int.Parse(urlParts[currentIndex].Split('-')[1]));
					HasObjectFilter = true;
					ObjectFilterType = Model.Entities.ObjectType.Event;
					ObjectFilterK = ev.K;
					PageType = PageTypes.Application;
					PageName = "Home";
					CurrentFilter += "/" + urlParts[currentIndex];
					currentIndex++;
					return UrlPartTypes.ObjectFilter;
				}
				catch
				{
					currentIndex++;
				}
				return UrlPartTypes.Null;
				#endregion
			}
			else if (urlParts[currentIndex].StartsWith("gallery-"))
			{
				#region gallery
				try
				{
					Gallery g = new Gallery(int.Parse(urlParts[currentIndex].Split('-')[1]));
					HasObjectFilter = true;
					PageType = PageTypes.Application;
					PageName = "Home";
					ObjectFilterType = Model.Entities.ObjectType.Gallery;
					ObjectFilterK = g.K;
					CurrentFilter += "/" + urlParts[currentIndex];
					currentIndex++;
					return UrlPartTypes.ObjectFilter;
				}
				catch
				{
					currentIndex++;
				}
				return UrlPartTypes.Null;
				#endregion
			}
			else if (urlParts[currentIndex].StartsWith("photo-"))
			{
				#region photo
				try
				{
					Photo p = new Photo(int.Parse(urlParts[currentIndex].Split('-')[1]));
					HasObjectFilter = true;
					PageType = PageTypes.Application;
					PageName = "Home";
					ObjectFilterType = Model.Entities.ObjectType.Photo;
					ObjectFilterK = p.K;
					CurrentFilter += "/" + urlParts[currentIndex];
					currentIndex++;
					return UrlPartTypes.ObjectFilter;
				}
				catch
				{
					currentIndex++;
				}
				return UrlPartTypes.Null;
				#endregion
			}
			else if (urlParts[currentIndex].StartsWith("article-"))
			{
				#region article
				try
				{
					Article a = new Article(int.Parse(urlParts[currentIndex].Split('-')[1]));
					HasObjectFilter = true;
					PageType = PageTypes.Application;
					PageName = "Home";
					ObjectFilterType = Model.Entities.ObjectType.Article;
					ObjectFilterK = a.K;
					CurrentFilter += "/" + urlParts[currentIndex];
					currentIndex++;
					return UrlPartTypes.ObjectFilter;
				}
				catch
				{
					currentIndex++;
				}
				return UrlPartTypes.Null;
				#endregion
			}
			else if (GetMusicTypeK(urlParts[currentIndex].ToLower()) > 0)
			{
				#region music filter
				this.HasMusicFilter = true;
				this.MusicFilterK = GetMusicTypeK(urlParts[currentIndex].ToLower());
				CurrentFilter += "/" + urlParts[currentIndex].ToLower();
				currentIndex++;
				return UrlPartTypes.MusicFilter;
				#endregion
			}
			else if (GetThemeK(urlParts[currentIndex].ToLower()) > 0)
			{
				#region theme filter
				this.HasThemeFilter = true;
				this.ThemeFilterK = GetThemeK(urlParts[currentIndex].ToLower());
				CurrentFilter += "/" + urlParts[currentIndex].ToLower();
				currentIndex++;
				return UrlPartTypes.ThemeFilter;
				#endregion
			}
			else if (GetCountryK(urlParts[currentIndex].ToLower()) > 0)
			{
				#region Lookup country / place / venue
				HasObjectFilter = true;
				ObjectFilterType = Model.Entities.ObjectType.Country;
				ObjectFilterK = GetCountryK(urlParts[currentIndex].ToLower());
				PageType = PageTypes.Application;
				PageName = "Home";
				CurrentFilter += "/" + urlParts[currentIndex].ToLower();
				currentIndex++;
				int countryK = this.ObjectFilterK;

				if (urlParts.Length > currentIndex)
				{
					Country country = new Country(countryK);
					Q regionQ = new Q(true);
					if (country.UseRegion)
					{
						Query qRegion = new Query();
						qRegion.NoLock = true;
						qRegion.Columns = new ColumnSet(Region.Columns.K);
						qRegion.TopRecords = 1;
						qRegion.QueryCondition = new And(
							new Q(Region.Columns.CountryK, countryK),
							new Q(Region.Columns.Abbreviation, urlParts[currentIndex]));
						RegionSet rs = new RegionSet(qRegion);
						if (rs.Count > 0)
						{
							HasObjectFilter = true;
							ObjectFilterType = Model.Entities.ObjectType.Region;
							ObjectFilterK = rs[0].K;
							PageType = PageTypes.Application;
							PageName = "Home";
							int regionK = ObjectFilterK;
							regionQ = new Q(Place.Columns.RegionK, regionK);
							CurrentFilter += "/" + urlParts[currentIndex].ToLower();

							currentIndex++;

							if (!(urlParts.Length > currentIndex))
								return UrlPartTypes.ObjectFilter;
						}


					}
					#region Lookup place
					Query placeQuery = new Query();
					placeQuery.NoLock = true;
					placeQuery.Columns = new ColumnSet(Place.Columns.K);
					placeQuery.QueryCondition = new And(
						new Q(Place.Columns.Enabled, true),
						new Q(Place.Columns.CountryK, countryK),
						new Q(Place.Columns.UrlName, urlParts[currentIndex].ToLower()),
						regionQ
					);
					PlaceSet ps = new PlaceSet(placeQuery);
					if (ps.Count > 0)
					{
						HasObjectFilter = true;
						ObjectFilterType = Model.Entities.ObjectType.Place;
						ObjectFilterK = ps[0].K;
						PageType = PageTypes.Application;
						PageName = "Home";
						CurrentFilter += "/" + urlParts[currentIndex].ToLower();
						currentIndex++;
						int placeK = this.ObjectFilterK;

						if (urlParts.Length > currentIndex)
						{
							#region Lookup venue
							Query venueQuery = new Query();
							venueQuery.NoLock = true;
							venueQuery.Columns = new ColumnSet(Venue.Columns.K);
							venueQuery.QueryCondition = new And(
								new Q(Venue.Columns.PlaceK, placeK),
								new Q(Venue.Columns.UrlName, urlParts[currentIndex].ToLower())
								);
							VenueSet vs = new VenueSet(venueQuery);
							if (vs.Count > 0)
							{
								HasObjectFilter = true;
								ObjectFilterType = Model.Entities.ObjectType.Venue;
								ObjectFilterK = vs[0].K;
								PageType = PageTypes.Application;
								PageName = "Home";
								CurrentFilter += "/" + urlParts[currentIndex].ToLower();
								currentIndex++;
								int venueK = this.ObjectFilterK;
							}
							#endregion
						}
					}
					#endregion
				}
				return UrlPartTypes.ObjectFilter;
				#endregion
			}
			else if (YearRegex.IsMatch(urlParts[currentIndex]))
			{
				#region year / month / day
				int year = int.Parse(urlParts[currentIndex]);
				if (year > 1990 && year < 2030)
				{
					HasYearFilter = true;
					DateFilter = new DateTime(year, 1, 1);
					PageType = PageTypes.Pages;
					PageName = "Calendar";
					CurrentFilter += "/" + urlParts[currentIndex];
					currentIndex++;
					if (urlParts.Length > currentIndex && MonthRegex.IsMatch(urlParts[currentIndex]))
					{
						int month = MonthNumber(urlParts[currentIndex]);
						HasMonthFilter = true;
						DateFilter = new DateTime(year, month, 1);
						PageType = PageTypes.Pages;
						PageName = "Calendar";
						CurrentFilter += "/" + urlParts[currentIndex];
						currentIndex++;
						if (urlParts.Length > currentIndex && DayRegex.IsMatch(urlParts[currentIndex]))
						{
							int day = int.Parse(urlParts[currentIndex]);
							try
							{
								DateFilter = new DateTime(year, month, day);
								HasDayFilter = true;
								PageType = PageTypes.Pages;
								PageName = "Calendar";
								CurrentFilter += "/" + urlParts[currentIndex];
								currentIndex++;
							}
							catch
							{
								currentIndex++;
							}
						}
					}
					return UrlPartTypes.DateFilter;
				}
				else
					return UrlPartTypes.Null;
				#endregion
			}
			else if (urlParts[currentIndex].Equals("chat") || urlParts[currentIndex].Equals("messages"))
			{
				#region chat application
				PageType = PageTypes.Pages;
				PageName = "Chat";
				CurrentApplication = "chat";
				currentIndex++;
				if (ObjectFilterType.Equals(Model.Entities.ObjectType.Usr))
				{
					PageType = PageTypes.PagesFolder;
					PageFolder = "Usrs";
					PageName = "MyComments";
					CurrentApplication = "chat";
				}
				return UrlPartTypes.Application;
				#endregion
			}
			else if (urlParts[currentIndex].Equals("archive"))
			{
				#region archive application
				PageType = PageTypes.Pages;
				PageName = "Archive";
				CurrentApplication = "archive";
				currentIndex++;
				return UrlPartTypes.Application;
				#endregion
			}
			else if (urlParts[currentIndex].Equals("hottickets"))
			{
				#region hot tickets application
				PageType = PageTypes.Pages;
				PageName = "HotTickets";
				CurrentApplication = "hottickets";
				currentIndex++;
				return UrlPartTypes.Application;
				#endregion
			}
			else if (urlParts[currentIndex].Equals("home"))
			{
				#region home application
				CurrentApplication = "home";
				currentIndex++;
				return UrlPartTypes.Application;
				#endregion
			}
			else if (HasUsrObjectFilter && urlParts[currentIndex].Equals("photosof"))
			{
				#region photosof page
				currentIndex++;
				PageType = PageTypes.Application;
				PageName = "photosof";
				CurrentApplication = "photosof/" + urlParts[currentIndex].ToLower();
				currentIndex++;
				return UrlPartTypes.Application;
				#endregion
			}
			else
			{
				if (urlParts.Length > currentIndex)
				{
					if (!PageType.Equals(PageTypes.Styled))
						PageType = PageTypes.Application;
					PageName = urlParts[currentIndex].ToLower();
					CurrentApplication = urlParts[currentIndex].ToLower();
					currentIndex++;
					return UrlPartTypes.Application;
				}
				else
				{
					currentIndex++;
					return UrlPartTypes.Null;
				}
			}
		}
Esempio n. 13
0
		public static void CreatePhotoUpload(Usr u, Gallery g)
		{
			Query q = new Query();
			q.QueryCondition = new And(
				new Q(FacebookPost.Columns.DateTime, QueryOperator.GreaterThan, System.DateTime.Now.AddDays(-1)),
				new Q(FacebookPost.Columns.FacebookUid, u.Facebook.Uid),
				new Q(FacebookPost.Columns.Type, TypeEnum.PhotoUpload));
			FacebookPostSet fps = new FacebookPostSet(q);
			if (fps.Count < 10)
			{
				Query q1 = new Query();
				q1.QueryCondition = new And(
					new Q(FacebookPost.Columns.DateTime, QueryOperator.GreaterThan, System.DateTime.Now.AddDays(-1)),
					new Q(FacebookPost.Columns.FacebookUid, u.Facebook.Uid),
					new Q(FacebookPost.Columns.DataInt, g.K),
					new Q(FacebookPost.Columns.Type, TypeEnum.PhotoUpload));
				FacebookPostSet fps1 = new FacebookPostSet(q1);
				if (fps1.Count == 0)
				{

					FacebookPost fp = new FacebookPost();
					fp.Hits = 0;
					fp.FacebookUid = u.Facebook.Uid;
					fp.DateTime = System.DateTime.Now;
					fp.Type = TypeEnum.PhotoUpload;
					fp.Content = "GalleryK=" + g.K.ToString();
					fp.DataInt = g.K;
					fp.UsrK = u.K;
					fp.Update();

					//send facebook message
					//http://developers.facebook.com/docs/reference/api/post
					Dictionary<string, object> par = new Dictionary<string, object>();
					par["picture"] = g.MainPhoto != null ? g.MainPhoto.IconPath : "http://www.dontstayin.com/gfx/logo-90.png";
					par["link"] = "http://" + Vars.DomainName + g.Url() + "?fbpk=" + fp.K.ToString();
					par["caption"] = "Don't Stay In";
					if (g.Event != null)
					{
						par["name"] = g.Event.FriendlyNameGeneric(true, false, false, false);
						par["description"] = ("@ " + g.Event.FriendlyNameGeneric(false, true, true, true)).TruncateWithDots(990);
					}
					else if (g.Article != null)
					{
						par["name"] = g.Article.Name;
					}
					par["description"] = "";
					u.Facebook.PutWallPost("", par);
				}
			}
		}