/// <summary> /// Shows Tower Adverts if present /// </summary> private List <REIQ.Entities.Advertisement> GetBannerAdvertisements() { //banner ad (it includes suburbs ad and displayed randomly.if no booking for suburbs or surrounding suburbs then region ad will come) String region = String.Empty; REIQ.Entities.Suburb suburb = new REIQ.Entities.Suburb(); List <REIQ.Entities.Advertisement> ads = new List <REIQ.Entities.Advertisement>(); //Determine if we are searching by region var matchingItems = REIQ.Access.Suburb.ListMatching(ResetKeywordIfDefault(ParamKeyword).Trim()); if (matchingItems != null && matchingItems.Regions != null && matchingItems.Regions.Count() > 0) { region = matchingItems.Regions[0]; } //If we are searching by region if (!String.IsNullOrEmpty(region)) { //Get banner ads per region we are searching ads = REIQ.Access.Advertisement.GetBannerAdsByRegion(REIQ.Access.Advertisement.GetCategoryParam(ParamSearchType.ToString()), region); //If there are no banner ads per region we are searching -> then get the random banner ad assigned to any suburb of that region if (ads.Count == 0) { //Get suburbIDs of current region List <int> suburbIDs = REIQ.Access.Suburb.ListIdsOfSuburbsByRegion(region); foreach (Int32 suburbID in suburbIDs) { ads.AddRange(REIQ.Access.Advertisement.GetBannerAdsBySuburb(REIQ.Access.Advertisement.GetCategoryParam(ParamSearchType.ToString()), suburbID)); if (ads.Count >= 2) { break; } } } } else { //Try to Determine current Suburb suburb = REIQ.Access.Suburb.TryGetSuburbFromSearchString(ResetKeywordIfDefault(ParamKeyword).Trim()); //If we are searching by suburb if (suburb != null) { //get banner ads per suburb we are searching ads = REIQ.Access.Advertisement.GetBannerAdsBySuburb(REIQ.Access.Advertisement.GetCategoryParam(ParamSearchType.ToString()), suburb.sID); //if we got no banner ads per suburb we searching -> check if we have a banner ad per region of current suburb if (ads.Count == 0) { ads = REIQ.Access.Advertisement.GetBannerAdsByRegion(REIQ.Access.Advertisement.GetCategoryParam(ParamSearchType.ToString()), suburb.region); } } } return(ads); }
protected void Page_Load(object sender, EventArgs e) { try { Property = REIQ.Access.Property.GetFromPropertyId(this.PropertyId); if (Property != null) { Suburb = REIQ.Access.Suburb.GetFromName(Property.suburb); if (!IsPostBack) { //Suburb Chart stuff ch = new ChartClass(); ch.intChartRange = Convert.ToInt32("4"); cboChartType.SelectedValue = ChartType.ToString(); if (Suburb != null) { DataTable dtsuburbChart = ch.GetSubrub("any", Suburb.name, Suburb.postcode == null ? "0" : Suburb.postcode.ToString()); if (dtsuburbChart.Rows.Count > 0) { chartwork(int.Parse(dtsuburbChart.Rows[0]["suburbid"].ToString()), dtsuburbChart.Rows[0]["suburbname"].ToString()); } } } } } catch (Exception ex) { AutoMail.sendErrorMail(ex); } }
protected void Page_Load(object sender, EventArgs e) { try { Suburb = REIQ.Access.Suburb.GetFromName(SuburbName); } catch (Exception ex) { AutoMail.sendErrorMail(ex); } }
/// <summary> /// Shows Tower Adverts if present /// </summary> private String GetTowerAdvertisements() { //tower ad (it includes suburbs ad and displayed randomly.if no booking for suburbs or surrounding suburbs then region ad will come) string strtowerad = String.Empty; String region = String.Empty; REIQ.Entities.Suburb suburb = new REIQ.Entities.Suburb(); List <REIQ.Entities.Advertisement> ads = new List <REIQ.Entities.Advertisement>(); //Determine if we are searching by region var matchingItems = REIQ.Access.Suburb.ListMatching(ResetKeywordIfDefault(ParamKeyword).Trim()); if (matchingItems != null && matchingItems.Regions != null && matchingItems.Regions.Count() > 0) { region = matchingItems.Regions[0]; } //If we are searching by region if (!String.IsNullOrEmpty(region)) { //Get tower ads per region we are searching ads = REIQ.Access.Advertisement.GetTowerAdsByRegion(REIQ.Access.Advertisement.GetCategoryParam(ParamSearchType.ToString()), region); //If there are no tower ads per region we are searching -> then get the random tower ad assigned to any suburb of that region if (ads.Count == 0) { //Get suburbIDs of current region List <int> suburbIDs = REIQ.Access.Suburb.ListIdsOfSuburbsByRegion(region); foreach (Int32 suburbID in suburbIDs) { ads.AddRange(REIQ.Access.Advertisement.GetTowerAdsBySuburb(REIQ.Access.Advertisement.GetCategoryParam(ParamSearchType.ToString()), suburbID)); } } } else { //Try to Determine current Suburb suburb = REIQ.Access.Suburb.TryGetSuburbFromSearchString(ResetKeywordIfDefault(ParamKeyword).Trim()); //If we are searching by suburb if (suburb != null) { //get tower ads per suburb we are searching ads = REIQ.Access.Advertisement.GetTowerAdsBySuburb(REIQ.Access.Advertisement.GetCategoryParam(ParamSearchType.ToString()), suburb.sID); //if we got no tower ads per suburb we searching -> check if we have a tower ad per region of current suburb if (ads.Count == 0) { ads = REIQ.Access.Advertisement.GetTowerAdsByRegion(REIQ.Access.Advertisement.GetCategoryParam(ParamSearchType.ToString()), suburb.region); } } } if (ads.Count > 0) { REIQ.Entities.Advertisement advert = new REIQ.Entities.Advertisement(); //Init reiqAdminUrl needed for showing ads images String reiqAdminURL = "http://psadmin.reiq.com/"; if (ConfigurationManager.AppSettings["REIQAdmin"] != null) { reiqAdminURL = ConfigurationManager.AppSettings["REIQAdmin"].ToString(); } //If we found one tower ad - just show it if (ads.Count == 1) { advert = ads[0]; } else //show random one { Random RandomClass = new Random(); int rndNo = RandomClass.Next(ads.Count); advert = ads[rndNo]; } if (!String.IsNullOrEmpty(advert.link)) { strtowerad = "<a href='/hitadvert.aspx?adid=" + DataUtility.Encrypt(advert.AdId.ToString()) + "&url=" + advert.link + "' target='_blank' ><img alt='" + advert.alttext + "' title='" + advert.alttext + "' border='0' src='" + reiqAdminURL + "advimg/" + advert.AdId.ToString() + "/" + advert.imgurl + "'/></a><br><br>"; } else { strtowerad = "<img alt='" + advert.alttext + "' title='" + advert.alttext + "' border='0' src='" + reiqAdminURL + "advimg/" + advert.AdId.ToString() + "/" + advert.imgurl + "'/><br><br>"; } } return(HttpUtility.HtmlDecode(strtowerad)); }
protected void Page_Load(object sender, EventArgs e) { try { Suburb = REIQ.Access.Suburb.GetFromName(SuburbName); if (!IsPostBack) { //Binding Suburbs //DataTable dtsuburb = ch.GetAllSubrubWithdesc("1000"); //ahc.connection.Close(); //for (int i = 0; i < dtsuburb.Rows.Count; i++) //{ // cboSuburbInfo.Items.Add(new ListItem(dtsuburb.Rows[i]["name"].ToString() + ", " + dtsuburb.Rows[i]["postcode"].ToString(), dtsuburb.Rows[i]["sid"].ToString())); //} //cboSuburbInfo.DataSource = REIQ.Access.Suburb.GetAllSuburbsByTop(1000); //cboSuburbInfo.Items.Insert(0, new ListItem("-Select Suburb-", "")); //cboSuburbInfo.DataBind(); //Bedrooms setup cboSuburbInfo.Items.Add(new ListItem("Select Suburb", "")); foreach (REIQ.Entities.Suburb suburb in REIQ.Access.Suburb.GetAllSuburbsByTop(2000)) { cboSuburbInfo.Items.Add(new ListItem(suburb.name, suburb.name)); } cboSuburbInfo.DataBind(); cboSuburbInfo.SelectedValue = SuburbName; //if (!String.IsNullOrEmpty(Request.QueryString["su"]) && Request.QueryString["postcode"] != null) //{ // strSearchSuburb = Request.QueryString["su"].ToString(); // strSearchPostcode = Request.QueryString["postcode"].ToString(); //} //else //{ // //cboSuburbInfo.SelectedIndex = 1; // //DataRow[] drsuburb = dtsuburb.Select("sid=" + cboSuburbInfo.SelectedValue); // //strSearchSuburb = drsuburb[0]["name"].ToString(); // //strSearchPostcode = drsuburb[0]["postcode"].ToString(); //} //Suburb Chart stuff ch = new ChartClass(); ch.intChartRange = Convert.ToInt32("4"); cboChartType.SelectedValue = ChartType.ToString(); if (Suburb != null) { DataTable dtsuburbChart = ch.GetSubrub("any", Suburb.name, Suburb.postcode == null ? "0" : Suburb.postcode.ToString()); if (dtsuburbChart.Rows.Count > 0) { chartwork(int.Parse(dtsuburbChart.Rows[0]["suburbid"].ToString()), dtsuburbChart.Rows[0]["suburbname"].ToString()); } } } } catch (Exception ex) { AutoMail.sendErrorMail(ex); } }
protected override void OnPreRender(EventArgs e) { if (!IsPostBack) { //Does not show Featured Properties for Agency if (ParamAgencyId > 0) { this.Visible = false; return; } FoundProperties = RetrievePropertyIds(); if (FoundProperties == null) { this.Visible = false; return; } //Try to Determine current Suburb REIQ.Entities.Suburb suburb = REIQ.Access.Suburb.TryGetSuburbFromSearchString(ResetKeywordIfDefault(ParamKeyword).Trim()); //If we could not take suburb from search string then //get first available suburb from Search Results if (suburb == null) { foreach (Int32 propertyId in FoundProperties.Take(20)) { suburb = REIQ.Access.Suburb.GetFromPropertyId(propertyId); if (suburb != null) { break; } } } if (suburb != null) { //Get data from TopSpot table based on suburb info List <REIQ.Entities.topspot> topspots = REIQ.Access.TopSpot.Select(suburb.name, GetCategoryParam(), suburb.postcode == null ? String.Empty : suburb.postcode.ToString(), DateTime.Now.ToString("yyyy/MM/dd"), DateTime.Now.ToString("yyyy/MM/dd")); //TopSpot if (topspots.Count() > 0) { //I guess we need to get two topspots and get 1 property per topspot... So... List <REIQ.Entities.topspot> chosenTopspots = new List <REIQ.Entities.topspot>(); if (topspots.Count() == 1)//We have only one TopSpot booked - so just get properties for that topspot { chosenTopspots.Add(topspots.First()); chosenTopspots.Add(topspots.First()); } else//If we have many TopSpots - take random two { Random RandomClass = new Random(); int rndNo1 = RandomClass.Next(topspots.Count()); int rndNo2 = RandomClass.Next(topspots.Count()); while (rndNo1 == rndNo2) { rndNo2 = RandomClass.Next(topspots.Count()); } chosenTopspots.Add(topspots.ToList()[rndNo1]); chosenTopspots.Add(topspots.ToList()[rndNo2]); } foreach (REIQ.Entities.topspot topspot in chosenTopspots) { //Get all closest suburbs IEnumerable <KeyValuePair <String, String> > surroundingSuburbs = REIQ.Access.Suburb.ListSurroundingSuburbs(suburb.name, suburb.postcode == null ? 0 : (Int32)suburb.postcode); List <String> searchsuburbs = new List <string>(); List <String> searchpostcode = new List <string>(); //Forming list of surroundining suburbs and postcodes foreach (KeyValuePair <String, String> surroundingSuburb in surroundingSuburbs) { if (!searchsuburbs.Contains(surroundingSuburb.Key)) { searchsuburbs.Add(surroundingSuburb.Key); } if (!searchpostcode.Contains(surroundingSuburb.Value) && !String.IsNullOrEmpty(surroundingSuburb.Value)) { searchpostcode.Add(surroundingSuburb.Value); } } //Adding current chosen suburb postcode and name to params if (!searchsuburbs.Contains(suburb.name)) { searchsuburbs.Add(suburb.name); } string currentSuburbPostcode = suburb.postcode == null ? String.Empty : suburb.postcode.ToString(); if (!searchpostcode.Contains(currentSuburbPostcode) && !String.IsNullOrEmpty(currentSuburbPostcode)) { searchpostcode.Add(currentSuburbPostcode); } string status = "sa"; List <String> type = new List <string>(); if (topspot.category == "residentialsales") { status = "sa"; type.AddRange(new List <string>() { "Acreage/Rural", "Apartment/Unit", "Block of Units", "House", "land", "Townhouse/Villa" }); } else if (topspot.category == "residentialrentals") { status = "ra"; type.AddRange(new List <string>() { "Acreage/Rural", "Apartment/Unit", "Block of Units", "House", "land", "Townhouse/Villa" }); } else if (topspot.category == "commercialsales") { status = "sa"; type.AddRange(new List <string>() { "Commercial" }); } else if (topspot.category == "commercialrentals") { status = "ra"; type.AddRange(new List <string>() { "Commercial" }); } else if (topspot.category == "businesssales") { status = "sa"; type.AddRange(new List <string>() { "Business" }); } else if (topspot.category == "ruralsales") { status = "sa"; type.AddRange(new List <string>() { "Acreage/Rural" }); } IEnumerable <REIQ.Entities.Property> resultList = new List <REIQ.Entities.Property>(); if (topspot.options == "pid") { resultList = REIQ.Access.Property.GetFeaturedProperties(topspot.acid.ToString(), status, searchsuburbs, searchpostcode, String.Empty, topspot.optionsPid == null ? String.Empty : topspot.optionsPid.ToString(), type); } else if (topspot.options == "agent") { resultList = REIQ.Access.Property.GetFeaturedProperties(topspot.acid.ToString(), status, searchsuburbs, searchpostcode, topspot.optionsAid == null ? String.Empty : topspot.optionsAid.ToString(), String.Empty, type); } else if (topspot.options == "office") { resultList = REIQ.Access.Property.GetFeaturedProperties(topspot.acid.ToString(), status, searchsuburbs, searchpostcode, String.Empty, String.Empty, type); } if (resultList.Count() > 0) { //If we have 1 property - then just show it //Else take random property from list if (resultList.Count() == 1) { if (!FinalList.Contains(resultList.First())) { FinalList.Add(resultList.First()); } } else { Random RandomClass = new Random(); int rndNo1 = RandomClass.Next(resultList.Count()); while (FinalList.Any(s => s.pID == resultList.ToList()[rndNo1].pID)) { rndNo1 = RandomClass.Next(resultList.Count()); } FinalList.Add(resultList.ToList()[rndNo1]); } } } rptProperties.DataSource = FinalList; rptProperties.DataBind(); } } } base.OnPreRender(e); }