public void ForumInfo_Load(object o, System.EventArgs e) { if (!CurrentForumCheck) return; PanelThreadDescTypeNone.Visible = ThreadParentType.Equals(Model.Entities.ObjectType.None); PanelThreadDescTypeEvent.Visible = ThreadParentType.Equals(Model.Entities.ObjectType.Event); PanelThreadDescTypeVenue.Visible = ThreadParentType.Equals(Model.Entities.ObjectType.Venue); PanelThreadDescTypePlace.Visible = ThreadParentType.Equals(Model.Entities.ObjectType.Place); PanelThreadDescTypeCountry.Visible = ThreadParentType.Equals(Model.Entities.ObjectType.Country); PanelThreadDescTypeArticle.Visible = ThreadParentType.Equals(Model.Entities.ObjectType.Article); PanelThreadDescTypeBrand.Visible = ThreadParentType.Equals(Model.Entities.ObjectType.Brand); PanelThreadDescTypeGroup.Visible = ThreadParentType.Equals(Model.Entities.ObjectType.Group); PanelThreadDescRelatedPanel.Visible = false; PanelThreadDescGroupBrandPanel.Visible = false; PanelThreadDescBrandPanel.Visible = false; FavouriteGroupPanel.Visible = (ThreadParentType.Equals(Model.Entities.ObjectType.Group) && CurrentGroupUsr != null && CurrentGroupUsr.IsMember); SetPageTitle("General discussions"); if (ThreadParentType.Equals(Model.Entities.ObjectType.None)) { ThreadDescWorldwideHomeCountryLink.InnerText = ThreadDescWorldwideHomeCountryLink.InnerText.Replace("???", Country.Current.FriendlyName); ThreadDescWorldwideHomeCountryLink.HRef = Country.Current.UrlDiscussion(); } if (ThreadParentType.Equals(Model.Entities.ObjectType.Event)) { Event ev = new Event(ObjectK); ThreadDescEventEventLink.InnerText = ev.Name; ThreadDescEventEventLink.HRef = ev.Url(); ThreadDescEventVenueLink.InnerText = ev.Venue.Name; ThreadDescEventVenueLink.HRef = ev.Venue.Url(); ThreadDescEventPlaceLink.InnerText = ev.Venue.Place.Name; ThreadDescEventPlaceLink.HRef = ev.Venue.Place.Url(); ThreadDescEventDateLabel.Text = ev.FriendlyDate(false); PanelThreadDescRelatedPanel.Visible = ev.Brands.Count > 0; string brandsHtml = ""; for (int i = 0; i < ev.Brands.Count; i++) { brandsHtml += (i == 0 ? "" : (i == (ev.Brands.Count - 1) ? " or " : ", ")) + "the <b><a href=\"" + ev.Brands[i].UrlDiscussion() + "\">" + ev.Brands[i].Name + " forum</a></b>"; } PanelThreadDescRelatedPh.Controls.Add(new LiteralControl(brandsHtml)); SetPageTitle(ev.Name + " discussions"); } if (ThreadParentType.Equals(Model.Entities.ObjectType.Venue)) { Venue v = new Venue(ObjectK); ThreadDescVenueVenueLink.InnerText = v.Name; ThreadDescVenueVenueLink.HRef = v.Url(); ThreadDescVenuePlaceLink.InnerText = v.Place.Name; ThreadDescVenuePlaceLink.HRef = v.Place.Url(); SetPageTitle(v.Name + " discussions"); } if (ThreadParentType.Equals(Model.Entities.ObjectType.Place)) { Place t = new Place(ObjectK); ThreadDescPlacePlaceLink.InnerText = t.Name; ThreadDescPlacePlaceLink.HRef = t.Url(); SetPageTitle(t.Name + " discussions"); } if (ThreadParentType.Equals(Model.Entities.ObjectType.Country)) { Country c = new Country(ObjectK); ThreadDescCountryLabel.Text = c.FriendlyName; ThreadDescCountryLink.HRef = c.Url(); SetPageTitle(c.FriendlyName + " discussions"); } if (ThreadParentType.Equals(Model.Entities.ObjectType.Article)) { Article a = new Article(ObjectK); ThreadDescArticleArticleLink.InnerText = a.Title; ThreadDescArticleArticleLink.HRef = a.Url(); SetPageTitle(a.Title + " discussions"); } if (ThreadParentType.Equals(Model.Entities.ObjectType.Brand)) { Brand b = new Brand(ObjectK); ThreadDescBrandBrandLink.InnerText = b.Name; ThreadDescBrandBrandLink.HRef = b.Url(); SetPageTitle(b.Name + " discussions"); if (b.Group.TotalComments > 0) { PanelThreadDescBrandPanel.Visible = true; PanelThreadDescBrandGroupChatAnchor.InnerText = b.Group.FriendlyName + " group chat"; PanelThreadDescBrandGroupChatAnchor.HRef = b.Group.UrlDiscussion(); PanelThreadDescBrandGroupChatCommentsLabel.Text = b.Group.TotalComments.ToString("#,##0") + " comment" + (b.Group.TotalComments == 1 ? "" : "s"); } } if (ThreadParentType.Equals(Model.Entities.ObjectType.Group)) { ThreadDescGroupGroupLink.InnerText = CurrentGroup.FriendlyName + " group"; ThreadDescGroupGroupLink.HRef = CurrentGroup.Url(); SetPageTitle(CurrentGroup.FriendlyName + " discussions"); if (CurrentGroup.BrandK > 0) { PanelThreadDescGroupBrandPanel.Visible = true; PanelThreadDescGroupBrandAnchor.HRef = CurrentGroup.Brand.UrlDiscussion(); PanelThreadDescGroupBrandAnchor.InnerText = CurrentGroup.Brand.Name + " public chat"; PanelThreadDescGroupBrandCommentsLabel.Text = CurrentGroup.Brand.TotalComments.ToString("#,##0") + " comment" + (CurrentGroup.Brand.TotalComments == 1 ? "" : "s"); } } }
protected void AddressPostcodeVal(object o, ServerValidateEventArgs e) { Country c = new Country(int.Parse(AddressCountry.SelectedValue)); if (c.PostcodeType == 1) { Regex r = new Regex(Cambro.Misc.RegEx.Postcode); e.IsValid = r.IsMatch(AddressPostcode.Text); } else e.IsValid = true; }
void StoreSpotter() { bool NewSpotter = !Usr.Current.IsSpotter; Country c = new Country(int.Parse(AddressCountry.SelectedValue)); #region update AdminNote when edited if (!NewSpotter) { Usr.Current.AdminNote += "\n\n******Spotter changed details on " + DateTime.Now.ToString() + " - old details: *****\n"; if (!Usr.Current.FirstName.Equals(Cambro.Web.Helpers.StripHtml(FirstName.Text)) || !Usr.Current.LastName.Equals(Cambro.Web.Helpers.StripHtml(LastName.Text))) Usr.Current.AdminNote += "Name: " + Usr.Current.FirstName + " " + Usr.Current.LastName + "\n"; if (!Usr.Current.AddressStreet.Equals(Cambro.Web.Helpers.StripHtml(AddressStreet.Text))) Usr.Current.AdminNote += "Street: " + Usr.Current.AddressStreet + "\n"; if (!Usr.Current.AddressArea.Equals(Cambro.Web.Helpers.StripHtml(AddressArea.Text))) Usr.Current.AdminNote += "Area: " + Usr.Current.AddressArea + "\n"; if (!Usr.Current.AddressTown.Equals(Cambro.Web.Helpers.StripHtml(AddressTown.Text))) Usr.Current.AdminNote += "Town: " + Usr.Current.AddressTown + "\n"; if (!Usr.Current.AddressCounty.Equals(Cambro.Web.Helpers.StripHtml(AddressCounty.Text))) Usr.Current.AdminNote += "County: " + Usr.Current.AddressCounty + "\n"; if (!Usr.Current.AddressPostcode.Equals(Cambro.Web.Helpers.StripHtml(AddressPostcode.Text))) Usr.Current.AdminNote += "Postcode: " + Usr.Current.AddressPostcode + "\n"; if (!Usr.Current.DateOfBirth.Equals(new DateTime(int.Parse(DateOfBirthYear.Text), int.Parse(DateOfBirthMonth.Text), int.Parse(DateOfBirthDay.Text)))) Usr.Current.AdminNote += "Date of birth: " + Usr.Current.DateOfBirth.ToString() + "\n"; if (Usr.Current.AddressCountryK != c.K) Usr.Current.AdminNote += "Country: " + c.K + " (" + c.Name + ")\n"; } #endregion Usr.Current.IsSpotter = true; Usr.Current.FirstName = Cambro.Web.Helpers.StripHtml(FirstName.Text); Usr.Current.LastName = Cambro.Web.Helpers.StripHtml(LastName.Text); StoreMobileNumber(); Usr.Current.AddressStreet = Cambro.Web.Helpers.StripHtml(AddressStreet.Text); Usr.Current.AddressArea = Cambro.Web.Helpers.StripHtml(AddressArea.Text); Usr.Current.AddressTown = Cambro.Web.Helpers.StripHtml(AddressTown.Text); Usr.Current.AddressCounty = Cambro.Web.Helpers.StripHtml(AddressCounty.Text); Usr.Current.AddressPostcode = Cambro.Web.Helpers.StripHtml(AddressPostcode.Text); Usr.Current.DateOfBirth = new DateTime(int.Parse(DateOfBirthYear.Text), int.Parse(DateOfBirthMonth.Text), int.Parse(DateOfBirthDay.Text)); Usr.Current.AddressCountryK = c.K; if (PhotoUsageDoNotUse.Checked) Usr.Current.PhotoUsage = Model.Entities.Usr.PhotoUsageEnum.DoNotUse; else if (PhotoUsageContact.Checked) Usr.Current.PhotoUsage = Model.Entities.Usr.PhotoUsageEnum.Contact; else Usr.Current.PhotoUsage = Model.Entities.Usr.PhotoUsageEnum.Use; if (NewSpotter) { Usr.Current.CardStatus = Usr.CardStatusEnum.New; Usr dsiUsr = new Usr(8); if (true) { Bobs.Group spottersGroup = new Bobs.Group(3480); GroupUsr guTarget = spottersGroup.GetGroupUsr(Usr.Current); GroupUsr guDsi = spottersGroup.GetGroupUsr(dsiUsr); spottersGroup.Invite(Usr.Current, guTarget, dsiUsr, guDsi, "Chat about being a Spotter and all things Spotting in the DontStayIn Spotters group!", false); } if (Usr.Current.AddressCountryK == 225) { Bobs.Group spottersGroup = new Bobs.Group(4537); GroupUsr guTarget = spottersGroup.GetGroupUsr(Usr.Current); GroupUsr guDsi = spottersGroup.GetGroupUsr(dsiUsr); spottersGroup.Invite(Usr.Current, guTarget, dsiUsr, guDsi, "Chat about being a USA based DontStayIn Spotter in the USA Spotters group!", false); } } Usr.Current.Update(); if (CurrentEvent != null) Response.Redirect(CurrentEvent.SpotterSignUpUrl); else Response.Redirect("/pages/spotters"); }
public static string SaveAddress(string uid, string sessionKey, string secret, string expires, string baseDomain, string requestCode, string email, string firstName, string lastName, string addressFirstLine, string postalCode, string country) { FacebookHttpContext.Init(HttpContext.Current, uid, sessionKey, secret, expires, baseDomain); long usr; bool emailPermission; bool publishPermission; using (var batch = Batch.Start(FacebookHttpContext.Current)) { var usrR = FacebookHttpContext.Current.Users.GetLoggedInUser(); var emailPermissionR = FacebookHttpContext.Current.Users.HasAppPermission("email"); var publishPermissionR = FacebookHttpContext.Current.Users.HasAppPermission("publish_stream"); batch.Complete(); usr = usrR.Value; emailPermission = emailPermissionR.Value; publishPermission = publishPermissionR.Value; } Query q = new Query(); q.QueryCondition = new Q(Bobs.MixmagSubscription.Columns.FacebookUID, usr); MixmagSubscriptionSet mss = new MixmagSubscriptionSet(q); if (mss.Count == 0) { return "XXX"; } else { Bobs.MixmagSubscription s = mss[0]; s.FirstName = firstName; s.LastName = lastName; s.AddressFirstLine = addressFirstLine; s.AddressPostCode = postalCode; Country c = new Country(int.Parse(country)); s.AddressCountryK = c.K; s.IsAddressComplete = true; email = email.ToLower(); if (email.Length > 0) { if (IsEmail(email)) { if (s.Email != email) { s.EmailVerificationSecret = Cambro.Misc.Utility.GenRandomChars(5).ToLower(); s.Email = email; s.IsEmailBroken = false; s.EmailBrokenDateTime = null; s.IsEmailComplete = true; s.IsEmailVerified = false; s.IsEmailFromFacebook = false; SendVerificationEmail(s, requestCode); } } else { throw new Exception("Bad email address!"); } } s.Update(); return returnString(s, emailPermission, publishPermission); } }
public void PanelSignUpFormClick(object o, System.EventArgs e) { Page.Validate(); if (Page.IsValid) { if (IsEdit) { if (!CanEdit) throw new Exception("You can't edit this promoter!"); #region Store changes to promoter in admin note string oldDetails = ""; if (!Cambro.Web.Helpers.StripHtml(Name.Text).Equals(CurrentPromoter.Name)) oldDetails += "Name: [" + CurrentPromoter.Name + "] - [" + Cambro.Web.Helpers.StripHtml(Name.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(ContactName.Text).Equals(CurrentPromoter.ContactName)) oldDetails += "ContactName: [" + CurrentPromoter.ContactName + "] - [" + Cambro.Web.Helpers.StripHtml(ContactName.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(PhoneNumber.Text).Equals(CurrentPromoter.PhoneNumber)) oldDetails += "PhoneNumber: [" + CurrentPromoter.PhoneNumber + "] - [" + Cambro.Web.Helpers.StripHtml(PhoneNumber.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(AddressStreet.Text).Equals(CurrentPromoter.AddressStreet)) oldDetails += "AddressStreet: [" + CurrentPromoter.AddressStreet + "] - [" + Cambro.Web.Helpers.StripHtml(AddressStreet.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(AddressArea.Text).Equals(CurrentPromoter.AddressArea)) oldDetails += "AddressArea: [" + CurrentPromoter.AddressArea + "] - [" + Cambro.Web.Helpers.StripHtml(AddressArea.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(AddressTown.Text).Equals(CurrentPromoter.AddressTown)) oldDetails += "AddressTown: [" + CurrentPromoter.AddressTown + "] - [" + Cambro.Web.Helpers.StripHtml(AddressTown.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(AddressCounty.Text).Equals(CurrentPromoter.AddressCounty)) oldDetails += "AddressCounty: [" + CurrentPromoter.AddressCounty + "] - [" + Cambro.Web.Helpers.StripHtml(AddressCounty.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(AddressPostcode.Text).Equals(CurrentPromoter.AddressPostcode)) oldDetails += "AddressPostcode: [" + CurrentPromoter.AddressPostcode + "] - [" + Cambro.Web.Helpers.StripHtml(AddressPostcode.Text) + "]\n"; if (!int.Parse(AddressCountry.SelectedValue).Equals(CurrentPromoter.AddressCountryK)) oldDetails += "CountryK: [" + CurrentPromoter.AddressCountryK + "] - [" + int.Parse(AddressCountry.SelectedValue).ToString() + "]\n"; if (!((Promoter.VatStatusEnum)Convert.ToInt32(VatStatusDropDownList.SelectedValue)).Equals(CurrentPromoter.VatStatus)) oldDetails += "VatStatus: [" + CurrentPromoter.VatStatus.ToString() + "] - [" + ((Promoter.VatStatusEnum)Convert.ToInt32(VatStatusDropDownList.SelectedValue)).ToString() + "]\n"; if (!Cambro.Web.Helpers.StripHtml(VatNumberTextBox.Text.Trim()).Equals(CurrentPromoter.VatNumber)) oldDetails += "VatNumber: [" + CurrentPromoter.VatNumber + "] - [" + Cambro.Web.Helpers.StripHtml(VatNumberTextBox.Text.Trim()) + "]\n"; if (!Convert.ToInt32(VatCountryDropDownList.SelectedValue).Equals(CurrentPromoter.VatCountryK)) oldDetails += "VatCountryK: [" + CurrentPromoter.VatCountryK.ToString() + "] - [" + Convert.ToInt32(VatCountryDropDownList.SelectedValue).ToString() + "]\n"; if (!Cambro.Web.Helpers.StripHtml(BankNameTextBox.Text).Equals(CurrentPromoter.BankName)) oldDetails += "BankName: [" + CurrentPromoter.BankName + "] - [" + Cambro.Web.Helpers.StripHtml(BankNameTextBox.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(BankAccountNameTextBox.Text).Equals(CurrentPromoter.BankAccountName)) oldDetails += "BankAccountName: [" + CurrentPromoter.BankAccountName + "] - [" + Cambro.Web.Helpers.StripHtml(BankAccountNameTextBox.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(BankAccountNumberTextBox.Text).Equals(CurrentPromoter.BankAccountNumber)) oldDetails += "BankAccountNumber: [" + CurrentPromoter.BankAccountNumber + "] - [" + Cambro.Web.Helpers.StripHtml(BankAccountNumberTextBox.Text) + "]\n"; if (!Cambro.Web.Helpers.StripHtml(BankAccountSortCodeTextBox.Text).Equals(CurrentPromoter.BankAccountSortCode)) oldDetails += "BankAccountSortCode: [" + CurrentPromoter.BankAccountSortCode + "] - [" + Cambro.Web.Helpers.StripHtml(BankNameTextBox.Text) + "]\n"; if (uiAgency.Checked != CurrentPromoter.IsAgency) oldDetails += "IsAgency: [" + CurrentPromoter.IsAgency.ToString() + "] - [" + uiAgency.Checked.ToString() + "]\n"; if (oldDetails.Length > 0) CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") changed these details on " + DateTime.Now.ToString() + ":\n" + oldDetails; #endregion } else { Guid DuplicateGuid = (Guid)ViewState["PromoterDuplicateGuid"]; PromoterSet ps = new PromoterSet(new Query(new Q(Promoter.Columns.DuplicateGuid, DuplicateGuid))); if (ps.Count > 0) { Response.Redirect(ps[0].UrlApp("edit")); return; } else { #region Initialise promoter record CurrentPromoter = new Promoter(); CurrentPromoter.DateTimeSignUp = DateTime.Now; CurrentPromoter.AddedByUsrK = Usr.Current.K; CurrentPromoter.HasGuestlist = true; CurrentPromoter.GuestlistCharge = 0.25m; CurrentPromoter.GuestlistCredit = 20; CurrentPromoter.GuestlistCreditLimit = 0; CurrentPromoter.Status = Promoter.StatusEnum.Enabled; CurrentPromoter.PricingMultiplier = 1.0; CurrentPromoter.TotalPaid = 0; CurrentPromoter.DuplicateGuid = (Guid)ViewState["PromoterDuplicateGuid"]; CurrentPromoter.LetterType = Promoter.LetterTypes.CurrentNewPromoter; CurrentPromoter.LetterStatus = Promoter.LetterStatusEnum.New; CurrentPromoter.IsSkeleton = false; CurrentPromoter.OfferType = Promoter.OfferTypes.None; Random r = new Random(); CurrentPromoter.AccessCodeRandom = r.Next(1000, 9999).ToString() + r.Next(1000, 9999).ToString(); CurrentPromoter.ClientSector = (Promoter.ClientSectorEnum)Convert.ToInt32(Sector.SelectedValue); CurrentPromoter.SalesCampaignK = int.Parse(SalesCampaignDropDown.SelectedValue); if (!Usr.Current.IsAdmin) { CurrentPromoter.PrimaryUsrK = Usr.Current.K; CurrentPromoter.AddedMethod = Promoter.AddedMedhods.EndUser; } else { CurrentPromoter.AddedMethod = Promoter.AddedMedhods.SalesUser; } // assign new Promoter to Usr.Current if they are on a promoter sales team or to a randomly assigned promoter sales person, as requested by Dave 7/2/07 if (Usr.Current.SalesTeam > 0) { CurrentPromoter.SalesStatus = Promoter.SalesStatusEnum.Proactive; CurrentPromoter.SalesUsrK = Usr.Current.K; } else { CurrentPromoter.SalesStatus = Promoter.SalesStatusEnum.New; // Randomly assign a sales usr List<Usr> promoterSalesUsrs; if (CurrentPromoter.ClientSector.Equals(Promoter.ClientSectorEnum.Promoter)) promoterSalesUsrs = Usr.GetNewPromoterSalesUsrsNameAndK().ToList(); else promoterSalesUsrs = new List<Usr>() { new Usr(1) }; CurrentPromoter.SalesUsrK = promoterSalesUsrs[r.Next(0, promoterSalesUsrs.Count)].K; } CurrentPromoter.SalesStatusExpires = DateTime.Today.AddMonths(3); CurrentPromoter.SalesNextCall = DateTime.Now.AddDays(3); // If first call is on a weekend, then make it Monday if(CurrentPromoter.SalesNextCall.DayOfWeek == DayOfWeek.Saturday) CurrentPromoter.SalesNextCall = DateTime.Now.AddDays(2); else if(CurrentPromoter.SalesNextCall.DayOfWeek == DayOfWeek.Sunday) CurrentPromoter.SalesNextCall = DateTime.Now.AddDays(1); #endregion } } #region Update promoter record with form contents CurrentPromoter.Name = Cambro.Web.Helpers.StripHtml(Name.Text); CurrentPromoter.ContactName = Cambro.Web.Helpers.StripHtml(ContactName.Text); CurrentPromoter.PhoneNumber = Cambro.Web.Helpers.StripHtml(PhoneNumber.Text); CurrentPromoter.AddressStreet = Cambro.Web.Helpers.StripHtml(AddressStreet.Text); CurrentPromoter.AddressArea = Cambro.Web.Helpers.StripHtml(AddressArea.Text); CurrentPromoter.AddressTown = Cambro.Web.Helpers.StripHtml(AddressTown.Text); CurrentPromoter.AddressCounty = Cambro.Web.Helpers.StripHtml(AddressCounty.Text); CurrentPromoter.AddressPostcode = Cambro.Web.Helpers.StripHtml(AddressPostcode.Text); bool updateTicketInvoices = false; // new VAT details, for Ticket System. 22/5/07 if (CurrentPromoter.VatStatus != Promoter.VatStatusEnum.Registered && CurrentPromoter.VatStatus != (Promoter.VatStatusEnum)Convert.ToInt32(VatStatusDropDownList.SelectedValue)) updateTicketInvoices = true; CurrentPromoter.VatStatus = (Promoter.VatStatusEnum)Convert.ToInt32(VatStatusDropDownList.SelectedValue); CurrentPromoter.VatCountryK = Convert.ToInt32(VatCountryDropDownList.SelectedValue); CurrentPromoter.VatNumber = Cambro.Web.Helpers.StripHtml(VatNumberTextBox.Text.Trim()); // new Admin only data entry fields, as requested by Dave 7/2/07 if (Usr.Current.IsAdmin || Usr.Current.IsSuperAdmin) { CurrentPromoter.AccountsEmail = Cambro.Web.Helpers.StripHtml(AccountsEmail.Text); CurrentPromoter.AccountsName = Cambro.Web.Helpers.StripHtml(AccountsName.Text); CurrentPromoter.AccountsPhone = Cambro.Web.Helpers.StripHtml(AccountsPhone.Text); CurrentPromoter.ContactPersonalTitle = Cambro.Web.Helpers.StripHtml(PersonalTitle.Text); CurrentPromoter.ContactTitle = Cambro.Web.Helpers.StripHtml(JobTitle.Text); CurrentPromoter.PhoneNumber2 = Cambro.Web.Helpers.StripHtml(PhoneNumber2.Text); CurrentPromoter.WebAddress = Cambro.Web.Helpers.StripHtml(WebAddress.Text); CurrentPromoter.ClientSector = (Promoter.ClientSectorEnum)Convert.ToInt32(Sector.SelectedValue); CurrentPromoter.SalesCampaignK = int.Parse(SalesCampaignDropDown.SelectedValue); CurrentPromoter.IsAgency = uiAgency.Checked; // new admin only bank details, as requested by Dave 15/6/07 CurrentPromoter.BankName = Cambro.Web.Helpers.StripHtml(BankNameTextBox.Text); CurrentPromoter.BankAccountName = Cambro.Web.Helpers.StripHtml(BankAccountNameTextBox.Text); CurrentPromoter.BankAccountNumber = Cambro.Web.Helpers.StripHtml(BankAccountNumberTextBox.Text); CurrentPromoter.BankAccountSortCode = Cambro.Web.Helpers.StripHtml(BankAccountSortCodeTextBox.Text); if (this.AccessMultiRadio.Checked && this.uiAccessUsersMultiSelector.Count > 0 && (Usr.Current.IsAdmin || Usr.Current.IsSuperAdmin)){ CurrentPromoter.PrimaryUsrK = int.Parse(uiPrimaryUserDropDown.SelectedValue); }else { CurrentPromoter.PrimaryUsrK = 0; CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") has setup this account with no primary user - " + DateTime.Now.ToString() + "\n"; } } if (!IsEdit) { if (CurrentPromoter.PrimaryUsrK > 0) CurrentPromoter.AddQuestionsThread(CurrentPromoter.PrimaryUsr, Cambro.Web.Helpers.StripHtml(Name.Text)); else CurrentPromoter.AddQuestionsThread(Usr.Current, Cambro.Web.Helpers.StripHtml(Name.Text)); } Country newCountry = new Country(int.Parse(AddressCountry.SelectedValue)); CurrentPromoter.AddressCountryK = newCountry.K; CurrentPromoter.Update(); if (updateTicketInvoices) CurrentPromoter.UpdateTicketInvoiceItemTaxCode(); CurrentPromoter.CreateUniqueUrlName(); #endregion #region Add / remove selected users if (CurrentPromoter.PrimaryUsrK == Usr.Current.K || Usr.Current.IsAdmin || Usr.Current.IsSuperAdmin) { ArrayList SelectedUsers = new ArrayList(); ArrayList CurrentUsers = new ArrayList(); if (CurrentPromoter.PrimaryUsrK > 0) { SelectedUsers.Add(CurrentPromoter.PrimaryUsrK); } if (AccessMultiRadio.Checked) { foreach (var pair in this.uiAccessUsersMultiSelector.Selections) { Usr u = new Usr(int.Parse(pair.Value)); if (!SelectedUsers.Contains(u.K)) SelectedUsers.Add(u.K); } } foreach (Usr u in CurrentPromoter.AdminUsrs) { if (!CurrentUsers.Contains(u.K)) CurrentUsers.Add(u.K); } if (SelectedUsers.Count > 0) { Usr JohnB = new Usr(1); Thread t = new Thread(CurrentPromoter.QuestionsThreadK); foreach (int usrK in SelectedUsers) { if (!CurrentUsers.Contains(usrK)) { PromoterUsr pu = new PromoterUsr(); pu.PromoterK = CurrentPromoter.K; pu.UsrK = usrK; pu.Update(); t.Invite(new List<int>(new int[] { usrK }), JohnB, DateTime.Now, new List<int>(), !IsEdit, null, false); ThreadUsr tu = new ThreadUsr(CurrentPromoter.QuestionsThreadK, usrK); tu.Favourite = true; tu.Update(); CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") added new user to admins - " + DateTime.Now.ToString() + " - " + pu.UsrK.ToString() + " (" + pu.Usr.NickName + ")\n"; CurrentPromoter.Update(); pu.Usr.UpdateIsPromoter(); } } } //if (!AccessNoAccountUsersRadio.Checked) //{ foreach (int usrK in CurrentUsers) { if (!SelectedUsers.Contains(usrK)) { PromoterUsr pu = new PromoterUsr(CurrentPromoter.K, usrK); CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") removed user from the admins - " + DateTime.Now.ToString() + " - " + pu.UsrK.ToString() + " (" + pu.Usr.NickName + ")\n"; CurrentPromoter.Update(); pu.Delete(); pu.Update(); pu.Usr.UpdateIsPromoter(); try { ThreadUsr tu = new ThreadUsr(CurrentPromoter.QuestionsThreadK, usrK); tu.Delete(); tu.Update(); UpdateTotalParticipantsJob job = new UpdateTotalParticipantsJob(tu.Thread); job.ExecuteSynchronously(); } catch { } } } //} //else //{ // foreach (int usrK in CurrentUsers) // { // PromoterUsr pu = new PromoterUsr(CurrentPromoter.K, usrK); // CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") removed user from the admins - " + DateTime.Now.ToString() + " - " + pu.UsrK.ToString() + " (" + pu.Usr.NickName + ")\n"; // CurrentPromoter.Update(); // pu.Delete(); // pu.Update(); // pu.Usr.UpdateIsPromoter(); // try // { // ThreadUsr tu = new ThreadUsr(CurrentPromoter.QuestionsThreadK, usrK); // tu.Delete(); // tu.Update(); // tu.Thread.UpdateTotalParticipants(); // } // catch { } // } //} } #endregion #region Add / remove selected brands ArrayList SelectedBrands = new ArrayList(); ArrayList CurrentBrands = new ArrayList(); if (AccountTypeRadioEvents.Checked) { foreach (var pair in this.uiBrandMultiSelector.Selections) { Brand b = new Brand(int.Parse(pair.Value)); if (!SelectedBrands.Contains(b.K)) SelectedBrands.Add(b.K); } } CurrentPromoter.AllBrands = null; foreach (Brand b in CurrentPromoter.AllBrands) { if (!CurrentBrands.Contains(b.K)) CurrentBrands.Add(b.K); } string failedBrands = ""; foreach (int brandK in SelectedBrands) { if (!CurrentBrands.Contains(brandK)) { Brand b = new Brand(brandK); bool changeStatus = false; if (b.PromoterK == 0) { CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") added brand - " + DateTime.Now.ToString() + " - " + b.K + " (" + b.Name + ") - "; b.PromoterK = CurrentPromoter.K; changeStatus = true; } else if (b.PromoterStatus.Equals(Brand.PromoterStatusEnum.Unconfirmed)) { CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") added brand - " + DateTime.Now.ToString() + " - " + b.K + " (" + b.Name + ") - removed from promoter " + b.PromoterK + " (" + b.Promoter.Name + ") - "; b.PromoterK = CurrentPromoter.K; changeStatus = true; } else //brand owned by someone else! { CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") attempted to add brand - " + DateTime.Now.ToString() + " - " + b.K + " (" + b.Name + "), but it's already confirmed to promoter " + b.PromoterK + " (" + b.Promoter.Name + ")\n"; failedBrands = (failedBrands.Length == 0 ? "" : ", ") + b.Name; } if (changeStatus) { bool foundBrandOwner = false; CurrentPromoter.AdminUsrs = null; foreach (Usr u in CurrentPromoter.AdminUsrs) { if (b.OwnerUsrK == u.K) foundBrandOwner = true; } if (foundBrandOwner || Usr.Current.IsAdmin) { b.PromoterStatus = Brand.PromoterStatusEnum.Confirmed; CurrentPromoter.AdminNote += "(status confirmed)\n"; } else { b.PromoterStatus = Brand.PromoterStatusEnum.Unconfirmed; CurrentPromoter.AdminNote += "(status new)\n"; } } b.Update(); CurrentPromoter.Update(); } } foreach (int brandK in CurrentBrands) { if (!SelectedBrands.Contains(brandK)) { Brand b = new Brand(brandK); CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") removed brand - " + DateTime.Now.ToString() + " - " + b.K + " (" + b.Name + ")"; b.PromoterStatus = Brand.PromoterStatusEnum.Unconfirmed; b.PromoterK = 0; b.Update(); CurrentPromoter.Update(); } } #endregion #region Add / remove selected venues ArrayList SelectedVenues = new ArrayList(); ArrayList CurrentVenues = new ArrayList(); if (VenuesRadioYes.Checked) { foreach (var pair in this.uiVenuesMultiSelector.Selections) { Venue v = new Venue(int.Parse(pair.Value)); if (!SelectedVenues.Contains(v.K)) SelectedVenues.Add(v.K); } } CurrentPromoter.AllVenues = null; foreach (Venue v in CurrentPromoter.AllVenues) { if (!CurrentVenues.Contains(v.K)) CurrentVenues.Add(v.K); } string failedVenues = ""; foreach (int venueK in SelectedVenues) { if (!CurrentVenues.Contains(venueK)) { Venue v = new Venue(venueK); bool changeStatus = false; if (v.PromoterK == 0) { CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") added venue - " + DateTime.Now.ToString() + " - " + v.K + " (" + v.Name + ") - "; v.PromoterK = CurrentPromoter.K; changeStatus = true; } else if (v.PromoterStatus.Equals(Venue.PromoterStatusEnum.Unconfirmed)) { CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") added venue - " + DateTime.Now.ToString() + " - " + v.K + " (" + v.Name + ") - removed from promoter " + v.PromoterK + " (" + v.Promoter.Name + ") - "; v.PromoterK = CurrentPromoter.K; changeStatus = true; } else //venue owned by someone else! { CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") attempted to add venue - " + DateTime.Now.ToString() + " - " + v.K + " (" + v.Name + "), but it's already confirmed to promoter " + v.PromoterK + " (" + v.Promoter.Name + ")\n"; failedVenues = (failedVenues.Length == 0 ? "" : ", ") + v.Name + " in " + v.Place.Name; } if (changeStatus) { bool foundVenueOwner = false; CurrentPromoter.AdminUsrs = null; foreach (Usr u in CurrentPromoter.AdminUsrs) { if (v.OwnerUsrK == u.K) foundVenueOwner = true; } if (foundVenueOwner || Usr.Current.IsAdmin) { v.PromoterStatus = Venue.PromoterStatusEnum.Confirmed; CurrentPromoter.AdminNote += "(status confirmed)\n"; } else { v.PromoterStatus = Venue.PromoterStatusEnum.Unconfirmed; CurrentPromoter.AdminNote += "(status new)\n"; } } v.Update(); CurrentPromoter.Update(); } } foreach (int venueK in CurrentVenues) { if (!SelectedVenues.Contains(venueK)) { Venue v = new Venue(venueK); CurrentPromoter.AdminNote += "\n" + Usr.Current.NickName + " (" + Usr.Current.K.ToString() + ") removed venue - " + DateTime.Now.ToString() + " - " + v.K + " (" + v.Name + ")"; v.PromoterStatus = Venue.PromoterStatusEnum.Unconfirmed; v.PromoterK = 0; v.Update(); CurrentPromoter.Update(); } } #endregion this.ViewState["CurrentPromoterK"] = CurrentPromoter.K; CurrentPromoter = new Promoter(CurrentPromoter.K); CurrentPromoter.FixQuestionsThreadUsrs(); CurrentPromoter.UpdateModerators(); Usr.Current.LegalTermsPromoter2 = true; Usr.Current.Update(); if (failedBrands.Length > 0 || failedVenues.Length > 0) { //show error form... BrandErrorLabel.Text = failedBrands; VenueErrorLabel.Text = failedVenues; BrandErrorPanel.Visible = failedBrands.Length > 0; VenueErrorPanel.Visible = failedVenues.Length > 0; ChangePanel(PanelBrandVenueError); } else { if (IsEdit) { if (Usr.Current.IsAdmin) Response.Redirect(CurrentPromoter.Url()); else ChangePanel(PanelEditDone); } else { if (!Usr.Current.IsAdmin) { Thread t = new Thread(CurrentPromoter.QuestionsThreadK); Response.Redirect(t.Url()); } else { Response.Redirect(CurrentPromoter.Url()); } } } } }
void bindPlaceDrop(int SelectedCountryK) { StringBuilder sb = new StringBuilder(); int maxLength = 30; if (SelectedCountryK == 0) { append(sb, "Select a country first...", "0"); //TownDropDown.Items.Add(new ListItem("Select a country first...", "0")); //return; } else { Country country = new Country(SelectedCountryK); Query qTop = new Query(); qTop.Columns = new ColumnSet(Place.Columns.Name, Place.Columns.K, Place.LinkColumns); qTop.TopRecords = 10; qTop.QueryCondition = new And(new Q(Place.Columns.CountryK, SelectedCountryK), new Q(Place.Columns.Enabled, true)); qTop.OrderBy = new OrderBy(Place.Columns.TotalEvents, OrderBy.OrderDirection.Descending); PlaceSet psTop = new PlaceSet(qTop); if (psTop.Count == 0) { append(sb, "No towns in our database for this country", "0"); //TownDropDown.Items.Add(new ListItem("No towns in our database for this country", "0")); } else { append(sb, "Towns in " + country.FriendlyName + "...", "0"); append(sb, "", "0"); append(sb, "--- TOP TOWNS ---", "0"); //TownDropDown.Items.Add(new ListItem("Select a town...", "0")); //TownDropDown.Items.Add(new ListItem("", "0")); //TownDropDown.Items.Add(new ListItem("--- TOP TOWNS ---", "0")); foreach (Place p in psTop) { append(sb, p.Name.TruncateWithDots(maxLength), p.Url()); //TownDropDown.Items.Add(new ListItem(p.Name.TruncateWithDots(maxLength), p.Url())); } Query qAll = new Query(); qAll.Columns = new ColumnSet(Place.Columns.Name, Place.Columns.K, Place.LinkColumns); qAll.OrderBy = new OrderBy(Place.Columns.Name); qAll.QueryCondition = new And(new Q(Place.Columns.CountryK, SelectedCountryK), new Q(Place.Columns.Enabled, true)); PlaceSet psAll = new PlaceSet(qAll); append(sb, "", "0"); append(sb, "--- ALL TOWNS ---", "0"); //TownDropDown.Items.Add(new ListItem("", "0")); //TownDropDown.Items.Add(new ListItem("--- ALL TOWNS ---", "0")); foreach (Place p in psAll) { append(sb, p.Name.TruncateWithDots(maxLength), p.Url()); //TownDropDown.Items.Add(new ListItem(p.Name.TruncateWithDots(maxLength), p.Url())); } } } ExploreTownPh.Controls.Add(new LiteralControl(sb.ToString())); }
void UpdateAncestors(Country c) { this.CountryK = c.K; }
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", "")); } } }
public void PanelLocation_Val(object o, ServerValidateEventArgs e) { Country c = new Country(); bool validRadio = LocationTypeNone.Checked || LocationTypeCountry.Checked || LocationTypePlace.Checked; bool validCountry = true; bool validPlace = true; int selectedCountryK = 0; if (LocationTypeCountry.Checked || LocationTypePlace.Checked) { try { Country country = new Country(int.Parse(LocationCountryDropDown.SelectedValue)); if (!country.Enabled) validCountry = false; selectedCountryK = country.K; } catch { validCountry = false; } } if (LocationTypePlace.Checked) { try { Place place = new Place(int.Parse(LocationPlaceDropDown.SelectedValue)); if (!place.Enabled) validPlace = false; if (selectedCountryK != place.CountryK) validPlace = false; } catch { validPlace = false; } } e.IsValid = validRadio && validCountry && validPlace; }
protected void Page_Load(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); // if (Vars.DevEnv) // System.Threading.Thread.Sleep(new Random().Next(2000)); if (Request.QueryString["type"] == "calendar") { bool freeGuestlist = Request.QueryString["freeGuestlist"] == null || Request.QueryString["freeGuestlist"].Length == 0 || Request.QueryString["freeGuestlist"] == "0" ? false : true; Brand brand = Request.QueryString["brandk"] == null || Request.QueryString["brandk"].Length == 0 || Request.QueryString["brandk"] == "0" ? null : new Brand(int.Parse(Request.QueryString["brandk"])); Place place = Request.QueryString["placek"] == null || Request.QueryString["placek"].Length == 0 || Request.QueryString["placek"] == "0" ? null : new Place(int.Parse(Request.QueryString["placek"])); Venue venue = Request.QueryString["venuek"] == null || Request.QueryString["venuek"].Length == 0 || Request.QueryString["venuek"] == "0" || Request.QueryString["venuek"] == "1" ? null : new Venue(int.Parse(Request.QueryString["venuek"])); int key = Request.QueryString["key"] == null || Request.QueryString["key"].Length == 0 || Request.QueryString["key"] == "0" ? 0 : int.Parse(Request.QueryString["key"]); MusicType music = Request.QueryString["musictypek"] == null || Request.QueryString["musictypek"].Length == 0 || Request.QueryString["musictypek"] == "0" ? null : new MusicType(int.Parse(Request.QueryString["musictypek"])); bool me = Request.QueryString["me"] != null && Request.QueryString["me"] == "1"; bool addGalleryButton = Request.QueryString["addgallery"] != null && Request.QueryString["addgallery"] == "1"; bool allVenues = Request.QueryString["venuek"] != null && Request.QueryString["venuek"] == "1"; DateTime date = new DateTime( int.Parse(Request.QueryString["date"].Substring(0, 4)), int.Parse(Request.QueryString["date"].Substring(4, 2)), int.Parse(Request.QueryString["date"].Substring(6, 2)) > 0 ? int.Parse(Request.QueryString["date"].Substring(6, 2)) : 1 ); //if (date == DateTime.Today) // System.Threading.Thread.Sleep(1000); DateTime from = date.Previous(DayOfWeek.Monday, true); DateTime to = date.Next(DayOfWeek.Sunday, true); Event.EventsForDisplay events = new Event.EventsForDisplay(); events.IgnoreMusicType = true; if (me) { events.AttendedUsrK = Usr.Current.K; } else if (brand != null) { events.BrandK = brand.K; } else if (venue != null) { events.VenueK = venue.K; } else if (place != null && music != null) { events.PlaceK = place.K; events.MusicTypeK = music.K; } else if (place != null && freeGuestlist) { events.PlaceK = place.K; events.FreeGuestlist = freeGuestlist; } else if (key > 0) { } else throw new Exception(); EventSet es; if (key == 0) es = events.GetEventsBetweenDates(from, to); else es = new EventSet(new Query(new Q(Event.Columns.K, key))); CustomControls.DsiCalendar calendar = new Spotted.CustomControls.DsiCalendar(); calendar.AllEvents = es; calendar.Month = date.Month; calendar.ShowCountryFriendlyName = !(events.FilterByCountry || events.FilterByPlace || events.FilterByVenue); calendar.ShowPlace = !(events.FilterByPlace || events.FilterByVenue); calendar.ShowVenue = !events.FilterByVenue; calendar.ShowAddGalleryButton = addGalleryButton; calendar.Tickets = true; calendar.StartDate = from; calendar.EndDate = to; Out.Controls.Add(calendar); } else { sb.AppendLine("{"); if (Request.QueryString["type"] == "music") { #region Music types Query q = new Query(); q.QueryCondition = new Q(MusicType.Columns.K, QueryOperator.NotEqualTo, 1); q.Columns = new ColumnSet(MusicType.Columns.Name, MusicType.Columns.ParentK, MusicType.Columns.K); q.OrderBy = new OrderBy(MusicType.Columns.Order, OrderBy.OrderDirection.Ascending); q.CacheDuration = TimeSpan.FromDays(1); MusicTypeSet mts = new MusicTypeSet(q); append(sb, "Select your music...", "0"); append(sb, "", ""); foreach (MusicType mt in mts) { append(sb, (mt.ParentK == 1 ? "" : "... ") + mt.Name, mt.K.ToString()); } #endregion } else if (Request.QueryString["type"] == "country") { #region Countries append(sb, "Select a country...", "0"); Query qTop = new Query(); qTop.Columns = new ColumnSet(Country.Columns.FriendlyName, Country.Columns.K); qTop.OrderBy = new OrderBy(Country.Columns.TotalEvents, OrderBy.OrderDirection.Descending); qTop.QueryCondition = new Q(Country.Columns.Enabled, true); qTop.TopRecords = 10; qTop.CacheDuration = TimeSpan.FromDays(1); CountrySet csTop = new CountrySet(qTop); append(sb, "", ""); append(sb, "--- TOP COUNTRIES ---", "0"); foreach (Country c in csTop) { append(sb, c.FriendlyName.TruncateWithDots(maxLength), c.K.ToString()); } Query qAll = new Query(); qAll.Columns = new ColumnSet(Country.Columns.FriendlyName, Country.Columns.K); qAll.OrderBy = new OrderBy(Country.Columns.FriendlyName); qAll.QueryCondition = new And(new Q(Country.Columns.Enabled, true), new StringQueryCondition("(SELECT COUNT(*) FROM [Place] WHERE [Place].[Enabled] = 1 AND [Place].[CountryK] = [Country].[K]) > 0")); qAll.CacheDuration = TimeSpan.FromDays(1); CountrySet csAll = new CountrySet(qAll); append(sb, "", ""); append(sb, "--- ALL COUNTRIES ---", "0"); foreach (Country c in csAll) { append(sb, c.FriendlyName.TruncateWithDots(maxLength), c.K.ToString()); } #endregion } else if (Request.QueryString["type"] == "place") { #region Places int countryK = int.Parse(Request.QueryString["countryk"]); Country country = new Country(countryK); Query qTop = new Query(); qTop.Columns = new ColumnSet(Place.Columns.Name, Place.Columns.K, Place.LinkColumns); qTop.TopRecords = 10; qTop.QueryCondition = new And(new Q(Place.Columns.CountryK, country.K), new Q(Place.Columns.Enabled, true)); qTop.OrderBy = new OrderBy(Place.Columns.TotalEvents, OrderBy.OrderDirection.Descending); PlaceSet psTop = new PlaceSet(qTop); if (psTop.Count == 0) { append(sb, "No towns in our database for this country", ""); } else { append(sb, "Towns in " + country.FriendlyName.Truncate(maxLength) + "...", ""); append(sb, "", ""); if (psTop.Count < 10) { foreach (Place p in psTop) append(sb, p.NamePlainRegion.TruncateWithDots(maxLength), Request.QueryString["return"] == "k" ? p.K.ToString() : p.Url()); } else { append(sb, "--- TOP TOWNS ---", ""); foreach (Place p in psTop) append(sb, p.NamePlainRegion.TruncateWithDots(maxLength), Request.QueryString["return"] == "k" ? p.K.ToString() : p.Url()); Query qAll = new Query(); qAll.Columns = new ColumnSet(Place.Columns.Name, Place.Columns.K, Place.LinkColumns); qAll.OrderBy = new OrderBy(Place.Columns.UrlName); qAll.QueryCondition = new And(new Q(Place.Columns.CountryK, countryK), new Q(Place.Columns.Enabled, true)); PlaceSet psAll = new PlaceSet(qAll); append(sb, "", ""); append(sb, "--- ALL TOWNS ---", ""); foreach (Place p in psAll) append(sb, p.NamePlainRegion.TruncateWithDots(maxLength), Request.QueryString["return"] == "k" ? p.K.ToString() : p.Url()); } } #endregion } else if (Request.QueryString["type"] == "venue") { #region Venues int placeK = int.Parse(Request.QueryString["placek"]); Place place = new Place(placeK); Query qTop = new Query(); qTop.Columns = new ColumnSet(Venue.Columns.Name, Venue.Columns.K, Venue.LinkColumns); qTop.TopRecords = 10; qTop.QueryCondition = new Q(Venue.Columns.PlaceK, place.K); qTop.OrderBy = new OrderBy(Venue.Columns.TotalEvents, OrderBy.OrderDirection.Descending); VenueSet vsTop = new VenueSet(qTop); if (vsTop.Count == 0) { append(sb, "No venues in our database for this town", ""); } else { append(sb, "Venues in " + place.NamePlainRegion.Truncate(maxLength) + "...", ""); append(sb, "", ""); if (Request.QueryString["all"] == "1") { append(sb, "All venues", "1"); append(sb, "", ""); } if (vsTop.Count < 10) { appendVenues(sb, vsTop); } else { append(sb, "--- TOP VENUES ---", ""); appendVenues(sb, vsTop); Query qAll = new Query(); qAll.Columns = new ColumnSet(Venue.Columns.Name, Venue.Columns.K, Venue.LinkColumns); qAll.OrderBy = new OrderBy("( CASE WHEN [Venue].[UrlName] LIKE 'the-%' THEN SUBSTRING([Venue].[UrlName], 4, LEN([Venue].[UrlName]) - 4) ELSE [Venue].[UrlName] END )"); qAll.QueryCondition = new Q(Venue.Columns.PlaceK, placeK); VenueSet vsAll = new VenueSet(qAll); append(sb, "", ""); append(sb, "--- ALL VENUES ---", ""); if (vsAll.Count <= 300) { appendVenues(sb, vsAll); } else { append(sb, "Select the first letter:", ""); append(sb, "", ""); append(sb, "0-9", "*0"); string ch; for (int i = 65; i <= 90; i++) { ch = char.ConvertFromUtf32(i); append(sb, ch.ToUpper() + "...", "*" + ch.ToLower()); } } } } #endregion } else if (Request.QueryString["type"] == "venuebyletter") { #region Venues int placeK = int.Parse(Request.QueryString["placek"]); string letter = Request.QueryString["letter"]; if (letter.Length > 1) throw new Exception(); Place place = new Place(placeK); string qu = ""; if (letter.ToLower() == "0") { qu = "([Venue].[UrlName] LIKE '[0-9]%' OR [Venue].[UrlName] LIKE 'the-[0-9]%')"; } else if (letter.ToLower() == "t") { qu = "(([Venue].[UrlName] LIKE 't%' AND [Venue].[UrlName] NOT LIKE 'the-%' ) OR [Venue].[UrlName] LIKE 'the-t%')"; } else { qu = "([Venue].[UrlName] LIKE '" + letter.ToLower() + "%' OR [Venue].[UrlName] LIKE 'the-" + letter.ToLower() + "%')"; } Query q = new Query(); q.Columns = new ColumnSet(Venue.Columns.Name, Venue.Columns.K, Venue.LinkColumns); //q.OrderBy = new OrderBy(Venue.Columns.UrlName); q.OrderBy = new OrderBy("( CASE WHEN [Venue].[UrlName] LIKE 'the-%' THEN SUBSTRING([Venue].[UrlName], 4, LEN([Venue].[UrlName]) - 4) ELSE [Venue].[UrlName] END )"); q.QueryCondition = new And( new Q(Venue.Columns.PlaceK, placeK), new StringQueryCondition(qu)); VenueSet vs = new VenueSet(q); if (vs.Count == 0) { append(sb, "No venues starting with " + letter.ToUpper(), ""); } else { append(sb, "Venues starting with " + letter.ToUpper() + "...", ""); append(sb, "", ""); appendVenues(sb, vs); } #endregion } else if (Request.QueryString["type"] == "event") { #region Events int venueK = int.Parse(Request.QueryString["venuek"]); int brandK = int.Parse(Request.QueryString["brandk"]); int key = int.Parse(Request.QueryString["key"]); int year = int.Parse(Request.QueryString["date"].Substring(0, 4)); int month = int.Parse(Request.QueryString["date"].Substring(4, 2)); DateTime dateFrom = new DateTime(year, month, 1); DateTime dateTo = dateFrom.AddMonths(1); Venue venue = venueK > 1 ? new Venue(venueK) : null; Brand brand = brandK > 0 ? new Brand(brandK) : null; EventSet es; if (key == 0) { Query q = new Query(); if (brand == null) q.Columns = new ColumnSet(Event.Columns.DateTime, Event.Columns.Name, Event.Columns.K); else q.Columns = new ColumnSet(Event.Columns.DateTime, Event.Columns.Name, Event.Columns.K, Event.FriendlyLinkColumns); q.QueryCondition = new And( new Q(Event.Columns.DateTime, QueryOperator.GreaterThanOrEqualTo, dateFrom), new Q(Event.Columns.DateTime, QueryOperator.LessThan, dateTo), venue != null ? new Q(Event.Columns.VenueK, venue.K) : new Q(true), brand != null ? new Q(EventBrand.Columns.BrandK, brand.K) : new Q(true)); q.OrderBy = Event.FutureEventOrder; if (brandK > 0) { q.TableElement = new Join( Event.CountryAllJoin, new TableElement(TablesEnum.EventBrand), QueryJoinType.Inner, Event.Columns.K, EventBrand.Columns.EventK); } es = new EventSet(q); } else es = new EventSet(new Query(new Q(Event.Columns.K, key))); if (es.Count == 0) { append(sb, "No events in our database for this selection", ""); } else { //append(sb, "Events at " + venue.FriendlyName.Truncate(maxLength) + ", " + dateFrom.ToString("MMM yyyy") + "...", ""); //append(sb, "", ""); Dictionary<string, int> counter = new Dictionary<string, int>(); foreach (Event ev in es) { string key1 = eventString(ev, brand != null); if (counter.ContainsKey(key1.ToLower())) counter[key1.ToLower()]++; else counter[key1.ToLower()] = 1; } foreach (Event ev in es) { string key1 = eventString(ev, brand != null); if (counter[key1.ToLower()] > 1) key1 = key1.Substring(0, 8) + " - #" + ev.K.ToString() + key1.Substring(8); append(sb, key1, ev.K.ToString()); } } #endregion } sb.AppendLine(""); sb.Append("}"); } Out.Controls.Add(new LiteralControl(sb.ToString())); }