public IEnumerable <WiFiSignalWithGeoposition> GetAllSignals() { string sqlExpression = $@"SELECT * FROM {_dataTable}"; using (var connection = new SqlConnection(_connectionString)) { connection.Open(); var command = new SqlCommand(sqlExpression, connection); using (var reader = command.ExecuteReader()) { if (reader.HasRows) // если есть данные { while (reader.Read()) // построчно считываем данные { var wifiSignal = new WiFiSignalWithGeoposition { BSSID = reader.GetString(0), SSID = reader.GetString(1), Latitude = reader.GetDouble(2), Longitude = reader.GetDouble(3), SignalStrength = reader.GetInt16(4), Encryption = reader.GetString(5), }; yield return(wifiSignal); } } } } }
public void AddSignal(WiFiSignalWithGeoposition wiFiSignal) { var arr = new WiFiSignalWithGeoposition[1]; arr[0] = wiFiSignal; AddSignals(arr); }
public async Task <IEnumerable <WiFiSignalWithGeoposition> > GetAllSignalsAsync() { var list = new List <WiFiSignalWithGeoposition>(); string sqlExpression = $@"SELECT * FROM {_dataTable}"; using (var connection = new SqlConnection(_connectionString)) { await connection.OpenAsync(); var command = new SqlCommand(sqlExpression, connection); using (var reader = await command.ExecuteReaderAsync()) { if (reader.HasRows) // если есть данные { while (await reader.ReadAsync()) // построчно считываем данные { var wifiSignal = new WiFiSignalWithGeoposition { BSSID = reader.GetString(0), SSID = reader.GetString(1), Latitude = reader.GetDouble(2), Longitude = reader.GetDouble(3), SignalStrength = reader.GetInt16(4), Encryption = reader.GetString(5), }; list.Add(wifiSignal); } } } } return(list); }
private SqlCommand AddParameters(SqlCommand command, WiFiSignalWithGeoposition signal) { command.Parameters.AddWithValue("@bssid", signal.BSSID); command.Parameters.AddWithValue("@ssid", signal.SSID); command.Parameters.AddWithValue("@latitude", signal.Latitude.ToString(new CultureInfo("en-US"))); command.Parameters.AddWithValue("@longitude", signal.Longitude.ToString(new CultureInfo("en-US"))); command.Parameters.AddWithValue("@signalStrength", signal.SignalStrength.ToString(new CultureInfo("en-US"))); command.Parameters.AddWithValue("@encryption", signal.Encryption); return(command); }