protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CountryDrop.Items.Clear(); CountryDrop.Items.Add(new ListItem("select here...", "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; CountrySet csTop = new CountrySet(qTop); CountryDrop.Items.Add(new ListItem("", "0")); CountryDrop.Items.Add(new ListItem("- POPULAR COUNTRIES -", "0")); foreach (Country c in csTop) CountryDrop.Items.Add(new ListItem(Cambro.Misc.Utility.Snip(c.FriendlyName, 25), 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 Q(Country.Columns.Enabled, true); CountrySet csAll = new CountrySet(qAll); CountryDrop.Items.Add(new ListItem("", "0")); CountryDrop.Items.Add(new ListItem("--- ALL COUNTRIES ---", "0")); foreach (Country c in csAll) CountryDrop.Items.Add(new ListItem(Cambro.Misc.Utility.Snip(c.FriendlyName, 25), c.K.ToString())); } }
private void Page_Load(object sender, System.EventArgs e) { Query q = new Query(); q.NoLock = true; q.QueryCondition = new And(new Q(Country.Columns.Enabled, true), new Q(Country.Columns.TotalEvents, QueryOperator.GreaterThan, 0)); q.OrderBy = new OrderBy(Country.Columns.Name); q.Columns = Templates.Countries.ListFlag.Columns; CountrySet cs = new CountrySet(q); CountriesDataList.ItemTemplate = this.LoadTemplate("/Templates/Countries/ListFlag.ascx"); CountriesDataList.DataSource = cs; CountriesDataList.DataBind(); Query q1 = new Query(); q1.NoLock = true; q1.QueryCondition = new Q(Country.Columns.Enabled, true); q1.OrderBy = new OrderBy(Country.Columns.Name); q1.Columns = Templates.Countries.ListSmall.Columns; CountrySet cs1 = new CountrySet(q1); OtherCountriesDataList.ItemTemplate = this.LoadTemplate("/Templates/Countries/ListSmall.ascx"); OtherCountriesDataList.DataSource = cs1; OtherCountriesDataList.DataBind(); }
public void PanelSignUpForm_Load(object o, System.EventArgs e) { if (Usr.Current == null) return; #region set up mobile number dialing code if (!Page.IsPostBack) { if (Usr.Current.Mobile.Length > 0) { if ( Usr.Current.MobileCountryCode.Equals("44") || Usr.Current.MobileCountryCode.Equals("61") || Usr.Current.MobileCountryCode.Equals("33") || Usr.Current.MobileCountryCode.Equals("49") || Usr.Current.MobileCountryCode.Equals("353") || Usr.Current.MobileCountryCode.Equals("39") || Usr.Current.MobileCountryCode.Equals("34") || Usr.Current.MobileCountryCode.Equals("1") ) { DialingCodeDropDown.SelectedValue = Usr.Current.MobileCountryCode; DialingCodeOtherSpan.Style["display"] = "none"; } else { DialingCodeDropDown.SelectedValue = "0"; DialingCodeOtherSpan.Style["display"] = null; DialingCodeOther.Text = Usr.Current.MobileCountryCode; } MobileNumber.Text = Usr.Current.MobileNumber; } else { if (Country.Current != null && Country.Current.DialingCode > 0) { DialingCodeDropDown.SelectedValue = Country.Current.DialingCode.ToString(); DialingCodeOtherSpan.Style["display"] = "none"; } else { DialingCodeDropDown.SelectedValue = "0"; DialingCodeOtherSpan.Style["display"] = null; } } } if (DialingCodeDropDown.SelectedValue.Equals("0")) { DialingCodeOtherSpan.Style["display"] = null; } else { DialingCodeOtherSpan.Style["display"] = "none"; } #endregion #region set up address if (!Page.IsPostBack) { CountrySet cs = new CountrySet(new Query()); AddressCountry.DataSource = cs; AddressCountry.DataTextField = "Name"; AddressCountry.DataValueField = "K"; AddressCountry.DataBind(); FirstName.Text = Usr.Current.FirstName; LastName.Text = Usr.Current.LastName; AddressStreet.Text = Usr.Current.AddressStreet; AddressArea.Text = Usr.Current.AddressArea; AddressTown.Text = Usr.Current.AddressTown; AddressCounty.Text = Usr.Current.AddressCounty; AddressPostcode.Text = Usr.Current.AddressPostcode; PhotoUsageUse.Checked = Usr.Current.PhotoUsage == Model.Entities.Usr.PhotoUsageEnum.Use; PhotoUsageContact.Checked = Usr.Current.PhotoUsage == Model.Entities.Usr.PhotoUsageEnum.Contact; PhotoUsageDoNotUse.Checked = Usr.Current.PhotoUsage == Model.Entities.Usr.PhotoUsageEnum.DoNotUse; if (Usr.Current.DateOfBirth > DateTime.MinValue) { DateOfBirthDay.Text = Usr.Current.DateOfBirth.Day.ToString(); DateOfBirthMonth.Text = Usr.Current.DateOfBirth.Month.ToString(); DateOfBirthYear.Text = Usr.Current.DateOfBirth.Year.ToString(); } if (Usr.Current.AddressCountryK > 0) { try { AddressCountry.SelectedValue = Usr.Current.AddressCountryK.ToString(); } catch { } } else if (Country.FilterK > 0) { try { AddressCountry.SelectedValue = Country.FilterK.ToString(); } catch { } } } #endregion }
void BuildSignUpForm() { CountrySet cs = new CountrySet(new Query()); AddressCountry.DataSource = cs; AddressCountry.DataTextField = "Name"; AddressCountry.DataValueField = "K"; AddressCountry.DataBind(); VatCountryDropDownList.DataSource = cs; VatCountryDropDownList.DataTextField = "Name"; VatCountryDropDownList.DataValueField = "K"; VatCountryDropDownList.DataBind(); VatCountryDropDownList.Items.Insert(0, new ListItem("United Kingdom", "224")); // put this also at top of list - save Tim a bit of time VatCountryDropDownList.Items.Insert(0, new ListItem("", "0")); VatStatusDropDownList.Items.Clear(); VatStatusDropDownList.Items.Add(new ListItem("", "0")); VatStatusDropDownList.Items.Add(new ListItem(Utilities.CamelCaseToString(Promoter.VatStatusEnum.NotRegistered.ToString()), Convert.ToInt32(Promoter.VatStatusEnum.NotRegistered).ToString())); VatStatusDropDownList.Items.Add(new ListItem(Promoter.VatStatusEnum.Registered.ToString(), Convert.ToInt32(Promoter.VatStatusEnum.Registered).ToString())); if (IsEdit) { ContactName.Text = CurrentPromoter.ContactName; Name.Text = CurrentPromoter.Name; PhoneNumber.Text = CurrentPromoter.PhoneNumber; AddressStreet.Text = CurrentPromoter.AddressStreet; AddressArea.Text = CurrentPromoter.AddressArea; AddressTown.Text = CurrentPromoter.AddressTown; AddressCounty.Text = CurrentPromoter.AddressCounty; AddressPostcode.Text = CurrentPromoter.AddressPostcode; try { AddressCountry.SelectedValue = CurrentPromoter.AddressCountryK.ToString(); } catch { } // Vat details VatStatusDropDownList.SelectedValue = Convert.ToInt32(CurrentPromoter.VatStatus).ToString(); VatNumberTextBox.Text = CurrentPromoter.VatNumber; try { VatCountryDropDownList.SelectedValue = CurrentPromoter.VatCountryK.ToString(); } catch { } // new Admin only data entry fields, as requested by Dave 7/2/07 AccountsEmail.Text = CurrentPromoter.AccountsEmail; AccountsName.Text = CurrentPromoter.AccountsName; AccountsPhone.Text = CurrentPromoter.AccountsPhone; PersonalTitle.Text = CurrentPromoter.ContactPersonalTitle; JobTitle.Text = CurrentPromoter.ContactTitle; PhoneNumber2.Text = CurrentPromoter.PhoneNumber2; WebAddress.Text = CurrentPromoter.WebAddress; uiAgency.Checked = CurrentPromoter.IsAgency; Sector.SelectedValue = Convert.ToInt32(CurrentPromoter.ClientSector).ToString(); SalesCampaignDropDown.SelectedValue = CurrentPromoter.SalesCampaignK.ToString(); // new admin only bank details, as requested by Dave 15/6/07 BankNameTextBox.Text = CurrentPromoter.BankName; BankAccountNameTextBox.Text = CurrentPromoter.BankAccountName; BankAccountNumberTextBox.Text = CurrentPromoter.BankAccountNumber; BankAccountSortCodeTextBox.Text = CurrentPromoter.BankAccountSortCode; AccountTypeRadioEvents.Checked = CurrentPromoter.AllBrands.Count > 0; AccountTypeRadioNoEvents.Checked = CurrentPromoter.AllBrands.Count == 0; BrandsTr.Visible = AccountTypeRadioEvents.Checked; if (AccountTypeRadioEvents.Checked) { foreach (Brand b in CurrentPromoter.AllBrands) { this.uiBrandMultiSelector.Add(b.Name, b.K.ToString()); } } VenuesRadioYes.Checked = CurrentPromoter.AllVenues.Count > 0; VenuesRadioNo.Checked = CurrentPromoter.AllVenues.Count == 0; VenuesTr.Visible = VenuesRadioYes.Checked; if (VenuesRadioYes.Checked) { foreach (Venue v in CurrentPromoter.AllVenues) { this.uiVenuesMultiSelector.Add(v.Name + " in " + v.Place.Name, v.K.ToString()); } } AccessP.Visible = CurrentPromoter.PrimaryUsrK == Usr.Current.K || Usr.Current.IsAdmin || Usr.Current.IsSuperAdmin; NoAccessP.Visible = CurrentPromoter.PrimaryUsrK != Usr.Current.K && !Usr.Current.IsAdmin && !Usr.Current.IsSuperAdmin; try { PrimaryUsrSpan.InnerHtml = CurrentPromoter.PrimaryUsrLink; } catch{} if (CurrentPromoter.PrimaryUsrK == Usr.Current.K || Usr.Current.IsAdmin || Usr.Current.IsSuperAdmin) { if (CurrentPromoter.AdminUsrs.Count > 1 || Usr.Current.IsAdmin || Usr.Current.IsSuperAdmin) { if (CurrentPromoter.PrimaryUsrK > 0 && (Usr.Current.IsAdmin || Usr.Current.IsSuperAdmin)) { this.uiAccessUsersMultiSelector.Add(CurrentPromoter.PrimaryUsr.NickName, CurrentPromoter.PrimaryUsrK.ToString()); this.uiPrimaryUserDropDown.Items.Add(new ListItem(CurrentPromoter.PrimaryUsr.NickName, CurrentPromoter.PrimaryUsrK.ToString())); } foreach (Usr u in CurrentPromoter.AdminUsrs) { if (u.K != CurrentPromoter.PrimaryUsrK) { this.uiAccessUsersMultiSelector.Add(u.NickName, u.K.ToString()); } } } AccessMultiRadio.Checked = CurrentPromoter.AdminUsrs.Count > 1 || (CurrentPromoter.AdminUsrs.Count == 1 && (Usr.Current.IsAdmin || Usr.Current.IsSuperAdmin)); AccessJustMeRadio.Checked = CurrentPromoter.AdminUsrs.Count == 1 && !AccessMultiRadio.Checked; AccessNoAccountUsersRadio.Checked = CurrentPromoter.AdminUsrs.Count == 0 && !AccessMultiRadio.Checked; MultiAccess.Visible = AccessMultiRadio.Checked; } } else { ContactName.Text = Usr.Current.FirstName + " " + Usr.Current.LastName; if (Country.FilterK > 0) AddressCountry.SelectedValue = Country.FilterK.ToString(); AccountTypeRadioEvents.Checked = true; AccountTypeRadioNoEvents.Checked = false; } }
protected void Page_Load(object sender, EventArgs e) { Query qAll = new Query(); qAll.Columns = new ColumnSet(Country.Columns.FriendlyName, Country.Columns.K); qAll.OrderBy = new OrderBy(Country.Columns.FriendlyName); qAll.QueryCondition = new Q(Country.Columns.Enabled, true); CountrySet csAll = new CountrySet(qAll); CountryDropDownList.DataSource = csAll; CountryDropDownList.DataTextField = "FriendlyName"; CountryDropDownList.DataValueField = "K"; CountryDropDownList.DataBind(); CountryDropDownList.SelectedValue = IpCountry.ClientCountryK().ToString(); if (Request.QueryString["k"] != null && Request.QueryString["code"] != null) { Bobs.MixmagSubscription ms = new Bobs.MixmagSubscription(int.Parse(Request.QueryString["k"])); if (ms.EmailVerificationSecret.ToLower() == Request.QueryString["code"].ToLower()) { ms.IsEmailVerified = true; ms.Update(); } } if (Request.QueryString["k"] != null && Request.QueryString["email"] != null) { Bobs.MixmagSubscription ms = new Bobs.MixmagSubscription(int.Parse(Request.QueryString["k"])); if (ms.Email.ToLower() == Request.QueryString["email"].ToLower()) { Query q = new Query(); q.QueryCondition = new Q(Bobs.MixmagSubscription.Columns.Email, ms.Email); MixmagSubscriptionSet mss = new MixmagSubscriptionSet(q); foreach (Bobs.MixmagSubscription ms1 in mss) { ms1.SendMixmag = false; ms1.Update(); } } } if (Request.QueryString["k"] != null && Request.QueryString["uid"] != null) { Bobs.MixmagSubscription ms = new Bobs.MixmagSubscription(int.Parse(Request.QueryString["k"])); if (ms.FacebookUID == int.Parse(Request.QueryString["uid"])) { ms.SendMixmag = false; ms.Update(); } } if (IssueDate.HasValue) { string code = IssueDate.Value.Year.ToString("0000"); code += IssueDate.Value.Month.ToString("00"); code += CoverId.HasValue ? CoverId.Value.ToString("0") : "0"; if (PageNumber.HasValue && PageNumber.Value > 0) { code += PageNumber.Value.ToString(); } RequestCode.Value = code; } int selectedIssue = 0; DateTime? selectedIssueDate = null; if (IssueDate.HasValue) { DateTime month = IssueDate.Value; Query q = new Query(); if (CoverId.HasValue) { q.QueryCondition = new And( new Q(MixmagIssue.Columns.IssueCoverDate, month), new Q(MixmagIssue.Columns.IssueCoverId, CoverId.Value) ); } else { q.QueryCondition = new Q(MixmagIssue.Columns.IssueCoverDate, month); } q.OrderBy = new OrderBy(MixmagIssue.Columns.IssueCoverId); MixmagIssueSet mis = new MixmagIssueSet(q); if (mis.Count > 0) { MixmagIssue issue = mis[0]; LoginButtonIntroTextP.InnerText = "You must connect with Facebook to read Mixmag:"; FacebookHttpContext context = null; try { context = FacebookHttpContext.Current; } catch { } if (context != null) { var usrR = FacebookHttpContext.Current.Users.GetLoggedInUser(); if (usrR != null && usrR.Value > 0) { Query q2 = new Query(); q2.QueryCondition = new Q(Bobs.MixmagSubscription.Columns.FacebookUID, usrR.Value); MixmagSubscriptionSet mss = new MixmagSubscriptionSet(q2); if (mss.Count > 0) { Bobs.MixmagSubscription subscriber = mss[0]; MixmagRead mr = null; try { mr = new MixmagRead(subscriber.K, issue.K); } catch (BobNotFound) { mr = new MixmagRead(); mr.MixmagSubscriberK = subscriber.K; mr.MixmagIssueK = issue.K; mr.DateTimeRead = DateTime.Now; } if (subscriber.PublishStoryOnRead.HasValue && subscriber.PublishStoryOnRead.Value) { //Have we sent a message to this subscribers facebook wall on the last 12 hours? If so, don't send this one. Query q3 = new Query(); q3.QueryCondition = new And( new Q(MixmagRead.Columns.MixmagSubscriberK, subscriber.K), new Q(MixmagRead.Columns.DateTimeLastStoryPublished, QueryOperator.GreaterThan, DateTime.Now.AddHours(-48)), new Q(MixmagRead.Columns.StoryPublished, true) ); MixmagReadSet mrs = new MixmagReadSet(q3); if (mrs.Count == 0) { //send to wall... bool found = false; if (PageNumber.HasValue) { foreach (MixmagIssue.ContentsItem item in issue.Contents) { if (item.PageNumber == PageNumber.Value) { FacebookHttpContext.Current.Status.Set(item.StatusMessage + " - " + issue.Url(true, PageNumber)); found = true; } } } if (!found) FacebookHttpContext.Current.Status.Set(issue.Contents[0].StatusMessage + " - " + issue.Url(true, null)); mr.StoryPublished = true; mr.DateTimeLastStoryPublished = DateTime.Now; } } if (mr.TotalReads.HasValue) mr.TotalReads++; else mr.TotalReads = 1; mr.DateTimeLastRead = DateTime.Now; mr.Update(); if (issue.TotalRead.HasValue) issue.TotalRead++; else issue.TotalRead = 1; issue.Update(); //Response.Redirect(issue.CerosUrl); Response.Write(@"<FRAMESET cols=""100%""><FRAMESET rows=""100%""><FRAME src=""" + issue.CerosUrl + (PageNumber.HasValue ? ("/page/" + PageNumber.ToString()) : "") + @"""></FRAMESET></FRAMESET>"); Response.End(); } } } SelectedIssueHolder.Visible = true; SelectedIssuePh.Controls.Clear(); SelectedIssuePh.Controls.Add(new LiteralControl(issue.GetHtml(PageNumber, false))); selectedIssue = issue.K; } } if (selectedIssue == 0) { //Get latest issue Query q1 = new Query(); q1.QueryCondition = new And( new Q(MixmagIssue.Columns.DateTimeSend, QueryOperator.LessThan, DateTime.Now), new Q(MixmagIssue.Columns.Ready, true)); q1.OrderBy = new OrderBy(MixmagIssue.Columns.IssueCoverDate, OrderBy.OrderDirection.Descending); q1.TopRecords = 1; MixmagIssueSet latestDateTimeSet = new MixmagIssueSet(q1); if (latestDateTimeSet.Count > 0) { selectedIssueDate = latestDateTimeSet[0].IssueCoverDate; Query q2 = new Query(); q2.QueryCondition = new And( new Q(MixmagIssue.Columns.DateTimeSend, QueryOperator.LessThan, DateTime.Now), new Q(MixmagIssue.Columns.Ready, true), new Q(MixmagIssue.Columns.IssueCoverDate, latestDateTimeSet[0].IssueCoverDate.Value)); q2.OrderBy = new OrderBy(MixmagIssue.Columns.IssueCoverId); MixmagIssueSet latestIssueSet = new MixmagIssueSet(q2); if (latestIssueSet.Count > 0) { SelectedIssueHeader.InnerHtml = "Current issue" + (latestIssueSet.Count > 1 ? "s" : ""); SelectedIssuePh.Controls.Clear(); foreach (MixmagIssue issue in latestIssueSet) SelectedIssuePh.Controls.Add(new LiteralControl(issue.GetHtml(null, false))); SelectedIssueHolder.Visible = true; } } } { Query q = new Query(); q.QueryCondition = new And( new Q(MixmagIssue.Columns.DateTimeSend, QueryOperator.LessThan, DateTime.Now), new Q(MixmagIssue.Columns.Ready, true), selectedIssue > 0 ? new Q(MixmagIssue.Columns.K, QueryOperator.NotEqualTo, selectedIssue) : new Q(true), selectedIssueDate.HasValue ? new Q(MixmagIssue.Columns.IssueCoverDate, QueryOperator.NotEqualTo, selectedIssueDate) : new Q(true)); q.OrderBy = new OrderBy( new OrderBy(MixmagIssue.Columns.IssueCoverDate, OrderBy.OrderDirection.Descending), new OrderBy(MixmagIssue.Columns.IssueCoverId)); q.TopRecords = 24; MixmagIssueSet backIssues = new MixmagIssueSet(q); if (backIssues.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (MixmagIssue mi in backIssues) { sb.Append(mi.GetHtml(null, false)); } BackIssuesPh.Controls.Clear(); BackIssuesPh.Controls.Add(new LiteralControl(sb.ToString())); BackIssuesHolder.Visible = true; } } }
public void UpdateIpCountry(object o, System.EventArgs e) { Cambro.Web.Helpers.WriteAlertHeader(); Cambro.Web.Helpers.WriteAlert("Selecting IpCountry entries...", 1); Query q = new Query(); IpCountrySet bs = new IpCountrySet(q); for (int count = 0; count < bs.Count; count++) { IpCountry c = bs[count]; try { Country country = null; CountrySet cs = new CountrySet(new Query(new Q(Country.Columns.Code2Letter, c.Code2Letter))); if (cs.Count == 1) country = cs[0]; else { CountrySet cs1 = new CountrySet(new Query(new Q(Country.Columns.Code3Letter, c.Code3Letter))); if (cs1.Count == 1) country = cs1[0]; } if (country != null) c.CountryK = country.K; else c.CountryK = 0; c.Update(); if (count % 10 == 0) Cambro.Web.Helpers.WriteAlert("Done " + count + "/" + bs.Count, 2); } catch(Exception ex) { Cambro.Web.Helpers.WriteAlert("Exception " + count + "/" + bs.Count + " - " + ex.ToString(), 3); } bs.Kill(count); } Cambro.Web.Helpers.WriteAlert("Done!", 3); Cambro.Web.Helpers.WriteAlertFooter(); }
//<h1 class="TabHolder" runat="server" visible="false"> // <a href="/" class="TabbedHeading Selected" id="ExploreBoxExploreHeader" onclick="exploreBoxTabClick(0);return false;">Explore Don't Stay In</a> // <a href="/" class="TabbedHeading" id="ExploreBoxFindHeader" onclick="exploreBoxTabClick(1);return false;">Find your photo</a> //</h1> //function exploreBoxTabClick(tabID) //{ // Sys.Application.addHistoryPoint({ Home_ExploreTab: tabID }, tabID == 0 ? "Explore" : "Find your photo"); //} //function exploreBoxTabNavigate(sender, e) //{ // var tabID = e.get_state().Home_ExploreTab; // document.getElementById("<%= ExploreBoxExploreHolder.ClientID %>").style.display = (tabID == 1 ? "none" : ""); // document.getElementById("ExploreBoxFindHolder").style.display = (tabID == 1 ? "" : "none"); // document.getElementById("ExploreBoxExploreHeader").className = (tabID == 1 ? "TabbedHeading" : "TabbedHeading Selected"); // document.getElementById("ExploreBoxFindHeader").className = (tabID == 1 ? "TabbedHeading Selected" : "TabbedHeading"); //} protected void Page_Load(object sender, EventArgs e) { JQuery.Include(Page, "selectboxes", "selectboxes"); int defaultCountryK = 0; if (Usr.Current == null) { if (Visit.Current.CountryK > 0) defaultCountryK = Visit.Current.CountryK; } else { defaultCountryK = Usr.Current.Home.CountryK; } bool foundDefault = false; //http://www.texotela.co.uk/code/jquery/select/ StringBuilder sb = new StringBuilder(); int maxLength = 20; append(sb, "Select a country...", "0"); //CountryDropDown.Items.Add(new ListItem("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, "", "0"); append(sb, "--- TOP COUNTRIES ---", "0"); //CountryDropDown.Items.Add(new ListItem("", "0")); //CountryDropDown.Items.Add(new ListItem("--- TOP COUNTRIES ---", "0")); foreach (Country c in csTop) { bool thisIsDefault = false; if (c.K == defaultCountryK) { thisIsDefault = true; foundDefault = true; } append(sb, c.FriendlyName.TruncateWithDots(maxLength), c.K.ToString(), thisIsDefault); //CountryDropDown.Items.Add(new ListItem(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, "", "0"); append(sb, "--- ALL COUNTRIES ---", "0"); //CountryDropDown.Items.Add(new ListItem("", "0")); //CountryDropDown.Items.Add(new ListItem("--- ALL COUNTRIES ---", "0")); foreach (Country c in csAll) { bool thisIsDefault = false; if (!foundDefault && c.K == defaultCountryK) { thisIsDefault = true; foundDefault = true; } append(sb, c.FriendlyName.TruncateWithDots(maxLength), c.K.ToString(), thisIsDefault); //CountryDropDown.Items.Add(new ListItem(c.FriendlyName.TruncateWithDots(maxLength), c.K.ToString())); } ExploreCountryPh.Controls.Add(new LiteralControl(sb.ToString())); bindPlaceDrop(defaultCountryK); ExploreDefaultCountryPh.Controls.Add(new LiteralControl(defaultCountryK.ToString())); }
private void Page_Load(object sender, System.EventArgs e) { Response.ContentType = "text/xml"; Response.Clear(); Response.Buffer = false; XmlTextWriter x = new XmlTextWriter(Response.OutputStream, Encoding.UTF8); x.Formatting = Formatting.Indented; x.WriteRaw("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); string dateFormat = "yyyy-MM-ddTHH:mm:sszzz"; if (Request.QueryString[0].Equals("index")) { #region sitemapindex x.WriteStartElement("sitemapindex"); x.WriteAttributeString("xmlns", "http://www.google.com/schemas/sitemap/0.84"); if (true) { #region sitemap - countries x.WriteStartElement("sitemap"); x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?country"); Query q = new Query(); q.QueryCondition = new And( new Q(Thread.Columns.Private, false), new Q(Thread.Columns.PrivateGroup, false), new Q(Thread.Columns.GroupPrivate, false) ); q.OrderBy = new OrderBy(Thread.Columns.LastPost, OrderBy.OrderDirection.Descending); q.TopRecords = 1; ThreadSet bobset = new ThreadSet(q); if (bobset.Count > 0) x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat)); x.WriteEndElement(); //sitemap #endregion } if (true) { #region sitemap - place x.WriteStartElement("sitemap"); x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?place"); Query q = new Query(); q.OrderBy = new OrderBy(Place.Columns.LastPost, OrderBy.OrderDirection.Descending); q.TopRecords = 1; PlaceSet bobset = new PlaceSet(q); if (bobset.Count > 0) x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat)); x.WriteEndElement(); //sitemap #endregion } if (true) { #region sitemap - venue x.WriteStartElement("sitemap"); x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?venue"); Query q = new Query(); q.OrderBy = new OrderBy(Venue.Columns.LastPost, OrderBy.OrderDirection.Descending); q.TopRecords = 1; VenueSet bobset = new VenueSet(q); if (bobset.Count > 0) x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat)); x.WriteEndElement(); //sitemap #endregion } if (true) { #region sitemap - event x.WriteStartElement("sitemap"); x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?event"); Query q = new Query(); q.OrderBy = new OrderBy(Event.Columns.LastPost, OrderBy.OrderDirection.Descending); q.TopRecords = 1; EventSet bobset = new EventSet(q); if (bobset.Count > 0) x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat)); x.WriteEndElement(); //sitemap #endregion } if (true) { #region sitemap - thread x.WriteStartElement("sitemap"); x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?thread"); Query q = new Query(); q.QueryCondition = new And( new Q(Thread.Columns.Private, false), new Q(Thread.Columns.PrivateGroup, false), new Q(Thread.Columns.GroupPrivate, false) ); q.OrderBy = new OrderBy(Thread.Columns.LastPost, OrderBy.OrderDirection.Descending); q.TopRecords = 1; ThreadSet bobset = new ThreadSet(q); if (bobset.Count > 0) x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat)); x.WriteEndElement(); //sitemap #endregion } if (true) { #region sitemap - photo x.WriteStartElement("sitemap"); x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?photo"); Query q = new Query(); q.QueryCondition = Photo.EnabledQueryCondition; q.OrderBy = new OrderBy(Photo.Columns.EnabledDateTime, OrderBy.OrderDirection.Descending); q.TopRecords = 1; PhotoSet bobset = new PhotoSet(q); if (bobset.Count > 0) x.WriteElementString("lastmod", bobset[0].EnabledDateTime.ToString(dateFormat)); x.WriteEndElement(); //sitemap #endregion } if (true) { #region sitemap - usr x.WriteStartElement("sitemap"); x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?usr"); x.WriteEndElement(); //sitemap #endregion } if (true) { #region sitemap - article x.WriteStartElement("sitemap"); x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?article"); Query q = new Query(); q.QueryCondition = Article.EnabledQueryCondition; q.OrderBy = new OrderBy(Article.Columns.EnabledDateTime, OrderBy.OrderDirection.Descending); q.TopRecords = 1; ArticleSet bobset = new ArticleSet(q); if (bobset.Count > 0) x.WriteElementString("lastmod", bobset[0].EnabledDateTime.ToString(dateFormat)); x.WriteEndElement(); //sitemap #endregion } if (true) { #region sitemap - comp x.WriteStartElement("sitemap"); x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?comp"); x.WriteEndElement(); //sitemap #endregion } if (true) { #region sitemap - brand x.WriteStartElement("sitemap"); x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?brand"); Query q = new Query(); q.OrderBy = new OrderBy(Brand.Columns.LastPost, OrderBy.OrderDirection.Descending); q.TopRecords = 1; BrandSet bobset = new BrandSet(q); if (bobset.Count > 0) x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat)); x.WriteEndElement(); //sitemap #endregion } if (true) { #region sitemap - group x.WriteStartElement("sitemap"); x.WriteElementString("loc", "http://www.dontstayin.com/sitemapxml?group"); Query q = new Query(); q.QueryCondition = new And( new Q(Group.Columns.BrandK, 0), new Q(Group.Columns.PrivateGroupPage, false)); q.OrderBy = new OrderBy(Group.Columns.LastPost, OrderBy.OrderDirection.Descending); q.TopRecords = 1; GroupSet bobset = new GroupSet(q); if (bobset.Count > 0) x.WriteElementString("lastmod", bobset[0].LastPost.Value.ToString(dateFormat)); x.WriteEndElement(); //sitemap #endregion } x.WriteEndElement(); //sitemapindex #endregion } else { #region urlset x.WriteStartElement("urlset"); x.WriteAttributeString("xmlns", "http://www.google.com/schemas/sitemap/0.84"); #region Countries if (Request.QueryString[0].Equals("country")) { if (true) { #region url x.WriteStartElement("url"); x.WriteElementString("loc", "http://www.dontstayin.com/"); Query q = new Query(); q.QueryCondition = new And( new Q(Thread.Columns.Private, false), new Q(Thread.Columns.PrivateGroup, false), new Q(Thread.Columns.GroupPrivate, false) ); q.OrderBy = new OrderBy(Thread.Columns.LastPost, OrderBy.OrderDirection.Descending); q.TopRecords = 1; ThreadSet bobset = new ThreadSet(q); if (bobset.Count > 0) x.WriteElementString("lastmod", bobset[0].LastPost.ToString(dateFormat)); x.WriteElementString("changefreq", "hourly"); x.WriteEndElement(); //url #endregion } if (true) { Query q = new Query(); q.QueryCondition = new Q(Country.Columns.TotalEvents, QueryOperator.GreaterThan, 0); q.OrderBy = new OrderBy(Country.Columns.TotalEvents, OrderBy.OrderDirection.Descending); q.Columns = new ColumnSet(Country.LinkColumns, Country.Columns.TotalEvents); if (Vars.DevEnv) q.TopRecords = 10; CountrySet bobset = new CountrySet(q); for (int i = 0; i < bobset.Count; i++) { Country p = bobset[i]; #region url x.WriteStartElement("url"); x.WriteElementString("loc", "http://www.dontstayin.com" + p.Url()); if (p.TotalEvents > 100) x.WriteElementString("changefreq", "hourly"); else if (p.TotalEvents > 20) x.WriteElementString("changefreq", "daily"); else if (p.TotalEvents > 10) x.WriteElementString("changefreq", "weekly"); else x.WriteElementString("changefreq", "monthly"); x.WriteEndElement(); //url #endregion bobset.Kill(i); } } } #endregion #region Places if (Request.QueryString[0].Equals("place")) { Query q = new Query(); q.QueryCondition = new Or( new Q(Place.Columns.TotalComments, QueryOperator.GreaterThan, 0), new Q(Place.Columns.TotalEvents, QueryOperator.GreaterThan, 0)); q.OrderBy = new OrderBy(Place.Columns.TotalComments, OrderBy.OrderDirection.Descending); q.Columns = new ColumnSet(Place.LinkColumns, Place.Columns.LastPost); if (Vars.DevEnv) q.TopRecords = 10; else q.TopRecords = 40000; PlaceSet bobset = new PlaceSet(q); for (int i = 0; i < bobset.Count; i++) { Place p = bobset[i]; #region url x.WriteStartElement("url"); x.WriteElementString("loc", "http://www.dontstayin.com" + p.Url()); if (p.LastPost != DateTime.MinValue) { x.WriteElementString("lastmod", p.LastPost.ToString(dateFormat)); TimeSpan ts = DateTime.Now.Subtract(p.LastPost); if (ts.TotalHours < 24) x.WriteElementString("changefreq", "hourly"); else if (ts.TotalDays < 7) x.WriteElementString("changefreq", "daily"); else if (ts.TotalDays < 30) x.WriteElementString("changefreq", "weekly"); else x.WriteElementString("changefreq", "monthly"); } else x.WriteElementString("changefreq", "monthly"); x.WriteEndElement(); //url #endregion bobset.Kill(i); } } #endregion #region Venues if (Request.QueryString[0].Equals("venue")) { Query q = new Query(); q.OrderBy = new OrderBy(Venue.Columns.TotalEvents, OrderBy.OrderDirection.Descending); q.Columns = new ColumnSet(Venue.LinkColumns, Venue.Columns.LastPost, Venue.Columns.TotalEvents); if (Vars.DevEnv) q.TopRecords = 10; else q.TopRecords = 40000; VenueSet bobset = new VenueSet(q); for (int i = 0; i < bobset.Count; i++) { Venue v = bobset[i]; #region url x.WriteStartElement("url"); x.WriteElementString("loc", "http://www.dontstayin.com" + v.Url()); if (v.LastPost != DateTime.MinValue) { x.WriteElementString("lastmod", v.LastPost.ToString(dateFormat)); TimeSpan ts = DateTime.Now.Subtract(v.LastPost); if (ts.TotalHours < 24) x.WriteElementString("changefreq", "hourly"); else if (ts.TotalDays < 7) x.WriteElementString("changefreq", "daily"); else if (ts.TotalDays < 30) x.WriteElementString("changefreq", "weekly"); else x.WriteElementString("changefreq", "monthly"); } else if (v.TotalEvents > 10) x.WriteElementString("changefreq", "weekly"); else x.WriteElementString("changefreq", "monthly"); x.WriteEndElement(); //url #endregion bobset.Kill(i); } } #endregion #region Events if (Request.QueryString[0].Equals("event")) { Query q = new Query(); q.OrderBy = new OrderBy(Event.Columns.LastPost, OrderBy.OrderDirection.Descending); q.Columns = new ColumnSet(Event.LinkColumns, Event.Columns.LastPost, Event.Columns.DateTime); if (Vars.DevEnv) q.TopRecords = 10; else q.TopRecords = 40000; EventSet bobset = new EventSet(q); for (int i = 0; i < bobset.Count; i++) { Event ev = bobset[i]; #region url x.WriteStartElement("url"); x.WriteElementString("loc", "http://www.dontstayin.com" + ev.Url()); if (ev.LastPost != DateTime.MinValue) { x.WriteElementString("lastmod", ev.LastPost.ToString(dateFormat)); TimeSpan ts = DateTime.Now.Subtract(ev.LastPost); if (ts.TotalHours < 24) x.WriteElementString("changefreq", "hourly"); else if (ts.TotalDays < 7) x.WriteElementString("changefreq", "daily"); else if (ts.TotalDays < 30) x.WriteElementString("changefreq", "weekly"); else x.WriteElementString("changefreq", "monthly"); } else x.WriteElementString("changefreq", "monthly"); x.WriteEndElement(); //url #endregion bobset.Kill(i); } } #endregion #region Threads if (Request.QueryString[0].Equals("thread")) { Query q = new Query(); q.QueryCondition = new And( new Q(Thread.Columns.Private, false), new Q(Thread.Columns.PrivateGroup, false), new Q(Thread.Columns.GroupPrivate, false) ); q.Columns = new ColumnSet(Thread.Columns.K, Thread.Columns.UrlFragment, Thread.Columns.TotalComments, Thread.Columns.LastPost); q.OrderBy = new OrderBy(Thread.Columns.LastPost, OrderBy.OrderDirection.Descending); if (Vars.DevEnv) q.TopRecords = 10; else q.TopRecords = 40000; ThreadSet bobset = new ThreadSet(q); for (int i = 0; i < bobset.Count; i++) { Thread t = bobset[i]; #region url x.WriteStartElement("url"); if (t.LastPage == 1) x.WriteElementString("loc", "http://www.dontstayin.com" + t.Url()); else x.WriteElementString("loc", "http://www.dontstayin.com" + t.Url("c", t.LastPage.ToString())); x.WriteElementString("lastmod", t.LastPost.ToString(dateFormat)); TimeSpan ts = DateTime.Now.Subtract(t.LastPost); if (ts.TotalHours < 24) x.WriteElementString("changefreq", "hourly"); else if (ts.TotalDays < 7) x.WriteElementString("changefreq", "daily"); else if (ts.TotalDays < 30) x.WriteElementString("changefreq", "weekly"); else x.WriteElementString("changefreq", "monthly"); x.WriteEndElement(); //url #endregion bobset.Kill(i); } } #endregion #region Photos if (Request.QueryString[0].Equals("photo")) { Query q = new Query(); q.QueryCondition = Photo.EnabledQueryCondition; q.Columns = new ColumnSet(Photo.Columns.K, Photo.Columns.UrlFragment, Photo.Columns.EventK, Photo.Columns.ArticleK); q.OrderBy = new OrderBy(Photo.Columns.EnabledDateTime, OrderBy.OrderDirection.Descending); if (Vars.DevEnv) q.TopRecords = 10; else q.TopRecords = 50000; PhotoSet bobset = new PhotoSet(q); for (int i = 0; i < bobset.Count; i++) { Photo p = bobset[i]; #region url x.WriteStartElement("url"); x.WriteElementString("loc", "http://www.dontstayin.com" + p.Url()); x.WriteEndElement(); //url #endregion bobset.Kill(i); } } #endregion #region Usrs if (Request.QueryString[0].Equals("usr")) { Query q = new Query(); q.QueryCondition = new And( new Q(Usr.Columns.IsSkeleton, false), new Q(Usr.Columns.IsEmailVerified, true), new Or( new Q(Usr.Columns.Pic, QueryOperator.NotEqualTo, Guid.Empty), new Q(Usr.Columns.CommentCount, QueryOperator.NotEqualTo, 0) ) ); q.Columns = new ColumnSet(Usr.Columns.NickName); q.OrderBy = new OrderBy(Usr.Columns.DateTimeLastPageRequest, OrderBy.OrderDirection.Descending); if (Vars.DevEnv) q.TopRecords = 10; else q.TopRecords = 50000; UsrSet bobset = new UsrSet(q); for (int i = 0; i < bobset.Count; i++) { Usr u = bobset[i]; #region url x.WriteStartElement("url"); x.WriteElementString("loc", "http://www.dontstayin.com" + u.Url()); x.WriteEndElement(); //url #endregion bobset.Kill(i); } } #endregion #region Articles if (Request.QueryString[0].Equals("article")) { Query q = new Query(); q.QueryCondition = Article.EnabledQueryCondition; q.Columns = new ColumnSet(Article.Columns.UrlFragment, Article.Columns.ParentObjectK, Article.Columns.ParentObjectType, Article.Columns.K); q.OrderBy = new OrderBy(Article.Columns.EnabledDateTime, OrderBy.OrderDirection.Descending); if (Vars.DevEnv) q.TopRecords = 10; else q.TopRecords = 50000; ArticleSet bobset = new ArticleSet(q); for (int i = 0; i < bobset.Count; i++) { Article a = bobset[i]; #region url x.WriteStartElement("url"); x.WriteElementString("loc", "http://www.dontstayin.com" + a.Url()); x.WriteEndElement(); //url #endregion bobset.Kill(i); } } #endregion #region Competitions if (Request.QueryString[0].Equals("comp")) { Query q = new Query(); q.QueryCondition = new Q(Comp.Columns.Status, Comp.StatusEnum.Enabled); q.Columns = new ColumnSet(Comp.Columns.K); q.OrderBy = new OrderBy(Comp.Columns.DateTimeClose, OrderBy.OrderDirection.Descending); if (Vars.DevEnv) q.TopRecords = 10; else q.TopRecords = 50000; CompSet bobset = new CompSet(q); for (int i = 0; i < bobset.Count; i++) { Comp c = bobset[i]; #region url x.WriteStartElement("url"); x.WriteElementString("loc", "http://www.dontstayin.com" + c.Url()); x.WriteEndElement(); //url #endregion bobset.Kill(i); } } #endregion #region Brands if (Request.QueryString[0].Equals("brand")) { Query q = new Query(); q.OrderBy = new OrderBy(Brand.Columns.LastPost, OrderBy.OrderDirection.Descending); q.Columns = new ColumnSet(Brand.LinkColumns, Brand.Columns.LastPost); if (Vars.DevEnv) q.TopRecords = 10; else q.TopRecords = 40000; BrandSet bobset = new BrandSet(q); for (int i = 0; i < bobset.Count; i++) { Brand b = bobset[i]; #region url x.WriteStartElement("url"); x.WriteElementString("loc", "http://www.dontstayin.com" + b.Url()); if (b.LastPost > DateTime.MinValue) { x.WriteElementString("lastmod", b.LastPost.ToString(dateFormat)); TimeSpan ts = DateTime.Now.Subtract(b.LastPost); if (ts.TotalHours < 24) x.WriteElementString("changefreq", "hourly"); else if (ts.TotalDays < 7) x.WriteElementString("changefreq", "daily"); else if (ts.TotalDays < 30) x.WriteElementString("changefreq", "weekly"); else x.WriteElementString("changefreq", "monthly"); } else x.WriteElementString("changefreq", "monthly"); x.WriteEndElement(); //url #endregion bobset.Kill(i); } } #endregion #region Groups if (Request.QueryString[0].Equals("group")) { Query q = new Query(); q.QueryCondition = new And( new Q(Group.Columns.BrandK, 0), new Q(Group.Columns.PrivateGroupPage, false)); q.OrderBy = new OrderBy(Group.Columns.LastPost, OrderBy.OrderDirection.Descending); q.Columns = new ColumnSet(Group.Columns.BrandK, Group.Columns.UrlName, Group.Columns.LastPost); if (Vars.DevEnv) q.TopRecords = 10; else q.TopRecords = 40000; GroupSet bobset = new GroupSet(q); for (int i = 0; i < bobset.Count; i++) { Group g = bobset[i]; #region url x.WriteStartElement("url"); x.WriteElementString("loc", "http://www.dontstayin.com" + g.Url()); if (g.LastPost.HasValue && g.LastPost > DateTime.MinValue) { x.WriteElementString("lastmod", g.LastPost.Value.ToString(dateFormat)); TimeSpan ts = DateTime.Now.Subtract(g.LastPost.Value); if (ts.TotalHours < 24) x.WriteElementString("changefreq", "hourly"); else if (ts.TotalDays < 7) x.WriteElementString("changefreq", "daily"); else if (ts.TotalDays < 30) x.WriteElementString("changefreq", "weekly"); else x.WriteElementString("changefreq", "monthly"); } else x.WriteElementString("changefreq", "monthly"); x.WriteEndElement(); //url #endregion bobset.Kill(i); } } #endregion x.WriteEndElement(); //urlset #endregion } x.Flush(); x.Close(); Response.End(); }
private void PanelLocation_Load(object sender, System.EventArgs e) { PanelLocationSaveP.Visible = IsEdit; PanelLocationBackButton.Visible = !(IsEdit && CurrentGroup.BrandK > 0); if (!Page.IsPostBack) { Query q = new Query(); q.Columns = new ColumnSet(Country.Columns.K, Country.Columns.Name); q.OrderBy = new OrderBy(Country.Columns.Name); q.QueryCondition = new Q(Country.Columns.Enabled, true); CountrySet cs = new CountrySet(q); LocationCountryDropDown.DataTextField = "Name"; LocationCountryDropDown.DataValueField = "K"; LocationCountryDropDown.DataSource = cs; LocationCountryDropDown.DataBind(); if (IsEdit) { LocationTypeNone.Checked = CurrentGroup.CountryK == 0; LocationTypeCountry.Checked = CurrentGroup.CountryK != 0 && CurrentGroup.PlaceK == 0; LocationTypePlace.Checked = CurrentGroup.PlaceK != 0; if (CurrentGroup.CountryK != 0 && LocationCountryDropDown.Items.FindByValue(CurrentGroup.CountryK.ToString()) != null) LocationCountryDropDown.SelectedValue = CurrentGroup.CountryK.ToString(); else if (Country.Current.K != 0 && LocationCountryDropDown.Items.FindByValue(Country.Current.K.ToString()) != null) LocationCountryDropDown.SelectedValue = Country.Current.K.ToString(); else LocationCountryDropDown.SelectedValue = "224"; } else { if (Country.Current.K != 0 && LocationCountryDropDown.Items.FindByValue(Country.Current.K.ToString()) != null) LocationCountryDropDown.SelectedValue = Country.Current.K.ToString(); else LocationCountryDropDown.SelectedValue = "224"; } UpdateLocationDropDowns(); } }
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())); }
static Place getPlaceFromString(string homeTownName, ref bool goodMatch) { if (homeTownName.Trim().Length == 0) return null; string placeName = ""; string countryName = ""; Place homePlace = null; Country homeCountry = null; #region split into country and place name if (homeTownName.Length > 0 && homeTownName.Contains(",")) { placeName = homeTownName.Substring(0, homeTownName.LastIndexOf(',')).Trim(); countryName = homeTownName.Substring(homeTownName.LastIndexOf(',') + 1).Trim(); } else { placeName = homeTownName; } #endregion if (countryName.Length > 0) { #region get country by name CountrySet csName = new CountrySet( new Query( new Q(Country.Columns.Name, countryName.Trim()) ) ); if (csName.Count > 0) { homeCountry = csName[0]; } #endregion else { #region get country by friendly name (abbreviation) CountrySet csFriendlyName = new CountrySet( new Query( new Q(Country.Columns.FriendlyName, countryName.Trim()) ) ); if (csFriendlyName.Count > 0) { homeCountry = csFriendlyName[0]; } #endregion } } #region if we haven't found a country yet, use the IPcountry if (homeCountry == null) { try { homeCountry = new Country(IpCountry.ClientCountryK()); } catch { homeCountry = new Country(224); } } #endregion if (placeName.Length > 0) { #region lookup enabled places in the home country PlaceSet psNameWithCountry = new PlaceSet( new Query( new And( new Q(Place.Columns.Name, placeName.Trim()), new Q(Place.Columns.CountryK, homeCountry.K), new Q(Place.Columns.Enabled, true) ) ) ); if (psNameWithCountry.Count > 0) { homePlace = psNameWithCountry[0]; goodMatch = true; } #endregion else { #region lookup non-enabled places and find the nearest enabled place PlaceSet psNameWithCountryNotEnalbed = new PlaceSet( new Query( new And( new Q(Place.Columns.Name, placeName.Trim()), new Q(Place.Columns.CountryK, homeCountry.K) ) ) ); if (psNameWithCountryNotEnalbed.Count > 0) { PlaceSet ps = new PlaceSet( new Query( new Q(Place.Columns.Enabled, true), psNameWithCountryNotEnalbed[0].NearestPlacesOrderBy, 1 ) ); if (ps.Count > 0) { homePlace = ps[0]; goodMatch = true; } } #endregion else { #region lookup global enabled places by name PlaceSet psName = new PlaceSet( new Query( new And( new Q(Place.Columns.Name, placeName.Trim()), new Q(Place.Columns.Enabled, true) ), new OrderBy(Place.Columns.Population, OrderBy.OrderDirection.Descending), 1 ) ); if (psName.Count > 0) { homePlace = psName[0]; } #endregion else { #region lookup global non-enabled places and find the nearest enabled place PlaceSet psNameNotEnalbed = new PlaceSet( new Query( new Q(Place.Columns.Name, placeName.Trim()) ) ); if (psNameNotEnalbed.Count > 0) { PlaceSet ps = new PlaceSet( new Query( new Q(Place.Columns.Enabled, true), psNameNotEnalbed[0].NearestPlacesOrderBy, 1 ) ); if (ps.Count > 0) { homePlace = ps[0]; } } #endregion } } } } #region if we haven't found a place yet, use the capital (or largest enabled place) from the home country. If all fails, use London. if (homePlace == null) { if (homeCountry != null) { homePlace = homeCountry.GetCapitalOrLargestEnabledPlace(); } } if (homePlace == null) homePlace = new Place(1); #endregion return homePlace; }