Example #1
0
 private void LoadSernsorPlaces()
 {
     try
     {
         using (var db = new pb_TunnelVisualizarDatabaseEntities())
         {
             foreach (var dbSensor in db.sensors)
             {
                 map_viw.Markers.Add(new GMapMarker(new PointLatLng(Convert.ToDouble(dbSensor.position_x), Convert.ToDouble(dbSensor.position_y)))
                 {
                     Shape = getRectangle.rectangle(Brushes.Green)
                 });
             }
         }
     }
     catch (Exception e)
     {
         SystemConsole.setConsoleTxtThreadSafe(e.Message);
     }
 }
 private void dataUpdaterFunction()
 {
     try
     {
         while (true)
         {
             this.container.Dispatcher.Invoke((Action)(() =>
             {
                 using (var db = new pb_TunnelVisualizarDatabaseEntities())
                 {
                     this._sensor = db.sensors.Find(this._sensor.iddata);
                     if (this._sensor.data_waterFlow.Count() > 0)
                     {
                         this._dataWaterFlow = this._sensor.data_waterFlow.Last();
                         this.flow_rate_label.Content = this._dataWaterFlow.data == null
                             ? "null"
                             : this._dataWaterFlow.data.ToString();
                         try
                         {
                             if (Convert.ToDouble(this._dataWaterFlow.data) <= Convert.ToDouble(this.flow_rate_label_meter.Text))
                             {
                                 this.Card.Background = Brushes.Red;
                                 this.flag_1 = false;
                             }
                             else
                             {
                                 flag_1 = true;
                                 if (flag_1 && flag_2)
                                 {
                                     this.Card.Background = Brushes.WhiteSmoke;
                                 }
                             }
                         }
                         catch (Exception e)
                         {
                         }
                     }
                     if (this._sensor.data_waterLavel.Count() > 0)
                     {
                         this._dataWaterLavel = this._sensor.data_waterLavel.Last();
                         this.water_height_label.Content = this._dataWaterLavel.data == null
                             ? "null"
                             : this._dataWaterLavel.data.ToString();
                         try
                         {
                             if (Convert.ToDouble(this._dataWaterLavel.data) <= Convert.ToDouble(this.water_height_label_meter.Text))
                             {
                                 this.Card.Background = Brushes.Red;
                                 this.flag_2 = false;
                             }
                             else
                             {
                                 flag_2 = true;
                                 if (flag_1 && flag_2)
                                 {
                                     this.Card.Background = Brushes.WhiteSmoke;
                                 }
                             }
                         }
                         catch (Exception e)
                         {
                         }
                     }
                 }
             }));
             Thread.Sleep(1000);
         }
     }
     catch (Exception e)
     {
         SystemConsole.setConsoleTxtThreadSafe(e.Message);
     }
 }