protected void Page_Load(object sender, EventArgs e) { InmueblesBLL bllinmuebles = new InmueblesBLL(); ProvinciasBLL bllprovincia = new ProvinciasBLL(); LocalidadesBLL blllocalidades = new LocalidadesBLL(); dt = bllinmuebles.SelectAllInmuebles(); foreach (DataRow dtRow in dt.Rows) { if (dtRow["Latitud"].ToString() == "" || dtRow["Longitud"].ToString() == "") { var id = dtRow["IdInmueble"].ToString(); var direccion = dtRow["Calle"].ToString(); var numero = dtRow["Numero"].ToString(); string idLocalidad = dtRow["idLocalidad"].ToString(); string idprovincia = dtRow["idprovincia"].ToString(); coordinate = getCoordinate(direccion, numero, blllocalidades.GetNombreLocalidad(Convert.ToInt32(idLocalidad)), bllprovincia.GetNombreProvincia(Convert.ToInt32(idprovincia))); bllinmuebles.SetLatitudLongitud(id, coordinate.Latitude, coordinate.Longitude); sumcant++; if (sumcant >= cant) return; } } }
private void createJson() { InmueblesBLL bllinmuebles = new InmueblesBLL(); dt = bllinmuebles.SelectAllInmuebles(); int count = 0; int position = 0; foreach (DataRow dtRow in dt.Rows) { if (dtRow["Latitud"].ToString() != "" && dtRow["Longitud"].ToString() != "") { count++; } } count = 100; string json = "{\"count\":" + count + ",\"photos\":["; foreach (DataRow dtRow in dt.Rows) { if (dtRow["Latitud"].ToString() != "" && dtRow["Longitud"].ToString() != "") { position++; if (position < 99) { json += "{" + "\"mark_id\":\"" + dtRow["IdInmueble"].ToString().Trim() + "\"," + "\"Inmueble_dir\":\"" + dtRow["Calle"].ToString().Trim() + " " + dtRow["Numero"].ToString().Trim() + "\"," + "\"latitude\":" + convert(dtRow["Latitud"].ToString()) + "," + "\"longitude\":" + convert(dtRow["Longitud"].ToString()) + "},"; } else { if (position == 100) { json += "{" + "\"mark_id\":\"" + dtRow["IdInmueble"].ToString().Trim() + "\"," + "\"Inmueble_dir\":\"" + dtRow["Calle"].ToString().Trim() + " " + dtRow["Numero"].ToString().Trim() + "\"," + "\"latitude\":" + convert(dtRow["Latitud"].ToString()) + "," + "\"longitude\":" + convert(dtRow["Longitud"].ToString()) + "}"; } } } } json += "]}"; Response.Clear(); Response.ContentType = "application/json; charset=utf-8"; Response.Write(json); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { InmueblesBLL bllinmuebles = new InmueblesBLL(); dt = bllinmuebles.SelectAllInmuebles(); foreach (DataRow dtRow in dt.Rows) { if (dtRow["Latitud"].ToString() != "" && dtRow["Longitud"].ToString() != "") { json += "{" + dtRow["IdInmueble"].ToString() + "," + dtRow["Calle"].ToString() + "," + dtRow["Numero"].ToString() + "," + dtRow["Latitud"].ToString() + "," + dtRow["Longitud"].ToString() + "},"; } } json += "]"; Response.Clear(); Response.ContentType = "application/json; charset=utf-8"; Response.Write(json); Response.End(); }