void uiSaveButton_Click(object sender, EventArgs e) { if (!uiPlacesChooser.SelectedPlaceKs.Any()) { throw new Exception("You cannot visit nowhere. This should not have been an available option from the site"); } using (var transaction = new Transaction()) { Delete delete = new Delete(TablesEnum.UsrPlaceVisit, new Q(UsrPlaceVisit.Columns.UsrK, Usr.Current.K)); delete.Run(transaction); foreach (var item in this.uiPlacesChooser.SelectedPlaceKs) { UsrPlaceVisit utv = new UsrPlaceVisit(); utv.UsrK = Usr.Current.K; utv.PlaceK = item; utv.Update(transaction); } transaction.Commit(); Usr.Current.UpdatePlacesVisitCount(true); } this.uiSaveButton.Attributes["disabled"] = "true"; }
public void DeleteAll(Transaction transaction) { if (!this.Bob.DbRecordExists) return; //EventBrands Delete BrandDelete = new Delete( TablesEnum.EventBrand, new Q(EventBrand.Columns.BrandK, this.K) ); BrandDelete.Run(transaction); CompSet cs = new CompSet(new Query(new Q(Comp.Columns.BrandK, this.K))); foreach (Comp c in cs) { c.BrandK = 0; c.LinkType = Comp.LinkTypes.None; c.Update(); } try { this.Group.DeleteAll(transaction); } catch { } Guid oldPic = this.HasPic ? this.Pic : Guid.Empty; int oldPicMiscK = this.PicMisc != null ? this.PicMiscK : 0; this.Delete(transaction); if (oldPic != Guid.Empty) Storage.RemoveFromStore(Storage.Stores.Pix, oldPic, "jpg"); if (oldPicMiscK > 0) { Misc m = new Misc(oldPicMiscK); m.DeleteAll(transaction); } }
public void DeleteAll(Transaction transaction) { if (!this.Bob.DbRecordExists) return; Query qUsrEventGuestlist = new Query(); qUsrEventGuestlist.QueryCondition = new Q(UsrEventGuestlist.Columns.UsrK, this.K); UsrEventGuestlistSet uegs = new UsrEventGuestlistSet(qUsrEventGuestlist); foreach (UsrEventGuestlist ueg in uegs) { ueg.Delete(transaction); ueg.Event.UpdateGuestlistCount(transaction); } //Promoters Query PromoterQ = new Query(); PromoterQ.TableElement = Promoter.UsrJoin; PromoterQ.QueryCondition = new Q(Usr.Columns.K, this.K); PromoterSet promoters = new PromoterSet(PromoterQ); Delete PromoterUsrDelete = new Delete( TablesEnum.PromoterUsr, new Q(PromoterUsr.Columns.UsrK, this.K) ); PromoterUsrDelete.CommandTimeout = 3600; PromoterUsrDelete.Run(transaction); foreach (Promoter p in promoters) { p.AdminUsrs = null; if (p.AdminUsrs.Count == 0) { p.DeleteAll(transaction); } else if (p.PrimaryUsrK == this.K) { p.PrimaryUsrK = p.AdminUsrs[0].K; p.Update(transaction); } } //UsrPlaceVisit Delete UsrPlaceVisitDelete = new Delete( TablesEnum.UsrPlaceVisit, new Q(UsrPlaceVisit.Columns.UsrK, this.K) ); UsrPlaceVisitDelete.CommandTimeout = 3600; UsrPlaceVisitDelete.Run(transaction); //UsrEventAttended Delete UsrEventAttendedDelete = new Delete( TablesEnum.UsrEventAttended, new Q(UsrEventAttended.Columns.UsrK, this.K) ); UsrEventAttendedDelete.CommandTimeout = 3600; UsrEventAttendedDelete.Run(transaction); //UsrPhotoFavourite Delete UsrPhotoFavouriteDelete = new Delete( TablesEnum.UsrPhotoFavourite, new Q(UsrPhotoFavourite.Columns.UsrK, this.K) ); UsrPhotoFavouriteDelete.CommandTimeout = 3600; UsrPhotoFavouriteDelete.Run(transaction); //UsrPhotoMe PhotoSet psMe = this.PhotosMe(new ColumnSet(Photo.Columns.K, Photo.Columns.EventK, Photo.Columns.FirstUsrK, Photo.Columns.UsrCount), 0); foreach (Photo p in psMe) { this.PhotoMe(p, false, transaction); } //UsrMusicTypeFavourite Delete UsrMusicTypeFavouriteDelete = new Delete( TablesEnum.UsrMusicTypeFavourite, new Q(UsrMusicTypeFavourite.Columns.UsrK, this.K) ); UsrMusicTypeFavouriteDelete.CommandTimeout = 3600; UsrMusicTypeFavouriteDelete.Run(transaction); //Buddy / Buddy reverse; BuddySet bs = new BuddySet(new Query(new Or(new Q(Buddy.Columns.UsrK, this.K), new Q(Buddy.Columns.BuddyUsrK, this.K)))); foreach (Buddy b in bs) b.DeleteAll(transaction); //ChatMessageFrom // Delete ChatMessageFromDelete = new Delete( // TablesEnum.ChatMessage, // new Q(ChatMessage.Columns.FromUsrK,this.K) // ); // ChatMessageFromDelete.Run(transaction); //ChatMessageTo // Delete ChatMessageToDelete = new Delete( // TablesEnum.ChatMessage, // new Q(ChatMessage.Columns.ToUsrK, this.K) // ); // ChatMessageToDelete.Run(transaction); //UsrDate Delete UsrDateDelete = new Delete( TablesEnum.UsrDate, new Or(new Q(UsrDate.Columns.UsrK, this.K), new Q(UsrDate.Columns.DateUsrK, this.K)) ); UsrDateDelete.CommandTimeout = 3600; UsrDateDelete.Run(transaction); //Owners - Event EventSet esOwner = new EventSet(new Query(new Q(Event.Columns.OwnerUsrK, this.K))); foreach (Event e in esOwner) { e.OwnerUsrK = 8; e.Update(transaction); } BrandSet bsOwner = new BrandSet(new Query(new Q(Brand.Columns.OwnerUsrK, this.K))); foreach (Brand b in bsOwner) { b.OwnerUsrK = 8; b.Update(transaction); } //Owners - Venue VenueSet vsOwner = new VenueSet(new Query(new Q(Venue.Columns.OwnerUsrK, this.K))); foreach (Venue v in vsOwner) { v.OwnerUsrK = 8; v.Update(transaction); } //Remove EnabledByUsrK in Photos that this usr has enabled PhotoSet pEnableds = new PhotoSet(new Query(new Q(Photo.Columns.EnabledByUsrK, this.K))); foreach (Photo p in pEnableds) { p.EnabledByUsrK = 0; p.Update(transaction); } //ThreadUsr Delete ThreadUsrDelete = new Delete( TablesEnum.ThreadUsr, new Or(new Q(ThreadUsr.Columns.UsrK, this.K), new Q(ThreadUsr.Columns.InvitingUsrK, this.K)) ); ThreadUsrDelete.CommandTimeout = 3600; ThreadUsrDelete.Run(transaction); //CommentAlert Delete CommentAlertDelete = new Delete( TablesEnum.CommentAlert, new Q(CommentAlert.Columns.UsrK, this.K) ); CommentAlertDelete.CommandTimeout = 3600; CommentAlertDelete.Run(transaction); //GroupUsr Delete GroupUsrDelete = new Delete( TablesEnum.GroupUsr, new Q(GroupUsr.Columns.UsrK, this.K) ); GroupUsrDelete.CommandTimeout = 3600; GroupUsrDelete.Run(transaction); //Threads? ThreadSet ts = new ThreadSet(new Query(new Q(Thread.Columns.UsrK, this.K))); foreach (Thread t in ts) t.DeleteAll(transaction); Bobs.Update uLastPostUsrK = new Bobs.Update(); uLastPostUsrK.Changes.Add(new Assign(Thread.Columns.LastPostUsrK, 0)); uLastPostUsrK.Table = TablesEnum.Thread; uLastPostUsrK.Where = new Q(Thread.Columns.LastPostUsrK, this.K); uLastPostUsrK.CommandTimeout = 3600; uLastPostUsrK.Run(transaction); Bobs.Update uFirstParticipantUsrK = new Bobs.Update(); uFirstParticipantUsrK.Changes.Add(new Assign(Thread.Columns.FirstParticipantUsrK, 0)); uFirstParticipantUsrK.Table = TablesEnum.Thread; uFirstParticipantUsrK.Where = new Q(Thread.Columns.FirstParticipantUsrK, this.K); uFirstParticipantUsrK.CommandTimeout = 3600; uFirstParticipantUsrK.Run(); //Comments? CommentSet cs = new CommentSet(new Query(new Q(Comment.Columns.UsrK, this.K))); foreach (Comment c in cs) c.DeleteAll(transaction); //PhotoReview ??? PhotoReviewSet prs = new PhotoReviewSet(new Query(new Q(PhotoReview.Columns.UsrK, this.K))); foreach (PhotoReview pr in prs) { pr.Delete(transaction); pr.Photo.UpdateStats(transaction); } //Galleries GallerySet gs = new GallerySet(new Query(new Q(Gallery.Columns.OwnerUsrK, this.K))); foreach (Gallery g in gs) g.DeleteAll(transaction); //Photos PhotoSet ps = new PhotoSet(new Query(new Q(Photo.Columns.UsrK, this.K))); foreach (Photo p in ps) p.DeleteAll(transaction); //Aticles ArticleSet ars = new ArticleSet(new Query(new Q(Article.Columns.OwnerUsrK, this.K))); foreach (Article a in ars) a.DeleteAll(transaction); int k = this.K; //Usr-AddedByUsrK UsrSet usrsAddedByUsr = new UsrSet(new Query(new Q(Usr.Columns.AddedByUsrK, this.K))); foreach (Usr u in usrsAddedByUsr) { u.AddedByUsrK = 0; u.Update(transaction); } Guid oldPic = this.Pic; //Usr this.Delete(transaction); if (oldPic != Guid.Empty) Storage.RemoveFromStore(Storage.Stores.Pix, oldPic, "jpg"); }
public void StripAll() { Query qUsrEventGuestlist = new Query(); qUsrEventGuestlist.QueryCondition = new Q(UsrEventGuestlist.Columns.UsrK, this.K); UsrEventGuestlistSet uegs = new UsrEventGuestlistSet(qUsrEventGuestlist); foreach (UsrEventGuestlist ueg in uegs) { ueg.Delete(); ueg.Update(); ueg.Event.UpdateGuestlistCount(); } //UsrPlaceVisit Delete UsrPlaceVisitDelete = new Delete( TablesEnum.UsrPlaceVisit, new Q(UsrPlaceVisit.Columns.UsrK, this.K) ); UsrPlaceVisitDelete.Run(); //UsrEventAttended Delete UsrEventAttendedDelete = new Delete( TablesEnum.UsrEventAttended, new Q(UsrEventAttended.Columns.UsrK, this.K) ); UsrEventAttendedDelete.Run(); //UsrPhotoFavourite Delete UsrPhotoFavouriteDelete = new Delete( TablesEnum.UsrPhotoFavourite, new Q(UsrPhotoFavourite.Columns.UsrK, this.K) ); UsrPhotoFavouriteDelete.Run(); //UsrPhotoMe Delete UsrPhotoMeDelete = new Delete( TablesEnum.UsrPhotoMe, new Q(UsrPhotoMe.Columns.UsrK, this.K) ); UsrPhotoMeDelete.Run(); //UsrMusicTypeFavourite Delete UsrMusicTypeFavouriteDelete = new Delete( TablesEnum.UsrMusicTypeFavourite, new Q(UsrMusicTypeFavourite.Columns.UsrK, this.K) ); UsrMusicTypeFavouriteDelete.Run(); //Buddy / Buddy reverse; BuddySet bs = new BuddySet(new Query(new Or(new Q(Buddy.Columns.UsrK, this.K), new Q(Buddy.Columns.BuddyUsrK, this.K)))); foreach (Buddy b in bs) b.DeleteAll(null); //UsrDate Delete UsrDateDelete = new Delete( TablesEnum.UsrDate, new Or(new Q(UsrDate.Columns.UsrK, this.K), new Q(UsrDate.Columns.DateUsrK, this.K)) ); UsrDateDelete.Run(); //Owners - Event EventSet esOwner = new EventSet(new Query(new Q(Event.Columns.OwnerUsrK, this.K))); foreach (Event e in esOwner) { e.DeleteAllUsr(Usr.Current); //e.OwnerUsrK=4; //e.Update(); } BrandSet bsOwner = new BrandSet(new Query(new Q(Brand.Columns.OwnerUsrK, this.K))); foreach (Brand b in bsOwner) { b.DeleteAll(null); //b.OwnerUsrK=4; //b.Update(); } //Owners - Venue VenueSet vsOwner = new VenueSet(new Query(new Q(Venue.Columns.OwnerUsrK, this.K))); foreach (Venue v in vsOwner) { v.DeleteAllUsr(Usr.Current); //v.OwnerUsrK=4; //v.Update(); } //PhotoReview ??? PhotoReviewSet prs = new PhotoReviewSet(new Query(new Q(PhotoReview.Columns.UsrK, this.K))); foreach (PhotoReview pr in prs) { pr.Delete(); pr.Update(); pr.Photo.UpdateStats(null); } //Galleries GallerySet gs = new GallerySet(new Query(new Q(Gallery.Columns.OwnerUsrK, this.K))); foreach (Gallery g in gs) g.DeleteAll(null); //Photos PhotoSet ps = new PhotoSet(new Query(new Q(Photo.Columns.UsrK, this.K))); foreach (Photo p in ps) p.DeleteAll(null); //Aticles ArticleSet ars = new ArticleSet(new Query(new Q(Article.Columns.OwnerUsrK, this.K))); foreach (Article a in ars) a.DeleteAll(null); Guid oldPic = Pic; this.PicPhotoK = 0; this.PicState = ""; this.Pic = Guid.Empty; this.PicOriginal = Guid.Empty; //this.NickName=Usr.GetCompliantNickName("user-"+this.K.ToString()); this.PersonalStatement = ""; this.IsSingle = false; this.EnhancedSecurity = true; this.IsSpotter = false; Random r = new Random(); this.LoginString = Cambro.Misc.Utility.GenRandomText(6, r); this.SetPassword(Cambro.Misc.Utility.GenRandomText(10, r), false); int k = this.K; //Usr this.Update(); if (oldPic != Guid.Empty) Storage.RemoveFromStore(Storage.Stores.Pix, oldPic, "jpg"); }
public void DeleteAll(Transaction transaction) { if (!this.Bob.DbRecordExists) return; this.ContentDisabled = false; this.Update(transaction); try { UsrSet usPhotoPic = new UsrSet(new Query(new Q(Usr.Columns.PicPhotoK, this.K))); foreach (Usr u in usPhotoPic) { try { Guid picToDelete = u.Pic; u.Pic = Guid.Empty; u.PicPhotoK = 0; u.PicState = ""; u.Update(transaction); Storage.RemoveFromStore(Storage.Stores.Pix, picToDelete, "jpg"); } catch { } } } catch { } try { if (this.Gallery.MainPhotoK == this.K) { Query q = new Query(); q.QueryCondition = new And( new Q(Photo.Columns.GalleryK, this.GalleryK), Photo.EnabledQueryCondition ); q.OrderBy = new OrderBy(Photo.Columns.DateTime); q.Columns = new ColumnSet(Photo.Columns.K, Photo.Columns.Status); PhotoSet psMain = new PhotoSet(q); int firstDisabled = 0; foreach (Photo p in psMain) { if (p.K != this.K) { if (p.Status == StatusEnum.Enabled) { this.Gallery.MainPhotoK = p.K; break; } else if (firstDisabled == 0) firstDisabled = p.K; } } if (firstDisabled > 0) this.Gallery.MainPhotoK = firstDisabled; this.Gallery.Update(transaction); //PhotoSet psMain = new PhotoSet( // new Query( // new And( // new Q(Photo.Columns.K, QueryOperator.NotEqualTo, this.K), // new Q(Photo.Columns.GalleryK, this.GalleryK), // Photo.EnabledQueryCondition), // new OrderBy(Photo.Columns.DateTime), // 1 // ) // ); //if (psMain.Count > 0) //{ // this.Gallery.MainPhotoK = psMain[0].K; //} //else //{ // PhotoSet psMain1 = new PhotoSet( // new Query( // new And( // new Q(Photo.Columns.K, QueryOperator.NotEqualTo, this.K), // new Q(Photo.Columns.GalleryK, this.GalleryK) // ), // new OrderBy(Photo.Columns.DateTime), // 1 // ) // ); // if (psMain1.Count > 0) // { // this.Gallery.MainPhotoK = psMain1[0].K; // } // else // { // this.Gallery.MainPhotoK = 0; // } //} //this.Gallery.Update(transaction); } } catch { } try { Delete UsrPhotoFavouriteDelete = new Delete( TablesEnum.UsrPhotoFavourite, new Q(UsrPhotoFavourite.Columns.PhotoK, this.K) ); UsrPhotoFavouriteDelete.Run(transaction); } catch { } try { Delete UsrPhotoMeDelete = new Delete( TablesEnum.UsrPhotoMe, new Q(UsrPhotoMe.Columns.PhotoK, this.K) ); UsrPhotoMeDelete.Run(transaction); } catch { } try { Delete CommentAlertDelete = new Delete( TablesEnum.CommentAlert, new And( new Q(CommentAlert.Columns.ParentObjectK, this.K), new Q(CommentAlert.Columns.ParentObjectType, Model.Entities.ObjectType.Photo) ) ); CommentAlertDelete.Run(transaction); } catch { } try { if (this.ThreadK.HasValue && this.ThreadK.Value > 0) this.Thread.DeleteAll(transaction); } catch { } try { ThreadSet ts = new ThreadSet(new Query(new Q(Thread.Columns.PhotoK, this.K))); foreach (Thread t in ts) { t.DeleteAll(transaction); } } catch { } try { Delete PhotoReviewDelete = new Delete( TablesEnum.PhotoReview, new Q(PhotoReview.Columns.PhotoK, this.K) ); PhotoReviewDelete.Run(transaction); } catch { } try { ParaSet ps = new ParaSet(new Query(new Q(Para.Columns.PhotoK, this.K))); foreach (Para p in ps) { if (p.Type.Equals(Para.TypeEnum.Photo)) p.DeleteAll(transaction); else { Guid oldPic = p.Pic; p.Pic = Guid.Empty; p.PhotoK = 0; p.Update(transaction); if (oldPic != Guid.Empty) Storage.RemoveFromStore(Storage.Stores.Pix, oldPic, "jpg"); } } } catch { } try { foreach (var tagPhoto in this.ChildTagPhotos()) { foreach (var tagPhotoHistory in tagPhoto.ChildTagPhotoHistorys()) { tagPhotoHistory.Delete(transaction); } tagPhoto.Delete(transaction); } } catch { } Guid uploadTemporary = this.UploadTemporary; string uploadTemporaryExtention = this.UploadTemporaryExtention; Guid master = this.Master; Guid web = this.Web; Guid thumb = this.Thumb; Guid icon = this.Icon; bool isVideo = this.MediaType == MediaTypes.Video; Guid videoMaster = this.VideoMaster; string videoFileExtention = this.VideoFileExtention; Guid videoMed = this.VideoMed; bool hasCrop = this.HasCrop; Guid crop = this.HasCrop ? this.Crop : Guid.Empty; try { this.Delete(transaction); } catch { } try { Storage.RemoveFromStore(Storage.Stores.Temporary, uploadTemporary, uploadTemporaryExtention); Storage.RemoveFromStore(Storage.Stores.Master, master, "jpg"); Storage.RemoveFromStore(Storage.Stores.Pix, web, "jpg"); Storage.RemoveFromStore(Storage.Stores.Pix, thumb, "jpg"); Storage.RemoveFromStore(Storage.Stores.Pix, icon, "jpg"); if (isVideo) { Storage.RemoveFromStore(Storage.Stores.Master, videoMaster, videoFileExtention); Storage.RemoveFromStore(Storage.Stores.Pix, videoMed, "flv"); } if (hasCrop) Storage.RemoveFromStore(Storage.Stores.Pix, crop, "jpg"); } catch { } try { this.Usr.UpdateTotalPhotos(transaction); } catch { } try { this.Gallery.UpdateStats(transaction, true); } catch { } try { this.Gallery.UpdatePhotoOrder(transaction); } catch { } try { if (this.Event != null) this.Event.UpdateTotalPhotos(transaction); } catch { } }
public void DeleteAll(Transaction transaction) { if (!this.Bob.DbRecordExists) return; //Events EventSet es = new EventSet(new Query(new Q(Event.Columns.VenueK,this.K))); foreach(Event e in es) e.DeleteAll(transaction); Delete CommentAlertDelete = new Delete( TablesEnum.CommentAlert, new And( new Q(CommentAlert.Columns.ParentObjectK,this.K), new Q(CommentAlert.Columns.ParentObjectType,Model.Entities.ObjectType.Venue) ) ); CommentAlertDelete.Run(transaction); //Threads ThreadSet ts = new ThreadSet( new Query( new And( new Q(Thread.Columns.ParentObjectType,Model.Entities.ObjectType.Venue), new Q(Thread.Columns.ParentObjectK,this.K) ) ) ); foreach (Thread t in ts) t.DeleteAll(transaction); //Articles ArticleSet ars = new ArticleSet(new Query(new Q(Article.Columns.VenueK, this.K))); foreach (Article a in ars) a.DeleteAll(transaction); Guid oldPic = this.HasPic ? this.Pic : Guid.Empty; int oldPicMiscK = this.PicMisc != null ? this.PicMiscK : 0; this.Delete(transaction); if (oldPic != Guid.Empty) Storage.RemoveFromStore(Storage.Stores.Pix, oldPic, "jpg"); if (oldPicMiscK > 0) { Misc m = new Misc(oldPicMiscK); m.DeleteAll(transaction); } this.Place.UpdateTotalEvents(transaction); }
public void DeleteAll(Transaction transaction) { if (!this.Bob.DbRecordExists) return; //delete Comments Delete CommentDelete = new Delete( TablesEnum.Comment, new Q(Comment.Columns.ThreadK, this.K) ); CommentDelete.Run(transaction); //delete ThreadUsrs Delete ThreadUsrDelete = new Delete( TablesEnum.ThreadUsr, new Q(ThreadUsr.Columns.ThreadK, this.K) ); ThreadUsrDelete.Run(transaction); //delete CommentAlerts Delete CommentAlertDelete = new Delete( TablesEnum.CommentAlert, new And( new Q(CommentAlert.Columns.ParentObjectK, this.K), new Q(CommentAlert.Columns.ParentObjectType, Model.Entities.ObjectType.Thread) ) ); CommentAlertDelete.Run(transaction); this.Delete(transaction); IHasPrimaryThread parentHasPrimaryThread = this.Parent as IHasPrimaryThread; if (parentHasPrimaryThread != null) parentHasPrimaryThread.UpdateSingleThread(); if (this.Parent != null) this.Parent.UpdateTotalComments(transaction); }
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); }
public void DeleteAll(Transaction transaction) { if (!this.Bob.DbRecordExists) return; // TicketRuns and Tickets this.ticketRuns = null; if (this.TicketRuns != null && this.TicketRuns.Count > 0) { foreach (TicketRun tr in this.TicketRuns) { if (tr.Status != TicketRun.TicketRunStatus.Ended) throw new DsiUserFriendlyException("Cannot delete an event that has ticket runs that have not ended."); if (tr.SoldTickets > 0 || tr.Tickets.Count > 0) throw new DsiUserFriendlyException("Cannot delete an event that has ticket runs that have sold tickets."); } Delete TicketRunDelete = new Delete(TablesEnum.TicketRun, new Q(TicketRun.Columns.EventK, this.K)); TicketRunDelete.Run(transaction); } //EventBrands Delete BrandDelete = new Delete( TablesEnum.EventBrand, new Q(EventBrand.Columns.EventK, this.K) ); BrandDelete.Run(transaction); //UsrEventAttended Delete UsrEventAttendedDelete = new Delete( TablesEnum.UsrEventAttended, new Q(UsrEventAttended.Columns.EventK, this.K) ); UsrEventAttendedDelete.Run(transaction); //Galleries foreach (Gallery g in this.AllGalleries) g.DeleteAll(transaction); //Threads ThreadSet ts = new ThreadSet(new Query(new And(new Q(Thread.Columns.ParentObjectType, Model.Entities.ObjectType.Event), new Q(Thread.Columns.ParentObjectK, this.K)))); foreach (Thread t in ts) t.DeleteAll(transaction); //EventMusicType Delete EventMusicTypeDelete = new Delete( TablesEnum.EventMusicType, new Q(EventMusicType.Columns.EventK, this.K) ); EventMusicTypeDelete.Run(transaction); //delete CommentAlerts Delete CommentAlertDelete = new Delete( TablesEnum.CommentAlert, new And( new Q(CommentAlert.Columns.ParentObjectK, this.K), new Q(CommentAlert.Columns.ParentObjectType, Model.Entities.ObjectType.Event) ) ); CommentAlertDelete.Run(transaction); //Articles ArticleSet ars = new ArticleSet(new Query(new Q(Article.Columns.EventK, this.K))); foreach (Article a in ars) a.DeleteAll(transaction); Guid oldPic = this.HasPic ? this.Pic : Guid.Empty; int oldPicMiscK = this.PicMisc != null ? this.PicMiscK : 0; this.Delete(transaction); if (oldPic != Guid.Empty) Storage.RemoveFromStore(Storage.Stores.Pix, oldPic, "jpg"); if (oldPicMiscK > 0) { Misc m = new Misc(oldPicMiscK); m.DeleteAll(transaction); } this.Venue.UpdateTotalEvents(transaction); this.Owner.UpdateEventCount(transaction); }
public void DeleteAll(Transaction transaction) { if (!this.Bob.DbRecordExists) return; Delete PromoterUsrDelete = new Delete( TablesEnum.PromoterUsr, new Q(PromoterUsr.Columns.PromoterK, this.K) ); PromoterUsrDelete.Run(transaction); foreach (Brand b in this.AllBrands) { b.PromoterK = 0; b.PromoterStatus = Brand.PromoterStatusEnum.Unconfirmed; b.Update(transaction); } foreach (Venue v in this.AllVenues) { v.PromoterK = 0; v.PromoterStatus = Venue.PromoterStatusEnum.Unconfirmed; v.Update(transaction); } }
public bool SavePlaceTargetting(IList<int> placeKs) { this.places = null; Delete delete = new Delete(TablesEnum.BannerPlace, new Q(BannerPlace.Columns.BannerK, this.K)); delete.Run(); bool done = false; foreach (int k in placeKs) { if (k > 0) { BannerPlace b = new BannerPlace() { BannerK = this.K, PlaceK = k }; b.Update(); done = true; } } return done; }
public bool SaveMusicTargetting(IList<int> musicTypeKs) { this.musicTypesChosen = null; this.musicTypesAll = null; Delete delete = new Delete(TablesEnum.BannerMusicType, new Q(BannerMusicType.Columns.BannerK, this.K)); delete.Run(); if (musicTypeKs.Count == 0 || musicTypeKs.Contains(1)) { return false; } List<int> done = new List<int>(musicTypeKs.Count); foreach (int mtK in musicTypeKs) { MusicType mt = new MusicType(mtK); if (!done.Contains(mt.K)) { BannerMusicType newBmt = new BannerMusicType() { BannerK = this.K, MusicTypeK = mt.K, Chosen = true }; newBmt.Update(); done.Add(mt.K); } if (mt.ParentK > 1 && !done.Contains(mt.ParentK)) { BannerMusicType newParentBmt = new BannerMusicType() { BannerK = this.K, MusicTypeK = mt.ParentK, Chosen = false }; newParentBmt.Update(); done.Add(mt.ParentK); } if (mt.ParentK == 1) { foreach (MusicType child in mt.Children) { if (!done.Contains(child.K)) { BannerMusicType newChildBmt = new BannerMusicType() { BannerK = this.K, MusicTypeK = child.K, Chosen = false }; newChildBmt.Update(); done.Add(child.K); } } } } return true; }
public void DeleteAll(Transaction transaction) { if (!this.Bob.DbRecordExists) return; try { //BannerMusicType Delete BannerMusicTypeDelete = new Delete( TablesEnum.BannerMusicType, new Q(BannerMusicType.Columns.BannerK, this.K) ); BannerMusicTypeDelete.Run(transaction); } catch { } try { //BannerPlace Delete BannerPlaceDelete = new Delete( TablesEnum.BannerPlace, new Q(BannerPlace.Columns.BannerK, this.K) ); BannerPlaceDelete.Run(transaction); } catch { } try { //BannerStat Delete BannerStatDelete = new Delete( TablesEnum.BannerStat, new Q(BannerStat.Columns.BannerK, this.K) ); BannerStatDelete.Run(transaction); } catch { } this.Delete(transaction); }
public void DeleteAll(Transaction transaction) { if (!this.Bob.DbRecordExists) return; //GroupUsrs Delete GroupUsrDelete = new Delete( TablesEnum.GroupUsr, new Q(GroupUsr.Columns.GroupK, this.K) ); GroupUsrDelete.Run(transaction); //GroupUsrs Delete GroupPhotoDelete = new Delete( TablesEnum.GroupPhoto, new Q(GroupPhoto.Columns.GroupK, this.K) ); GroupPhotoDelete.Run(transaction); //GroupEvents Delete GroupEventDelete = new Delete( TablesEnum.GroupEvent, new Q(GroupEvent.Columns.GroupK, this.K) ); GroupEventDelete.Run(transaction); ThreadSet ts = new ThreadSet(new Query(new Q(Thread.Columns.GroupK,this.K))); foreach (Thread t in ts) t.DeleteAll(transaction); Guid oldPic = this.HasPic ? this.Pic : Guid.Empty; int oldPicMiscK = this.PicMisc != null ? this.PicMiscK : 0; this.Delete(transaction); if (oldPic != Guid.Empty) Storage.RemoveFromStore(Storage.Stores.Pix, oldPic, "jpg"); if (oldPicMiscK > 0) { Misc m = new Misc(oldPicMiscK); m.DeleteAll(transaction); } }
public void DeleteAll(Transaction transaction) { if (!this.Bob.DbRecordExists) return; Delete d = new Delete(TablesEnum.CompEntry,new Q(CompEntry.Columns.CompK,this.K)); d.Run(transaction); this.Delete(transaction); }