예제 #1
0
        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);
                        }
                    }
                }
            }
        }
예제 #2
0
        public void AddSignal(WiFiSignalWithGeoposition wiFiSignal)
        {
            var arr = new WiFiSignalWithGeoposition[1];

            arr[0] = wiFiSignal;
            AddSignals(arr);
        }
예제 #3
0
        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);
        }
예제 #4
0
 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);
 }