Ejemplo n.º 1
0
        static async Task <string> CallLectura(DTOLecturaHub lec)
        {
            using (var cliente = new HttpClient())
            {
                cliente.BaseAddress = new Uri("http://localhost:58143/");
                var content = new StringContent(JsonConvert.SerializeObject(lec), Encoding.UTF8, "application/json");
                var request = await cliente.PostAsync("ActualizacionLocationHub/Create", content);

                return(await request.Content.ReadAsStringAsync());
            }
        }
 public void Create(DTOLecturaHub lec)
 {
     try
     {
         var hubContext = GlobalHost.ConnectionManager.GetHubContext <ActualizacionLocation>();
         hubContext.Clients.All.ActualizarLocation(lec);
     }
     catch
     {
     }
 }
Ejemplo n.º 3
0
        // POST: api/LecturaSensor
        public HttpResponseMessage Post([FromBody] LecturaSensor value)
        {
            if (value != null)
            {
                ListaEventos = BLLectura.AltaLectura(value);
                if (BLLectura.ActualizoLectura(value))
                {
                    DTOLecturaHub lec = new DTOLecturaHub();
                    lec.Lectura     = value;
                    lec.vehiculoRef = BLvehiculo.GetVehiculo(BLSensor.GetSensor(value.SensorRef).VehiculoRef).Id;
                    Task <String> responselec = CallLectura(lec);
                }
                if (!ListaEventos.Count.Equals(0))
                {
                    Vehiculo nuevo = new Vehiculo();
                    nuevo = BLvehiculo.GetVehiculo(ListaEventos.First().VehiculoRef);
                    foreach (Sensor s in nuevo.Lista_Sensores)
                    {
                        if (s.Tipo_Sensor.Equals("G"))
                        {
                            Task <String> response = Call(ListaEventos);
                            EnvioEventoCoord = true;
                        }
                    }
                    if (!EnvioEventoCoord)
                    {
                        Task <String> response = Call(ListaEventos);
                    }
                }

                return(new HttpResponseMessage()
                {
                    Content = new StringContent("200")
                });
            }
            else
            {
                return(new HttpResponseMessage()
                {
                    Content = new StringContent("500")
                });
            }
        }