Beispiel #1
0
		public void CreateUniqueUrlName(bool updateGroup)
		{
			string urlName = UrlInfo.GetUrlName(this.Name);
			if (urlName.Length==0)
				urlName = "brand-"+this.K.ToString();
			if (UrlInfo.IsReservedString(urlName))
				urlName = "brand-"+urlName;

			BrandSet bs = null;
			int namePost = 0;
			string newName = urlName;
			while (bs==null || bs.Count>0)
			{
				if (namePost>0)
					newName = urlName+"-"+namePost.ToString();
				Query q = new Query();
				q.NoLock=true;
				q.ReturnCountOnly=true;
				q.QueryCondition=new And(
					new Q(Brand.Columns.UrlName,newName),
					new Q(Brand.Columns.K,QueryOperator.NotEqualTo,this.K)
				);
				bs = new BrandSet(q);
				namePost++;
			}
			
			if (!this.UrlName.Equals(newName))
			{
				this.UrlName = newName;
				this.Update();
				Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Brand, this.K, true);
				job.ExecuteAsynchronously();

				if (updateGroup)
				{
					this.Group.UrlName="parties/"+newName;
					this.Group.Update();
					
					Utilities.UpdateChildUrlFragmentsJob job1 = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Group, this.GroupK, true);
					job1.ExecuteAsynchronously();

				}
			}
		}
Beispiel #2
0
		public void SaveNow()
		{
			if (Page.IsValid)
			{
				if (IsEdit)
				{
					if (!Usr.Current.CanEdit(CurrentVenue))
						throw new Exception("You can't edit this venue!");
					else
					{
						bool changedName = false;
						bool changedPlace = false;
						string newName = Cambro.Web.Helpers.StripHtml(PanelDetailsVenueName.Text.Trim());
						if (!CurrentVenue.Name.Equals(newName))
						{
							changedName = true;
							CurrentVenue.Name = newName;
						}
						CurrentVenue.Postcode = Cambro.Web.Helpers.StripHtml(PanelDetailsPostcodeTextBox.Text);
						CurrentVenue.Capacity = int.Parse(PanelDetailsVenueCapacity.Text);
						CurrentVenue.RegularEvents = PanelDetailsVenueRegularEventsYes.Checked;
						CurrentVenue.DetailsHtml = PanelDetailsVenueDetailsHtml.GetHtml();
						if (CurrentVenue.AdminNote.Length > 0)
							CurrentVenue.AdminNote += "\n";
						CurrentVenue.AdminNote += "Venue modified by " + Usr.Current.NickName + " (K=" + Usr.Current.K.ToString() + ") " + DateTime.Now.ToString();

						if (Usr.Current.IsSuper)
						{
							CurrentVenue.IsNew = false;
							CurrentVenue.IsEdited = false;
						}
						else
						{
							CurrentVenue.IsEdited = true;
							CurrentVenue.ModeratorUsrK = Usr.GetEventModeratorUsrK();
						}


						CurrentVenue.Update();

						if (changedName)
							CurrentVenue.CreateUniqueUrlName(false);

						if (CanEditPlace)
						{
							Place p = PanelDetailsPlacePicker.Place;
							if (p.K != CurrentVenue.PlaceK)
							{
								changedPlace = true;
								CurrentVenue.ChangePlace(p.K, false);
							}
						}
						if (changedName || changedPlace)
						{
							CurrentVenue.UpdateUrlFragment(false);

							Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Venue, CurrentVenue.K, true);
							job.ExecuteAsynchronously();


						}
						Response.Redirect(CurrentVenue.UrlApp("edit", "page", "pic"));
					}
				}
				else if (IsNew)
				{
					//Duplicate?
					VenueSet vsDup = new VenueSet(new Query(new Q(Venue.Columns.DuplicateGuid, (Guid)ContainerPage.ViewStatePublic["VenueDuplicateGuid"])));
					if (vsDup.Count == 0)
					{
						Venue v = Venue.Add(
							Usr.Current,
							Cambro.Web.Helpers.StripHtml(PanelDetailsVenueName.Text.Trim()),
							int.Parse(PanelDetailsVenueCapacity.Text),
							PanelDetailsPlacePicker.Place.K,
							Cambro.Web.Helpers.StripHtml(PanelDetailsPostcodeTextBox.Text),
							PanelDetailsVenueRegularEventsYes.Checked,
							(Guid)ContainerPage.ViewStatePublic["VenueDuplicateGuid"],
							PanelDetailsVenueDetailsHtml.GetHtml()
						);
						Response.Redirect(v.UrlApp("edit", "page", "pic"));

					}
					else
					{
						Response.Redirect(vsDup[0].UrlApp("edit", "page", "pic"));
					}
				}

			}
		}
Beispiel #3
0
		public void CreateUniqueUrlName(bool UpdateChildUrlFragments)
		{
			string urlName = UrlInfo.GetUrlName(this.Name);
			if (urlName.Length==0)
				urlName = "venue-"+this.K.ToString();
			if (UrlInfo.IsReservedString(urlName))
				urlName = "venue-"+urlName;

			VenueSet vs = null;
			int namePost = 0;
			string newName = urlName;
			while (vs==null || vs.Count>0)
			{
				if (namePost>0)
					newName = urlName+"-"+namePost.ToString();
				Query q = new Query();
				q.NoLock=true;
				q.ReturnCountOnly=true;
				q.QueryCondition=new And(
					new Q(Columns.PlaceK,this.PlaceK),
					new Q(Columns.K,QueryOperator.NotEqualTo,this.K),
					new Q(Columns.UrlName,newName));
				vs = new VenueSet(q);
				namePost++;
			}
			if (!this.UrlName.Equals(newName))
			{
				this.UrlName = newName;
				this.Update();
				if (UpdateChildUrlFragments)
				{
					Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Venue, this.K, true);
					job.ExecuteAsynchronously();
				}
			}
		}
Beispiel #4
0
		public void UpdateChildUrlFragments(bool Cascade)
		{
			Update uEvents = new Update();
			uEvents.Table=TablesEnum.Event;
			uEvents.Changes.Add(new Assign(Event.Columns.UrlFragment,UrlFilterPart));
			uEvents.Where=new Q(Event.Columns.VenueK,this.K);
			uEvents.Run();

			if (Cascade)
			{
				Query q = new Query();
				q.NoLock=true;
				q.QueryCondition=new Q(Event.Columns.VenueK,this.K);
				q.Columns=new ColumnSet(
					Event.Columns.K, 
					Event.Columns.UrlFragment,
					Event.Columns.VenueK,
					Event.Columns.DateTime);
				EventSet es = new EventSet(q);
				foreach (Event e in es)
				{
					try
					{
						Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Event, e.K, true);
						job.ExecuteAsynchronously();
					}
					catch(Exception ex)
					{
						if (Vars.DevEnv)
							throw ex;
					}
				}
			}

			Update uThreads = new Update();
			uThreads.Table=TablesEnum.Thread;
			uThreads.Changes.Add(new Assign(Thread.Columns.UrlFragment,UrlFilterPart));
			uThreads.Where=new And(
				new Q(Thread.Columns.ParentObjectType,Model.Entities.ObjectType.Venue),
				new Q(Thread.Columns.ParentObjectK,this.K));
			uThreads.Run();

			Update uArticles = new Update();
			uArticles.Table=TablesEnum.Article;
			uArticles.Changes.Add(new Assign(Article.Columns.UrlFragment,UrlFilterPart));
			uArticles.Where=new And(
				new Q(Article.Columns.ParentObjectType,Model.Entities.ObjectType.Venue),
				new Q(Article.Columns.ParentObjectK,this.K));
			uArticles.Run();

			if (Cascade)
			{
				Query q = new Query();
				q.NoLock=true;
				q.QueryCondition=new And(
					new Q(Article.Columns.ParentObjectType,Model.Entities.ObjectType.Venue),
					new Q(Article.Columns.ParentObjectK,this.K));
				q.Columns=new ColumnSet(
					Article.Columns.K,
					Article.Columns.UrlFragment,
					Article.Columns.ParentObjectK,
					Article.Columns.ParentObjectType);
				ArticleSet aSet = new ArticleSet(q);
				foreach (Article a in aSet)
				{
					try
					{
						Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Article, a.K, true);
						job.ExecuteAsynchronously();
					}
					catch(Exception ex)
					{
						if (Vars.DevEnv)
							throw ex;
					}
				}
			}
		}
Beispiel #5
0
		public void ChangePlace(int NewPlaceK, bool UpdateChildUrlFragments)
		{
			if (this.PlaceK!=NewPlaceK)
			{
				Place OldPlace = this.Place;
				Place NewPlace = new Place(NewPlaceK);
				
				Update uThreads = new Update();
				uThreads.Table = TablesEnum.Thread;
				uThreads.Where = new Q(Thread.Columns.VenueK,this.K);
				uThreads.Changes.Add(new Assign(Thread.Columns.PlaceK,NewPlace.K));
				uThreads.Changes.Add(new Assign(Thread.Columns.CountryK,NewPlace.CountryK));
				uThreads.Run();

				Update uArticle = new Update();
				uArticle.Table = TablesEnum.Article;
				uArticle.Where = new Q(Article.Columns.VenueK,this.K);
				uArticle.Changes.Add(new Assign(Article.Columns.PlaceK,NewPlace.K));
				uArticle.Changes.Add(new Assign(Article.Columns.CountryK, NewPlace.CountryK));
				uArticle.Run();

				this.PlaceK = NewPlace.K;
				this.Update();

				OldPlace.UpdateTotalComments(null);
				OldPlace.UpdateTotalEvents(null);
				this.Place=null;
				this.UpdateTotalComments(null);
				
				Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Venue, this.K, UpdateChildUrlFragments);
				job.ExecuteAsynchronously();

				this.Place.UpdateTotalEvents(null);
			}
		}
Beispiel #6
0
		public void UpdateUrlFragment(bool UpdateChildUrlFragments)
		{
			if (!this.UrlFragment.Equals(this.Place.UrlFilterPart))
			{
				this.UrlFragment = this.Place.UrlFilterPart;
				this.Update();
				if (UpdateChildUrlFragments)
				{
					Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Venue, this.K, true);
					job.ExecuteAsynchronously();
				}
			}
		}
Beispiel #7
0
		public void UpdateUrlFragment(bool UpdateChildUrlFragments)
		{
			bool changed = InitUrlFragment();

			if (changed)
			{
				this.Update();
				if (UpdateChildUrlFragments)
				{
					Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Article, this.K, true);
					job.ExecuteAsynchronously();
				}
			}
		}
Beispiel #8
0
		public void UpdateChildUrlFragments(bool Cascade)
		{
			Update uPlaces = new Update();
			uPlaces.Table=TablesEnum.Place;
			uPlaces.Changes.Add(new Assign(Place.Columns.UrlFragment,UrlFilterPart));
			uPlaces.Where=new Q(Place.Columns.CountryK,this.K);
			uPlaces.Run();

			if (Cascade)
			{
				Query q = new Query();
				q.NoLock=true;
				q.QueryCondition=new And(new Q(Place.Columns.CountryK,this.K),new Q(Place.Columns.Enabled,true));
				q.Columns=new ColumnSet(
					Place.Columns.K, 
					Place.Columns.UrlFragment, 
					Place.Columns.UrlName, 
					Place.Columns.RegionAbbreviation);
				PlaceSet ps = new PlaceSet(q);
				foreach (Place p in ps)
				{
					try
					{
						Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Place, p.K, true);
						job.ExecuteAsynchronously();
					}
					catch(Exception ex)
					{
						if (Vars.DevEnv)
							throw ex;
					}
				}
			}

			Update uThreads = new Update();
			uThreads.Table=TablesEnum.Thread;
			uThreads.Changes.Add(new Assign(Thread.Columns.UrlFragment,UrlFilterPart));
			uThreads.Where=new And(
				new Q(Thread.Columns.ParentObjectType,Model.Entities.ObjectType.Country),
				new Q(Thread.Columns.ParentObjectK,this.K));
			uThreads.Run();

			Update uArticles = new Update();
			uArticles.Table=TablesEnum.Article;
			uArticles.Changes.Add(new Assign(Article.Columns.UrlFragment,UrlFilterPart));
			uArticles.Where=new And(
				new Q(Article.Columns.ParentObjectType,Model.Entities.ObjectType.Country),
				new Q(Article.Columns.ParentObjectK,this.K));
			uArticles.Run();

			if (Cascade)
			{
				Query q = new Query();
				q.NoLock=true;
				q.QueryCondition=new And(
					new Q(Article.Columns.ParentObjectType,Model.Entities.ObjectType.Country),
					new Q(Article.Columns.ParentObjectK,this.K));
				q.Columns=new ColumnSet(
					Article.Columns.K, 
					Article.Columns.UrlFragment,
					Article.Columns.ParentObjectK,
					Article.Columns.ParentObjectType);
				ArticleSet aSet = new ArticleSet(q);
				foreach (Article a in aSet)
				{
					try
					{
						Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Article, a.K, true);
						job.ExecuteAsynchronously();
					}
					catch(Exception ex)
					{
						if (Vars.DevEnv)
							throw ex;
					}
				}
			}
		}
Beispiel #9
0
		void Save(bool RedirectToPic)
		{
			if (IsEdit)
			{
				string newName = Cambro.Web.Helpers.Strip(NameTextBox.Text);
				bool changedName = !CurrentGroup.Name.Equals(newName);
				CurrentGroup.Name = newName;

				CurrentGroup.Description = Cambro.Web.Helpers.Strip(DescriptionTextBox.Text);
				CurrentGroup.PostingRules = Cambro.Web.Helpers.Strip(RulesTextBox.Text);
				CurrentGroup.LongDescriptionHtml = IntroHtml.GetHtml();

				bool newPrivateChat;
				if (GroupPagePrivate.Checked)
				{
					CurrentGroup.PrivateGroupPage = true;
					CurrentGroup.PrivateMemberList = true;
					newPrivateChat = true;
				}
				else
				{
					CurrentGroup.PrivateGroupPage = false;
					CurrentGroup.PrivateMemberList = MembersListPrivate.Checked;
					newPrivateChat = ChatForumPrivate.Checked;
				}
				bool changedPrivateChat = newPrivateChat != CurrentGroup.PrivateChat;
				CurrentGroup.PrivateChat = newPrivateChat;

				if (MembershipMember.Checked)
					CurrentGroup.Restriction = Group.RestrictionEnum.Member;
				else if (MembershipModerator.Checked)
					CurrentGroup.Restriction = Group.RestrictionEnum.Moderator;
				else
					CurrentGroup.Restriction = Group.RestrictionEnum.None;

				int newTheme;
				if (ThemesRadioButtonList.SelectedValue.Equals("18"))
					newTheme = 0;
				else
				{
					Theme t = new Theme(int.Parse(ThemesRadioButtonList.SelectedValue));
					newTheme = t.K;
				}
				bool changedTheme = newTheme != CurrentGroup.ThemeK;
				CurrentGroup.ThemeK = newTheme;


				int newCountry;
				int oldCountry = CurrentGroup.CountryK;
				if (LocationTypeCountry.Checked || LocationTypePlace.Checked)
				{
					Country c = new Country(int.Parse(LocationCountryDropDown.SelectedValue));
					if (!c.Enabled)
						throw new Exception("invalid country!");
					newCountry = c.K;
				}
				else
				{
					newCountry = 0;
				}
				bool changedCountry = CurrentGroup.CountryK != newCountry;
				CurrentGroup.CountryK = newCountry;

				int newPlace;
				int oldPlace = CurrentGroup.PlaceK;
				if (LocationTypePlace.Checked)
				{
					Place p = new Place(int.Parse(LocationPlaceDropDown.SelectedValue));
					if (!p.Enabled || p.CountryK != CurrentGroup.CountryK)
						throw new Exception("invalid place!");
					newPlace = p.K;
				}
				else
				{
					newPlace = 0;
				}
				bool changedPlace = CurrentGroup.PlaceK != newPlace;
				CurrentGroup.PlaceK = newPlace;

				int newMusicType;
				if (CurrentGroup.ThemeK == 1 || CurrentGroup.ThemeK == 2)
				{
					if (!MusicTypesRadioButtonList.SelectedValue.Equals("0"))
					{
						MusicType mt = new MusicType(int.Parse(MusicTypesRadioButtonList.SelectedValue));
						if (!(mt.ParentK == 0 || mt.ParentK == 1))
							throw new Exception("Invalid music type");
						newMusicType = mt.K;
					}
					else
					{
						newMusicType = 0;
					}
				}
				else
				{
					newMusicType = 0;
				}
				bool changedMusic = CurrentGroup.MusicTypeK != newMusicType;
				CurrentGroup.MusicTypeK = newMusicType;

				if (changedName)
					CurrentGroup.CreateUniqueUrlName(false);

				Transaction transaction = null;//new Transaction();
				try
				{
					if (changedPrivateChat)
					{
						Update update = new Update();
						update.Table = TablesEnum.Thread;
						update.Changes.Add(new Assign(Thread.Columns.PrivateGroup, CurrentGroup.PrivateChat));
						update.Where = new Q(Thread.Columns.GroupK, CurrentGroup.K);
						update.Run(transaction);
					}

					if (changedTheme)
					{
						Update update = new Update();
						update.Table = TablesEnum.Thread;
						update.Changes.Add(new Assign(Thread.Columns.ThemeK, CurrentGroup.ThemeK));
						update.Where = new Q(Thread.Columns.GroupK, CurrentGroup.K);
						update.Run(transaction);
					}

					if (changedCountry)
					{
						Update update = new Update();
						update.Table = TablesEnum.Thread;
						update.Changes.Add(new Assign(Thread.Columns.CountryK, CurrentGroup.CountryK));
						update.Where = new And(new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Group), new Q(Thread.Columns.ParentObjectK, CurrentGroup.K));
						update.Run(transaction);
					}

					if (changedPlace)
					{
						Update update = new Update();
						update.Table = TablesEnum.Thread;
						update.Changes.Add(new Assign(Thread.Columns.PlaceK, CurrentGroup.PlaceK));
						update.Where = new And(new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Group), new Q(Thread.Columns.ParentObjectK, CurrentGroup.K));
						update.Run(transaction);

						if (oldPlace > 0)
						{
							Place oldP = new Place(oldPlace);
							oldP.UpdateTotalComments(null);
						}
						if (newPlace > 0)
						{
							Place newP = new Place(newPlace);
							newP.UpdateTotalComments(null);
						}
					}

					if (changedMusic)
					{
						Update update = new Update();
						update.Table = TablesEnum.Thread;
						update.Changes.Add(new Assign(Thread.Columns.MusicTypeK, CurrentGroup.MusicTypeK));
						update.Where = new Q(Thread.Columns.GroupK, CurrentGroup.K);
						update.Run(transaction);
					}

					if (changedName)
					{
						Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Group, CurrentGroup.K, true);
						job.ExecuteAsynchronously();
					}
					CurrentGroup.Update(transaction);

					//transaction.Commit();
				}
				catch (Exception ex)
				{
					//transaction.Rollback();
					throw ex;
				}
				finally
				{
					//transaction.Close();
				}
				if (RedirectToPic)
				{
					if (ContainerPage.Url["promoterk"].IsInt)
						Response.Redirect(CurrentGroup.UrlApp("edit", "pic", "", "promoterk", ContainerPage.Url["promoterk"]));
					else
						Response.Redirect(CurrentGroup.UrlApp("edit", "pic", ""));
				}
				else
				{
					RedirectSaved();
				}


			}
			else
			{
				GroupSet gsDup = new GroupSet(new Query(new Q(Group.Columns.DuplicateGuid, (Guid)ContainerPage.ViewStatePublic["GroupDuplicateGuid"])));
				if (gsDup.Count != 0)
				{
					Response.Redirect(gsDup[0].UrlApp("edit", "pic", ""));
				}
				else
				{
					Group g = new Group();
					g.Name = Cambro.Web.Helpers.Strip(NameTextBox.Text);
					g.Description = Cambro.Web.Helpers.Strip(DescriptionTextBox.Text);

					g.LongDescriptionHtml = IntroHtml.GetHtml();
					
					g.PostingRules = Cambro.Web.Helpers.Strip(RulesTextBox.Text, true, true, false, true);
					g.DateTimeCreated = DateTime.Now;
					g.PrivateGroupPage = GroupPagePrivate.Checked;
					if (GroupPagePrivate.Checked)
					{
						g.PrivateMemberList = true;
						g.PrivateChat = true;
					}
					else
					{
						g.PrivateMemberList = MembersListPrivate.Checked;
						g.PrivateChat = ChatForumPrivate.Checked;
					}

					if (MembershipMember.Checked)
						g.Restriction = Group.RestrictionEnum.Member;
					else if (MembershipModerator.Checked)
						g.Restriction = Group.RestrictionEnum.Moderator;
					else
						g.Restriction = Group.RestrictionEnum.None;

					if (ThemesRadioButtonList.SelectedValue.Equals("18"))
						g.ThemeK = 0;
					else
					{
						Theme t = new Theme(int.Parse(ThemesRadioButtonList.SelectedValue));
						g.ThemeK = t.K;
					}

					if (LocationTypeCountry.Checked || LocationTypePlace.Checked)
					{
						Country c = new Country(int.Parse(LocationCountryDropDown.SelectedValue));
						if (!c.Enabled)
							throw new Exception("invalid country!");
						g.CountryK = c.K;
					}
					if (LocationTypePlace.Checked)
					{
						Place p = new Place(int.Parse(LocationPlaceDropDown.SelectedValue));
						if (!p.Enabled || p.CountryK != g.CountryK)
							throw new Exception("invalid place!");
						g.PlaceK = p.K;
					}

					if (g.ThemeK == 1 || g.ThemeK == 2)
					{
						if (!MusicTypesRadioButtonList.SelectedValue.Equals("0"))
						{
							MusicType mt = new MusicType(int.Parse(MusicTypesRadioButtonList.SelectedValue));
							if (!(mt.ParentK == 0 || mt.ParentK == 1))
								throw new Exception("Invalid music type");
							g.MusicTypeK = mt.K;
						}
					}

					g.CreateUniqueUrlName(false);

					g.DuplicateGuid = (Guid)ContainerPage.ViewStatePublic["GroupDuplicateGuid"];
					g.EmailOnAllThreads = false;

					g.Update();

					g.ChangeUsr(false, Usr.Current.K, true, true, true, true, Bobs.GroupUsr.StatusEnum.Member, DateTime.Now, true);

					Response.Redirect(g.UrlApp("edit", "pic", ""));
				}
			}
		}
Beispiel #10
0
		public void UpdateChildUrlFragments(bool Cascade)
		{
			Update uGalleries = new Update();
			uGalleries.Table = TablesEnum.Gallery;
			uGalleries.Changes.Add(new Assign(Gallery.Columns.UrlFragment, UrlFilterPartVenueDate));
			uGalleries.Where = new Q(Gallery.Columns.EventK, this.K);
			uGalleries.Run();

			Update uPhotos = new Update();
			uPhotos.Table = TablesEnum.Photo;
			uPhotos.Changes.Add(new Assign(Photo.Columns.UrlFragment, UrlFilterPartVenueDate));
			uPhotos.Where = new Q(Photo.Columns.EventK, this.K);
			uPhotos.Run();

			Update uThreads = new Update();
			uThreads.Table = TablesEnum.Thread;
			uThreads.From = new Join(
				new TableElement(TablesEnum.Thread),
				new TableElement(TablesEnum.Photo),
				QueryJoinType.Left,
				Thread.Columns.PhotoK,
				Photo.Columns.K
			);
			uThreads.Changes.Add(new Assign(Thread.Columns.UrlFragment, UrlFilterPart));
			uThreads.Where = new Or(
				new Q(Photo.Columns.EventK, this.K),
				new And(
					new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Event),
					new Q(Thread.Columns.ParentObjectK, this.K)
				)
			);
			uThreads.Run();

			Update uArticles = new Update();
			uArticles.Table = TablesEnum.Article;
			uArticles.Changes.Add(new Assign(Article.Columns.UrlFragment, UrlFilterPartVenueDate));
			uArticles.Where = new And(
				new Q(Article.Columns.ParentObjectType, Model.Entities.ObjectType.Event),
				new Q(Article.Columns.ParentObjectK, this.K));
			uArticles.Run();

			if (Cascade)
			{
				Query q = new Query();
				q.NoLock = true;
				q.QueryCondition = new And(
					new Q(Article.Columns.ParentObjectType, Model.Entities.ObjectType.Event),
					new Q(Article.Columns.ParentObjectK, this.K));
				q.Columns = new ColumnSet(
					Article.Columns.K,
					Article.Columns.UrlFragment,
					Article.Columns.ParentObjectK,
					Article.Columns.ParentObjectType);
				ArticleSet aSet = new ArticleSet(q);
				foreach (Article a in aSet)
				{
					try
					{
						Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Article, a.K, true);
						job.ExecuteAsynchronously();
					}
					catch (Exception ex)
					{
						if (Vars.DevEnv)
							throw ex;
					}
				}
			}
		}
Beispiel #11
0
		void SaveEvent()
		{
			bool duplicate = false;
			//Save the event
			if (IsNew)
			{
				//Duplicate?
				EventSet esDup = new EventSet(new Query(new Q(Event.Columns.DuplicateGuid, (Guid)ContainerPage.ViewStatePublic["EventDuplicateGuid"])));
				if (esDup.Count == 0)
				{
					Event ev = Event.AddEvent(
						Cambro.Web.Helpers.StripHtml(EventName.Text).Trim(),
						CurrentVenue.K,
						StartTime,
						PanelDateCal.SelectedDate,
						Cambro.Misc.Utility.Snip(Cambro.Web.Helpers.StripHtml(EventShortDetailsHtml.Text), 500),
						EventLongDetailsHtml.GetHtml(),
						(Guid)ContainerPage.ViewStatePublic["EventDuplicateGuid"],
						EventCapacity.Text.Trim().Length > 0 ? int.Parse(EventCapacity.Text.Trim()) : null as int?,
						Usr.Current, 
						MusicTypesUc.SelectedMusicTypes.ToArray(), 
						null,
						SpotterRequestYes.Checked,
						SpotterRequestYes.Checked ? Cambro.Web.Helpers.StripHtml(SpotterRequestName.Text).Truncate(100) : "",
						SpotterRequestYes.Checked ? Cambro.Web.Helpers.StripHtml(SpotterRequestNumber.Text).Truncate(100) : ""
					);
					ViewState["InsertedEventK"] = ev.K;
				}
				else
				{
					ViewState["InsertedEventK"] = esDup[0].K;
					duplicate = true;
				}
			}
			else if (IsEdit)
			{

				if (!Usr.Current.CanEdit(CurrentEvent))
					throw new Exception("You may not edit this event!");

				bool changedDate = false;
				bool changedVenue = false;
				CurrentEvent.Name = Cambro.Web.Helpers.StripHtml(EventName.Text).Trim();
				CurrentEvent.StartTime = StartTime;
				if (CanEditDateVenue)
				{
					if (CurrentEvent.DateTime != PanelDateCal.SelectedDate)
					{
						CurrentEvent.DateTime = PanelDateCal.SelectedDate;
						changedDate = true;
					}
				}
				CurrentEvent.ShortDetailsHtml = Cambro.Misc.Utility.Snip(Cambro.Web.Helpers.StripHtml(EventShortDetailsHtml.Text), 500);

				CurrentEvent.LongDetailsHtml = EventLongDetailsHtml.GetHtml();

				CurrentEvent.SpotterRequest = SpotterRequestYes.Checked;
				if (SpotterRequestYes.Checked)
				{
					CurrentEvent.SpotterRequestName = Cambro.Web.Helpers.StripHtml(SpotterRequestName.Text).Truncate(100);
					CurrentEvent.SpotterRequestNumber = Cambro.Web.Helpers.StripHtml(SpotterRequestNumber.Text).Truncate(100);
				}
				else
				{
					CurrentEvent.SpotterRequestName = "";
					CurrentEvent.SpotterRequestNumber = "";
				}

				if (EventCapacity.Text.Length > 0)
					CurrentEvent.Capacity = int.Parse(EventCapacity.Text);

				if (CurrentEvent.AdminNote.Length > 0)
					CurrentEvent.AdminNote += "\n";
				CurrentEvent.AdminNote += "Event modified by " + Usr.Current.NickName + " (K=" + Usr.Current.K.ToString() + ") " + DateTime.Now.ToString();

				if (Usr.Current.IsSuper)
				{
					CurrentEvent.IsNew = false;
					CurrentEvent.IsEdited = false;
				}
				else
				{
					CurrentEvent.IsEdited = true;
					CurrentEvent.ModeratorUsrK = Usr.GetEventModeratorUsrK();
				}

				CurrentEvent.Update();

				if (CanEditDateVenue)
				{
					Venue v = this.PanelDetailsVenuePicker.Venue;
					if (v!= null && CurrentEvent.VenueK != v.K)
					{
						changedVenue = true;
						CurrentEvent.ChangeVenue(v.K, false);
					}
				}

				if (changedDate || changedVenue)
				{
					CurrentEvent.UpdateUrlFragment(false);
					Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Event, CurrentEvent.K, true);
					job.ExecuteAsynchronously();
				}

				foreach (int ob in MusicTypesUc.SelectedMusicTypes)
				{
					MusicType mt = new MusicType(ob);
					try
					{
						EventMusicType emt = new EventMusicType(CurrentEvent.K, mt.K);
					}
					catch
					{
						EventMusicType emt = new EventMusicType();
						emt.EventK = CurrentEvent.K;
						emt.MusicTypeK = mt.K;
						emt.Update();
					}
				}
				CurrentEvent.MusicTypes = null;
				foreach (EventMusicType emt in CurrentEvent.EventMusicTypes)
				{
					if (!MusicTypesUc.SelectedMusicTypes.Contains(emt.MusicTypeK))
					{
						emt.Delete();
						emt.Update();
					}
				}

				CurrentEvent.UpdateMusicTypesString(null);
			}
			if (IsNew || IsEdit)
			{
				if (!duplicate)
				{
					//Update brands...
					ArrayList selectedBrands = new ArrayList();
					ArrayList eventBrands = new ArrayList();
					ArrayList allBrandKs = new ArrayList();
					ArrayList allBrands = new ArrayList();

					foreach (var kvp in uiBrandsMultiSelector.Selections)
					{
						try
						{
							Brand b = new Brand(int.Parse(kvp.Value));
							selectedBrands.Add(b.K);
							if (!allBrandKs.Contains(b.K))
							{
								allBrandKs.Add(b.K);
								allBrands.Add(b);
							}
						}
						catch
						{ }
					}
					foreach (Brand b in CurrentEvent.Brands)
					{
						eventBrands.Add(b.K);
						if (!selectedBrands.Contains(b.K))
							CurrentEvent.AssignBrand(b.K, false, null);
					}
					foreach (int i in selectedBrands)
					{
						if (!eventBrands.Contains(i))
							CurrentEvent.AssignBrand(i, true, null);

					}
					foreach (Brand b in allBrands)
					{
						b.UpdateTotalComments(null);
					}


				}
			}

		}
Beispiel #12
0
		public void CreateUniqueUrlName()
		{
			string urlName = UrlInfo.GetUrlName(this.Name);
			if (urlName.Length==0)
				urlName = "promoter-"+this.K.ToString();
			if (UrlInfo.IsReservedString(urlName))
				urlName = "promoter-"+urlName;

			PromoterSet ps = null;
			int namePost = 0;
			string newName = urlName;
			while (ps==null || ps.Count>0)
			{
				if (namePost>0)
					newName = urlName+"-"+namePost.ToString();
				Query q = new Query();
				q.NoLock=true;
				q.ReturnCountOnly=true;
				q.QueryCondition=new And(
					new Q(Promoter.Columns.UrlName,newName),
					new Q(Promoter.Columns.K,QueryOperator.NotEqualTo,this.K)
				);
				ps = new PromoterSet(q);
				namePost++;
			}
			
			this.UrlName = newName;
			this.Update();

			Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Promoter, this.K, true);
			job.ExecuteAsynchronously();
		}
Beispiel #13
0
		public void UpdateUrlFragment()
		{
			if (!this.UrlFragment.Equals(this.Country.UrlName))
			{
				this.UrlFragment = this.Country.UrlName;
				this.Update();

				Utilities.UpdateChildUrlFragmentsJob job = new Utilities.UpdateChildUrlFragmentsJob(Model.Entities.ObjectType.Place, this.K, true);
				job.ExecuteAsynchronously();
			}
		}