public void AddEmptyLocationsToQueue(ConcurrentQueue <FactLocation> queue) { using (SQLiteConnection conn = new SQLiteConnection(connectionString)) { conn.Open(); using (SQLiteCommand cmd = new SQLiteCommand("select location from geocode where foundlocation='' and geocodestatus in (3, 8, 9)", conn)) { using (SQLiteDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { FactLocation loc = FactLocation.LookupLocation(reader[0].ToString()); if (!queue.Contains(loc)) { queue.Enqueue(loc); } } } } } }
public void AddEmptyLocationsToQueue(ConcurrentQueue <FactLocation> queue) { if (InstanceConnection.State != ConnectionState.Open) { InstanceConnection.Open(); } using (SqliteCommand cmd = new SqliteCommand("select location from geocode where foundlocation='' and geocodestatus in (3, 8, 9)", InstanceConnection)) { using (SqliteDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { FactLocation loc = FactLocation.LookupLocation(reader[0].ToString()); if (!queue.Contains(loc)) { queue.Enqueue(loc); } } } } InstanceConnection.Close(); }
void GoogleLocationSearch() { if (txtSearch.Text.Length > 0) { FactLocation loc = FactLocation.LookupLocation(txtSearch.Text); if (!loc.IsGeoCoded(false)) // if not geocoded then try database { DatabaseHelper.GetLocationDetails(loc); } if (loc.IsGeoCoded(false)) { FactLocation.CopyLocationDetails(loc, location); SetLocation(); pointUpdated = true; } else { GeoResponse res = GoogleMap.GoogleGeocode(txtSearch.Text, 8); if (res.Status == "OK" && !(res.Results[0].Geometry.Location.Lat == 0 && res.Results[0].Geometry.Location.Long == 0)) { loc.Latitude = res.Results[0].Geometry.Location.Lat; loc.Longitude = res.Results[0].Geometry.Location.Long; Coordinate mpoint = MapTransforms.TransformCoordinate(new Coordinate(loc.Longitude, loc.Latitude)); loc.LongitudeM = mpoint.X; loc.LatitudeM = mpoint.Y; loc.ViewPort = MapTransforms.TransformViewport(res.Results[0].Geometry.ViewPort); loc.GeocodeStatus = res.Results[0].PartialMatch ? FactLocation.Geocode.PARTIAL_MATCH : FactLocation.Geocode.MATCHED; FactLocation.CopyLocationDetails(loc, location); SetLocation(); pointUpdated = true; } else { MessageBox.Show("Google didn't find " + txtSearch.Text, "Failed Google Lookup"); } } } }