public static void Main(string[] args) { string mongoUri = Environment.GetEnvironmentVariable("MONGO_URI"); SQLiteConnect.SetupDicts(); MongoDBConnect.SetupConnect(mongoUri); Properties.Settings settings = Properties.Settings.Default; FrontendConnect c = new FrontendConnect(settings.username, settings.pin.ToString(), 1); c.Login(); c.jp.Join(); }
static void Main(string[] args) { PacketDevice selectedDevice = GetDevice(); string mongoUri = Environment.GetEnvironmentVariable("MONGO_URI"); MongoDBConnect.SetupConnect(mongoUri); //Open the device with a 65kB buffer, promiscuous mode, 1s timeout using (PacketCommunicator communicator = selectedDevice.Open(65536, PacketDeviceOpenAttributes.Promiscuous, 1000)) { Console.WriteLine("Waiting for TCP stream to start on {0}", selectedDevice.Description); communicator.SetFilter(filter); // Retrieve the packets communicator.ReceivePackets(0, HandlePacketPort); } }
public KhoaController() { dbconnect = new MongoDBConnect(); khoaCollection = dbconnect.database.GetCollection <KhoaModel>("khoa"); }
public SinhVienController() { dbconnect = new MongoDBConnect(); sinhvienCollection = dbconnect.database.GetCollection <SinhVienModel>("sinhvien"); }
public async Task <JsonResult> Localizar(HomeViewModel model) { Debug.WriteLine(model); //Captura a posição atual e adiciona a lista de pontos Coordenada coordLocal = ObterCoordenadasDaLocalizacao(model.Endereco); var aeroportosProximos = new List <Coordenada>(); aeroportosProximos.Add(coordLocal); //Captura a latitude e longitude locais double lat = Convert.ToDouble(coordLocal.Latitude); double lon = Convert.ToDouble(coordLocal.Longitude); //Testa o tipo de aeroporto que será usado na consulta string tipoAero = ""; if (model.Tipo == TipoAeroporto.Internacionais) { tipoAero = "International"; } if (model.Tipo == TipoAeroporto.Municipais) { tipoAero = "Municipal"; } //Captura o valor da distancia int distancia = model.Distancia * 1000; //Conecta MongoDB MongoDBConnect mongo = new MongoDBConnect(); //Configura o ponto atual no mapa var localizacaoAtual = new GeoJsonPoint <GeoJson2DGeographicCoordinates>( new GeoJson2DGeographicCoordinates(lon, lat) ); // filtro FilterDefinition <Airport> filter; if (string.IsNullOrEmpty(tipoAero)) { filter = Builders <Airport> .Filter.NearSphere(n => n.loc, localizacaoAtual, distancia); } else { filter = Builders <Airport> .Filter.NearSphere(n => n.loc, localizacaoAtual, distancia) & Builders <Airport> .Filter.Eq(x => x.type, tipoAero); } //Captura a lista try { var airports = mongo.Airports.Find(filter).ToListAsync().Result; //Escreve os pontos var coordenadas = airports.Select(s => new Coordenada( s.name, s.loc.Coordinates.Latitude.ToString(), s.loc.Coordinates.Longitude.ToString() )); aeroportosProximos.AddRange(coordenadas); } catch (Exception ex) { throw ex; } return(Json(aeroportosProximos)); }
public HocPhanController() { dbconnect = new MongoDBConnect(); hocphanCollection = dbconnect.database.GetCollection <HocPhanModel>("hocphan"); }