public void SortIsPromoter(object o, System.EventArgs e) { Cambro.Web.Helpers.WriteAlertHeader(); Cambro.Web.Helpers.WriteAlert("Selecting PromoterUsrs...", 1); Query q = new Query(); q.QueryCondition = new Q(Promoter.Columns.Status, Promoter.StatusEnum.Active); q.TableElement = new Join( new Join(Usr.Columns.K, PromoterUsr.Columns.UsrK), Promoter.Columns.K, PromoterUsr.Columns.PromoterK); UsrSet bs = new UsrSet(q); Group g = new Group(3684); //DontStayIn Promoters group try { for (int count = 0; count < bs.Count; count++) { Usr u = bs[count]; try { GroupUsr gu = u.GetGroupUsr(g.K); if (gu == null || !(gu.Status.Equals(GroupUsr.StatusEnum.Exited) || gu.Status.Equals(GroupUsr.StatusEnum.Barred))) { GroupUsr gu1 = g.ChangeUsr(false, u.K, false, false, false, false, Bobs.GroupUsr.StatusEnum.Member, u.DateTimeSignUp, false); gu1.Favourite = true; gu1.Update(); CommentAlert.Enable(u, g.K, Model.Entities.ObjectType.Group); } if (count % 10 == 0) Cambro.Web.Helpers.WriteAlert("Done " + count + "/" + bs.Count + " - " + u.NickName, 2); } catch (Exception ex) { Cambro.Web.Helpers.WriteAlert("Exception " + count + "/" + bs.Count + " - " + ex.ToString(), 3); } bs.Kill(count); } } finally { g.UpdateTotalMembers(); } Cambro.Web.Helpers.WriteAlert("Done!", 4); Cambro.Web.Helpers.WriteAlertFooter(); Response.End(); }
public void UpdateIsPromoter() { Query q = new Query(); q.QueryCondition = new Q(PromoterUsr.Columns.UsrK, this.K); q.TopRecords = 1; PromoterUsrSet pus = new PromoterUsrSet(q); if (this.IsPromoter != (pus.Count > 0)) { this.IsPromoter = (pus.Count > 0); this.Update(); } Query qActive = new Query(); qActive.QueryCondition = new And( new Q(PromoterUsr.Columns.UsrK, this.K), new Q(Promoter.Columns.Status, Promoter.StatusEnum.Active) ); qActive.TopRecords = 1; qActive.TableElement = new Join(PromoterUsr.Columns.PromoterK, Promoter.Columns.K); PromoterUsrSet pusActive = new PromoterUsrSet(qActive); bool isActivePromoter = pusActive.Count > 0; Group g = new Group(3684); //DontStayIn Promoters group GroupUsr gu = this.GetGroupUsr(g.K); if (isActivePromoter) this.AddToPromotersGroup(gu, g); else if (!isActivePromoter && gu != null) g.ChangeUsr(true, this.K, false, false, false, false, GroupUsr.StatusEnum.Member, DateTime.Now, true); }
public void AddToPromotersGroup(GroupUsr gu, Group g) { if (gu == null || !(gu.Status.Equals(GroupUsr.StatusEnum.Member) || gu.Status.Equals(GroupUsr.StatusEnum.Exited) || gu.Status.Equals(GroupUsr.StatusEnum.Barred))) { GroupUsr gu1 = g.ChangeUsr(false, this.K, false, false, false, false, Bobs.GroupUsr.StatusEnum.Member, DateTime.Now, false); gu1.Favourite = true; gu1.Update(); CommentAlert.Enable(this, g.K, Model.Entities.ObjectType.Group); Mailer m = new Mailer(); m.UsrRecipient = this; m.Subject = "We've added you to the private promoters group"; m.RedirectUrl = g.Url(); m.Body = @" <p> Congratulations on activating your promoter account. We've now given you access to the private promoter group, where you can chat with event organisers from all around the world. </p> <p> What we are trying to do with this forum is allow people a space to ask questions, seek advice and share knowledge about promoting events across the world. </p> <p> <b>Please do:</b> </p> <p> * Ask questions <br> * Give answers <br> </p> <p> <b>Please do not: </b> </p> <p> * Spam this forum with promotional messages <br> * Post about your upcoming events, <b>this includes 'industry invites'</b> </p> <p> If you break these rules you will be removed from the group without warning. </p> "; m.Send(); } }
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", "")); } } }