public void TestThatGeneratedCacheKeysAreInvalidatedWhenAForeignKeyIsChangedInAChildTable()
		{
			Caching.Instances.Main.FlushAll();
			Venue venue = new Venue();
			venue.Update();
			Venue venue2 = new Venue();
			venue2.Update();
			Event ev = new Event() { VenueK = venue.K };
			ev.Update();
			string value = Guid.NewGuid().ToString();
			Caching.Instances.Main.Store(new NamespacedCacheKey(CacheKeyPrefix.BobCacheItem, Caching.CacheKeys.Venue.Events(venue.K)), value);
			Caching.Instances.Main.Store(new NamespacedCacheKey(CacheKeyPrefix.BobCacheItem, Caching.CacheKeys.Venue.Events(venue2.K)), value);
			ev.VenueK = venue2.K;
			ev.Update();
			Assert.IsNull(Caching.Instances.Main.Get(new NamespacedCacheKey(CacheKeyPrefix.BobCacheItem, Caching.CacheKeys.Venue.Events(venue.K))));
			Assert.IsNull(Caching.Instances.Main.Get(new NamespacedCacheKey(CacheKeyPrefix.BobCacheItem, Caching.CacheKeys.Venue.Events(venue2.K))));
		}
		public void EnableSelected(object o, System.EventArgs e)
		{
			OutputP.InnerHtml = "";
			foreach (string str in Request.Form.Keys)
			{
				if (str.StartsWith("ucAdminEventSelectedK") && Request.Form[str].Equals("1"))
				{
					string str1 = str.Substring(21);
					OutputP.InnerHtml += "Enabling event " + str1 + "...";
					try
					{
						int eventK = int.Parse(str1);
						Event ev = new Event(eventK);
						ev.IsNew = false;
						ev.IsEdited = false;
						ev.Update();
						OutputP.InnerHtml += " Done.";
					}
					catch
					{
						OutputP.InnerHtml += " <b>FAILED</b> - exception while enabling event. Please contact admin with details.";
					}
					OutputP.InnerHtml += "<br>";
				}


				if (str.StartsWith("ucAdminVenueSelectedK") && Request.Form[str].Equals("1"))
				{
					string str1 = str.Substring(21);
					OutputP.InnerHtml += "Enabling venue " + str1 + "...";
					try
					{
						int venueK = int.Parse(str1);
						Venue ven = new Venue(venueK);
						ven.IsNew = false;
						ven.IsEdited = false;
						ven.Update();
						OutputP.InnerHtml += " Done.";
					}
					catch
					{
						OutputP.InnerHtml += " <b>FAILED</b> - exception while enabling venue. Please contact admin with details.";
					}
					OutputP.InnerHtml += "<br>";
				}
			}

			OutputP.Visible = true;

			Bind();
		}
		public static void AddEvent(Usr u, Event e, bool attendEvent)
		{

			throw new Exception("Disabled");

			try
			{
				long id = 0;
				if (e.FacebookEventId.HasValue)
				{
					id = e.FacebookEventId.Value;
				}
				else
				{
					#region add event
					FacebookGraphAPI dsiPage = FacebookGraphAPI.GetPageApi(Facebook.Apps.Dsi);

					Dictionary<string, object> ev = new Dictionary<string, object>();
					//access_token, name, description, location, street, city, privacy_type, start_time, end_time, picture
					ev["name"] = e.Name;
					ev["location"] = e.FriendlyNameGeneric(false, true, true, false);
					ev["file.jpg"] = Cropper.TryToGetLargerPic(e, 1.79);
					DateTime d = e.DateTime;
					if (e.StartTime == Model.Entities.Event.StartTimes.Morning)
						d = d.AddHours(6);
					else if (e.StartTime == Model.Entities.Event.StartTimes.Daytime)
						d = d.AddHours(14);
					else if (e.StartTime == Model.Entities.Event.StartTimes.Evening)
						d = d.AddHours(22);
					ev["start_time"] = d.ToString("s");
					ev["end_time"] = d.AddHours(8).ToString("s");
					ev["privacy_type"] = "OPEN";
					ev["no_story"] = "1";


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

					Newtonsoft.Json.Linq.JObject post;

					try
					{

						ev["description"] = "Click for full details: http://" + Vars.DomainName + e.UrlShort() + "?fbpk=" + fp.K.ToString();

						//Newtonsoft.Json.Linq.JObject post = u.Facebook.PutObject(u.Facebook.Uid.ToString(), "events", ev);
						post = dsiPage.PutObject(FacebookCommon.Common(Facebook.Apps.Dsi).PageId.ToString(), "events", ev);

					}
					catch
					{
						fp.Delete();
						return;
					}



					try
					{
						id = long.Parse(post["id"].ToString());

					}
					catch { }

					if (id > 0)
					{
						e.FacebookEventId = id;
						e.Update();
					}
					#endregion
				}


				if (attendEvent && id > 0 && u.FacebookConnected && u.FacebookEventAttend)
				{
					try
					{
						u.Facebook.PutObject(id.ToString(), "attending", new Dictionary<string, object>());
					}
					catch { }
				}
			}
			catch
			{
			}
		}
Exemple #4
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));
		}
Exemple #5
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();
		}
Exemple #6
0
		public int DuplicateEvent()
		{
			Transaction t = null;//new Transaction();
			Event ev = new Event();
			try
			{
				ev.AddedDateTime = DateTime.Now;
				ev.VenueK = SelectedEvent.VenueK;
				ev.Name = SelectedEvent.Name;
				ev.StartTime = SelectedEvent.StartTime;
				ev.DateTime = NewDateCalendar.SelectedDate;
				ev.ShortDetailsHtml = SelectedEvent.ShortDetailsHtml;
				ev.LongDetailsHtml = SelectedEvent.LongDetailsHtml;
				ev.IsDescriptionText = SelectedEvent.IsDescriptionText;
				ev.IsDescriptionCleanHtml = SelectedEvent.IsDescriptionCleanHtml;
				ev.Capacity = SelectedEvent.Capacity;
				ev.AdminNote = "Event copied from event " + SelectedEvent.K.ToString() + " by owner " + DateTime.Now.ToString();

				if (SelectedEvent.AdminNote.Length > 0)
					ev.AdminNote += "\nprevious admin note: \n*******\n" + SelectedEvent.AdminNote + "\n*******";

				ev.OwnerUsrK = Usr.Current.K;

				ev.IsNew = true;
				ev.ModeratorUsrK = Usr.GetEventModeratorUsrK();
				
				ev.InitUrlFragment();
				ev.Update(t);
				if (SelectedEvent.Pic != Guid.Empty)
				{
					ev.Pic = Guid.NewGuid();

					Storage.AddToStore(
						Storage.GetFromStore(Storage.Stores.Pix, SelectedEvent.Pic, "jpg"),
						Storage.Stores.Pix,
						ev.Pic,
						"jpg",
						ev,
						"Pic");

				}
				ev.Update(t);
				

				foreach (Brand b in SelectedEvent.Brands)
				{
					EventBrand eb = new EventBrand();
					eb.BrandK = b.K;
					eb.EventK = ev.K;
					eb.Update(t);
				}

				ev.Venue.UpdateTotalEvents(t);
				ev.Owner.UpdateEventCount(t);

				if (SelectedEvent.MusicTypes.Count > 0)
				{
					foreach (MusicType mt in SelectedEvent.MusicTypes)
					{
						EventMusicType emt = new EventMusicType();
						emt.EventK = ev.K;
						emt.MusicTypeK = mt.K;
						emt.Update(t);
					}
				}
				ev.UpdateMusicTypesString(t);

				//t.Commit();
			}
			catch (Exception ex)
			{
				//t.Rollback();
				ev.DeleteAll(null);
				if (!ev.Pic.Equals(Guid.Empty))
				{
					Storage.RemoveFromStore(Storage.Stores.Pix, ev.Pic, "jpg");
				}
				throw ex;
			}
			finally
			{
				//t.Close();
			}

			return ev.K;

		}