public override void DataBind()
		{
			bool found = false;
			bool sendUpdates = false;
			if (Usr.Current != null)
			{
				try
				{
					UsrEventAttended u1 = new UsrEventAttended(Usr.Current.K, ThisEvent.K);
					sendUpdates = u1.SendUpdate;
					found = true;
				}
				catch { }
			}
			UsrEventAttendYes.Checked = found;// && Usr.Current != null;
			UsrEventAttendNo.Checked = !found;// && Usr.Current != null;
			GalleryUpdateP.Visible = found;
			GalleryUpdateCheckBox.Checked = sendUpdates;

			UsrEventAttendFutureLabel.Visible = ThisEvent.IsFuture;
			UsrEventAttendPastLabel.Visible = !ThisEvent.IsFuture;
			UsrEventAttendYes.Text = ThisEvent.IsFuture ? "I'll be there" : "I was there";
			UsrEventAttendNo.Text = ThisEvent.IsFuture ? "Not this one" : "Nope, missed it";

			UsrEventAttendYes.Attributes["onclick"] = "try { return WhenLoggedInRadio(this); } catch(ex) { return false; }";
			UsrEventAttendNo.Attributes["onclick"] = "try { return WhenLoggedInRadio(this); } catch(ex) { return false; }";
		}
		public void GalleryUpdate_Change(object o, System.EventArgs e)
		{
			Usr.KickUserIfNotLoggedIn("You have to be logged in to do this!");
			try
			{
				UsrEventAttended u1 = new UsrEventAttended(Usr.Current.K, ThisEvent.K);
				u1.SendUpdate = GalleryUpdateCheckBox.Checked;
				u1.Update();
			}
			catch { }
		}
Example #3
0
		void SignUp()
		{
			//Try to sign-up to cover an event.
			if (!Usr.Current.IsSpotter)
			{
				ChangePanel(PanelIntro1);
			}
			else if (CurrentEvent.NoPhotos)
			{
				ChangePanel(PanelNoPhoto);
			}
			else
			{
				UsrEventAttended es1 = null;
				try
				{
					es1 = new UsrEventAttended(Usr.Current.K, CurrentEvent.K);
					if (es1.Spotter)
					{
						ChangePanel(PanelAlreadySignedUp);
						PanelAlreadySignedUpEventLabel.Text = CurrentEvent.FriendlyName;
						PanelAlreadySignedUpEventLink.HRef = CurrentEvent.Url();
					}
				}
				catch { }
				if (es1 == null || !es1.Spotter)
				{
					Usr.Current.AttendEvent(CurrentEvent.K, true, true, null);

					ChangePanel(PanelSignedUp);

					PanelSignedUpEventLink.InnerText = CurrentEvent.FriendlyName;
					PanelSignedUpEventLink.HRef = CurrentEvent.Url();
				}
			}
		}
Example #4
0
		public void Guestlist(int EventK, bool GuestlistOrNot, Transaction transaction)
		{
			Event e = new Event(EventK);
			if (!e.HasGuestlist)
				return;
			if (!e.GuestlistOpen)
				return;
			if (e.GuestlistFull && GuestlistOrNot)
				return;

			try
			{
				UsrEventGuestlist u = new UsrEventGuestlist(this.K, EventK);
				if (!GuestlistOrNot)
				{
					u.Delete(transaction);
				}
			}
			catch
			{
				if (GuestlistOrNot)
				{
					UsrEventGuestlist newG = new UsrEventGuestlist();
					newG.DateTime = DateTime.Now;
					newG.UsrK = this.K;
					newG.EventK = EventK;
					newG.Update();

					try
					{
						UsrEventAttended u = new UsrEventAttended(this.K, EventK);
					}
					catch
					{
						this.AttendEvent(EventK, true, null, transaction);
					}
				}
			}
			e.UpdateGuestlistCount(transaction);
		}
Example #5
0
		public void AttendEvent(int EventK, bool AddendOrNot, object spotterObject, Transaction transaction)
		{
			bool doneChange = false;
			bool spotter = false;
			bool changeSpotter = spotterObject != null;
			if (changeSpotter)
				spotter = (bool)spotterObject;

			Event ev = new Event(EventK);

			try
			{
				UsrEventAttended u = new UsrEventAttended(this.K, EventK);
				if (!AddendOrNot)
				{
					this.Guestlist(EventK, false, transaction);
					u.Delete(transaction);
					doneChange = true;
				}
				if (changeSpotter && spotter != u.Spotter)
				{
					u.Spotter = spotter;
					u.Update();
					u.Event.UpdateHasSpotter(transaction);
				}
			}
			catch
			{
				if (AddendOrNot)
				{
					UsrEventAttended newU = new UsrEventAttended();
					newU.UsrK = this.K;
					newU.EventK = EventK;
					newU.SendUpdate = true;
					newU.Spotter = spotter;
					newU.Update(transaction);
					if (spotter && !newU.Event.HasSpotter)
						newU.Event.UpdateHasSpotter(transaction);

					doneChange = true;

					if (FacebookConnected && FacebookStoryAttendEvent)
					{
						FacebookPost.CreateAttendEvent(this, ev);
					}
				//	if (FacebookConnected && FacebookEventAttend)
				//	{
				//		FacebookPost.AddEvent(this, ev, true);
				//	}
				}
			}
			if (doneChange)
				Event.UpdateUsrAttendCountStatic(EventK);
		}
Example #6
0
		public void MergeAndDelete(Event merge)
		{
			if (this.K == merge.K)
				throw new DsiUserFriendlyException("Can't merge event into itself!");

			Cambro.Web.Helpers.WriteAlertHeader();

			//throw new Exception("This function isn't finished yet!");

			Cambro.Web.Helpers.WriteAlert("Starting merge...", 1);

			#region Articles
			if (true)
			{

				Query q = new Query();
				q.QueryCondition = new Q(Article.Columns.EventK, merge.K);
				ArticleSet ars = new ArticleSet(q);
				foreach (Article a in ars)
				{
					Cambro.Web.Helpers.WriteAlert("Merging article " + a.K + "...", 2);
					a.ParentObjectK = this.K;
					a.EventK = this.K;

					if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Venue)
						a.VenueK = this.VenueK;
					else
						a.VenueK = 0;

					if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Place)
						a.PlaceK = this.Venue.PlaceK;
					else
						a.PlaceK = 0;

					if (a.Relevance <= Model.Entities.Article.RelevanceEnum.Country)
						a.CountryK = this.Venue.Place.CountryK;
					else
						a.CountryK = 0;

					a.UrlFragment = this.UrlFilterPartVenueDate;
					a.Update();


					#region Threads
					if (true)
					{
						Update u = new Update();
						u.Table = TablesEnum.Thread;
						u.Where = new Q(Thread.Columns.ArticleK, a.K);
						u.Changes.Add(new Assign(Thread.Columns.UrlFragment, a.UrlFilterPart));
						u.Changes.Add(new Assign(Thread.Columns.EventK, this.K));
						u.Changes.Add(new Assign(Thread.Columns.VenueK, this.VenueK));
						u.Changes.Add(new Assign(Thread.Columns.PlaceK, this.Venue.PlaceK));
						u.Changes.Add(new Assign(Thread.Columns.CountryK, this.Venue.Place.CountryK));
						u.Run();
					}
					#endregion
					#region Galleries
					if (true)
					{
						Update u = new Update();
						u.Table = TablesEnum.Gallery;
						u.Where = new Q(Gallery.Columns.ArticleK, a.K);
						u.Changes.Add(new Assign(Gallery.Columns.UrlFragment, a.UrlFilterPart));
						u.Run();
					}
					#endregion
					#region Photos
					if (true)
					{
						Update u = new Update();
						u.Table = TablesEnum.Photo;
						u.Where = new Q(Photo.Columns.ArticleK, a.K);
						u.Changes.Add(new Assign(Photo.Columns.UrlFragment, a.UrlFilterPart));
						u.Run();
					}
					#endregion
				}
				Cambro.Web.Helpers.WriteAlert("Done merging articles...", 2);
			}
			#endregion
			#region Banners
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging banners...", 4);
				Update u = new Update();
				u.Table = TablesEnum.Banner;
				u.Where = new Q(Banner.Columns.EventK, merge.K);
				u.Changes.Add(new Assign(Banner.Columns.EventK, this.K));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging banners...", 4);
			}
			#endregion
			#region Comp
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging competitions...", 5);
				Update u = new Update();
				u.Table = TablesEnum.Comp;
				u.Where = new Q(Comp.Columns.EventK, merge.K);
				u.Changes.Add(new Assign(Comp.Columns.EventK, this.K));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging competitions...", 5);
			}
			#endregion
			#region EventMusicType
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging music types...", 6);
				Query q1 = new Query();
				q1.TableElement = MusicType.EventJoin;
				q1.QueryCondition = new Q(Event.Columns.K, merge.K);
				MusicTypeSet ems1 = new MusicTypeSet(q1);

				Query q2 = new Query();
				q2.TableElement = MusicType.EventJoin;
				q2.QueryCondition = new Q(Event.Columns.K, this.K);
				MusicTypeSet ems2 = new MusicTypeSet(q2);

				bool hasAllMuisc = false;
				ArrayList majorTypes = new ArrayList();
				ArrayList relevantTypes = new ArrayList();

				#region find major types
				foreach (MusicType mt in ems1)
				{
					if (mt.K == 1)
					{
						hasAllMuisc = true;
						break;
					}
					if (mt.ParentK == 1 && !majorTypes.Contains(mt.K))
						majorTypes.Add(mt.K);
				}
				if (!hasAllMuisc)
				{
					foreach (MusicType mt in ems2)
					{
						if (mt.K == 1)
						{
							hasAllMuisc = true;
							break;
						}
						if (mt.ParentK == 1 && !majorTypes.Contains(mt.K))
							majorTypes.Add(mt.K);
					}
				}
				#endregion
				if (!hasAllMuisc)
				{
					foreach (MusicType mt in ems1)
					{
						if (!majorTypes.Contains(mt.ParentK) && !relevantTypes.Contains(mt.K))
							relevantTypes.Add(mt.K);
					}
					foreach (MusicType mt in ems2)
					{
						if (!majorTypes.Contains(mt.ParentK) && !relevantTypes.Contains(mt.K))
							relevantTypes.Add(mt.K);
					}
				}
				if (hasAllMuisc || relevantTypes.Count == 0)
				{
					Delete d = new Delete(TablesEnum.EventMusicType, new Q(EventMusicType.Columns.EventK, this.K));
					d.Run();
					EventMusicType emt = new EventMusicType();
					emt.EventK = this.K;
					emt.MusicTypeK = 1;
					emt.Update();
				}
				else
				{
					Delete d = new Delete(TablesEnum.EventMusicType, new Q(EventMusicType.Columns.EventK, this.K));
					d.Run();
					foreach (int mtK in relevantTypes)
					{
						EventMusicType emt = new EventMusicType();
						emt.EventK = this.K;
						emt.MusicTypeK = mtK;
						emt.Update();
					}
				}
				Cambro.Web.Helpers.WriteAlert("Done merging music types...", 6);
			}
			#endregion
			#region EventBrand
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging brands...", 7);
				EventBrandSet ebs = new EventBrandSet(new Query(new Q(EventBrand.Columns.EventK, merge.K)));
				foreach (EventBrand eb in ebs)
				{
					try
					{
						EventBrand ebThis = new EventBrand(this.K, eb.BrandK);
					}
					catch
					{
						EventBrand ebThis = new EventBrand();
						ebThis.EventK = this.K;
						ebThis.BrandK = eb.BrandK;
						ebThis.Update();
					}
				}
				Cambro.Web.Helpers.WriteAlert("Done merging brands...", 7);
			}
			#endregion
			 
			#region Gallery
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging galleries...", 9);
				Update u = new Update();
				u.Table = TablesEnum.Gallery;
				u.Where = new Q(Gallery.Columns.EventK, merge.K);
				u.Changes.Add(new Assign(Gallery.Columns.EventK, this.K));
				u.Changes.Add(new Assign(Gallery.Columns.UrlFragment, this.UrlFilterPartVenueDate));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging galleries...", 9);
			}
			#endregion
			#region Photo
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging photos...", 10);
				Update u = new Update();
				u.Table = TablesEnum.Photo;
				u.Where = new Q(Photo.Columns.EventK, merge.K);
				u.Changes.Add(new Assign(Photo.Columns.EventK, this.K));
				u.Changes.Add(new Assign(Photo.Columns.UrlFragment, this.UrlFilterPartVenueDate));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging photos...", 10);
			}
			#endregion
			#region GroupEvent
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging group-event links...", 11);
				GroupEventSet ges = new GroupEventSet(new Query(new Q(GroupEvent.Columns.EventK, merge.K)));
				foreach (GroupEvent ge in ges)
				{
					try
					{
						GroupEvent geThis = new GroupEvent(ge.GroupK, this.K);
					}
					catch
					{
						GroupEvent geThis = new GroupEvent();
						geThis.EventK = this.K;
						geThis.GroupK = ge.GroupK;
						geThis.Update();
					}
				}
				Cambro.Web.Helpers.WriteAlert("Done merging group-event links...", 11);
			}
			#endregion
			#region Thread ParentObjects
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging topics (1/2)...", 12);
				Update u = new Update();
				u.Table = TablesEnum.Thread;
				u.Where = new And(
					new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Event),
					new Q(Thread.Columns.ParentObjectK, merge.K));
				u.Changes.Add(new Assign(Thread.Columns.ParentObjectK, this.K));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging topics (1/2)...", 12);
			}
			#endregion
			#region Thread
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging topics (2/2)...", 13);
				Update u = new Update();
				u.Table = TablesEnum.Thread;
				u.Where = new And(
					new Q(Thread.Columns.EventK, merge.K),
					new Q(Thread.Columns.ArticleK, 0));
				u.Changes.Add(new Assign(Thread.Columns.EventK, this.K));
				u.Changes.Add(new Assign(Thread.Columns.UrlFragment, this.UrlFilterPartVenueDate));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging topics (2/2)...", 13);
			}
			#endregion
			#region UsrEventAttended
			if (true)
			{
				Cambro.Web.Helpers.WriteAlert("Merging members...", 14);
				UsrEventAttendedSet ueas = new UsrEventAttendedSet(new Query(new Q(UsrEventAttended.Columns.EventK, merge.K)));
				foreach (UsrEventAttended uea in ueas)
				{
					try
					{
						UsrEventAttended ueaThis = new UsrEventAttended(uea.UsrK, this.K);
						bool changed = false;
						if (!uea.SendUpdate && ueaThis.SendUpdate)
						{
							ueaThis.SendUpdate = false;
							changed = true;
						}
						if (uea.Spotter && !ueaThis.Spotter)
						{
							ueaThis.Spotter = true;
							changed = true;
						}
						if (changed)
							ueaThis.Update();
					}
					catch
					{
						UsrEventAttended ueaThis = new UsrEventAttended();
						ueaThis.EventK = this.K;
						ueaThis.UsrK = uea.UsrK;
						ueaThis.SendUpdate = uea.SendUpdate;
						ueaThis.Spotter = uea.Spotter;
						ueaThis.Update();
					}
				}
				Cambro.Web.Helpers.WriteAlert("Done merging members...", 14);
			}
			#endregion

			if (!this.HasPic)
			{
				Cambro.Web.Helpers.WriteAlert("Merging picture...", 15);
				this.Pic = merge.Pic;
				this.PicMiscK = merge.PicMiscK;
				this.PicPhotoK = merge.PicPhotoK;
				this.PicState = merge.PicState;
				merge.Pic = Guid.Empty;
				merge.PicMiscK = 0;
				merge.PicPhotoK = 0;
				merge.PicState = "";
				merge.Update();
				Cambro.Web.Helpers.WriteAlert("Done merging picture...", 15);
			}

			this.AdminNote += "Event " + merge.K + " was merged with this one " + DateTime.Now.ToString() + ". The admin note from event " + merge.K + " is:\n********************\n" + merge.AdminNote + "\n********************\n";

			if (!this.HasGuestlist && merge.HasGuestlist)
			{
				Cambro.Web.Helpers.WriteAlert("Merging guestlist...", 16);
				this.HasGuestlist = true;
				this.GuestlistOpen = merge.GuestlistOpen;
				this.GuestlistFinished = merge.GuestlistOpen;
				this.GuestlistLimit = merge.GuestlistLimit;
				this.GuestlistCount = merge.GuestlistCount;
				this.GuestlistDetails = merge.GuestlistDetails;
				this.GuestlistPromoterK = merge.GuestlistPromoterK;
				this.GuestlistRegularPrice = merge.GuestlistRegularPrice;
				this.GuestlistPrice = merge.GuestlistPrice;
				this.GuestlistPromotion = merge.GuestlistPromotion;

				Delete d = new Delete(TablesEnum.UsrEventGuestlist, new Q(UsrEventGuestlist.Columns.EventK, this.K));
				d.Run();

				Update u = new Update();
				u.Table = TablesEnum.UsrEventGuestlist;
				u.Where = new Q(UsrEventGuestlist.Columns.EventK, merge.K);
				u.Changes.Add(new Assign(UsrEventGuestlist.Columns.EventK, this.K));
				u.Run();
				Cambro.Web.Helpers.WriteAlert("Done merging guestlist...", 16);
			}

			if (merge.Donated)
				this.Donated = true;

			if (merge.HasHilight)
				this.HasHilight = true;

			this.UpdateUsrAttendCount(false);

			this.Update();

			int mergeVenueK = merge.VenueK;

			Cambro.Web.Helpers.WriteAlert("Deleting old event...", 17);
			merge.DeleteAll(null);
			Cambro.Web.Helpers.WriteAlert("Done deleting old event...", 17);

			if (mergeVenueK != this.VenueK)
			{
				Venue mergeVenue = new Venue(mergeVenueK);
				Cambro.Web.Helpers.WriteAlert("Updating stats for old venue...", 18);
				mergeVenue.UpdateTotalComments(null);
				mergeVenue.UpdateTotalEvents(null);
				Cambro.Web.Helpers.WriteAlert("Done updating stats for old venue...", 18);
			}

			Cambro.Web.Helpers.WriteAlert("Updating stats for new event...", 19);
			this.UpdateMusicTypesStringNoUpdate();
			this.UpdateTotalComments(null);
			this.UpdateHasSpotter(null);
			this.UpdateTotalPhotos(null);
			this.Venue.UpdateTotalEvents(null);
			Cambro.Web.Helpers.WriteAlert("Done updating stats for new event...", 19);

			this.Update();
			Cambro.Web.Helpers.WriteAlert("Done merging events!", 20);


		}
Example #7
0
		public void CountUsrs_PlaceConditions_IncludingIfUsrHasBeenToEventInTown()
		{
			new Delete(TablesEnum.Usr, new Q(true)).Run();

			Random r = new Random();
			List<int> placeKs = new List<int>() { 1, 2, 3, 4 };

			Venue v = new Venue()
			{
				PlaceK = placeKs[0]
			};
			v.Update();

			Event e = new Event()
			{
				VenueK = v.K
			};
			e.Update();

			int usrsToCreate = 15;
			int usrs = 0;
			usrsToCreate.Times(() =>
			{
				Usr u = new Usr()
				{
					Email = Guid.NewGuid().ToString(),
					IsSkeleton = false,
					IsEmailVerified = true,
					SendFlyers = true
				};
				u.Update();

				int i = r.Next(placeKs.Count * 2);
				if (i < placeKs.Count)
				{
					UsrEventAttended ue = new UsrEventAttended()
					{
						UsrK = u.K,
						EventK = e.K
					};
					ue.Update();
					usrs++;
				}
			});

			Assert.AreEqual(usrs, Flyer.CountUsrs(placeKs, new List<int>(), false));
		}
Example #8
0
		private void CreateUsr(int musicTypeK, int homePlaceK, int eventPlaceK, int visitPlaceK, bool isPromoter)
		{
			Usr u = new Usr()
			{
				Email = Guid.NewGuid().ToString(),
				IsSkeleton = false,
				IsEmailVerified = true,
				SendFlyers = true,
				HomePlaceK = homePlaceK,
				IsPromoter = isPromoter
			};
			u.Update();

			UsrMusicTypeFavourite um = new UsrMusicTypeFavourite()
			{
				UsrK = u.K,
				MusicTypeK = musicTypeK
			};
			um.Update();



			Venue v = new Venue()
			{
				PlaceK = eventPlaceK
			};
			v.Update();

			Event e = new Event()
			{
				VenueK = v.K
			};
			e.Update();

			UsrEventAttended ue = new UsrEventAttended()
			{
				UsrK = u.K,
				EventK = e.K
			};
			ue.Update();


			UsrPlaceVisit up = new UsrPlaceVisit()
			{
				UsrK = u.K,
				PlaceK = visitPlaceK
			};
			up.Update();
		}