Ejemplo n.º 1
0
        private void loadings(string station)
        {
            metList = new List<Metar>();
            try
            {
                string total = "";
                string[] lines = System.IO.File.ReadAllLines(Sending.directoryUrl + station + "-" + "metar" + ".json");
                foreach (string line in lines)
                {                  
                    total += line;
                }

                List<MetarOnline> model = JsonConvert.DeserializeObject<List<MetarOnline>>(total);
               
                for (int d = 0; d < model.Count; d++)
                {
                    u = new Metar(null);
                    u.Station = model.ElementAt(d).Station;
                    u.Types = model.ElementAt(d).Type;
                    u.Datetimes = model.ElementAt(d).Datetime;
                    u.Timezones = model.ElementAt(d).Timezone;
                    u.Direction = model.ElementAt(d).Wind_direction;
                    u.Speed = model.ElementAt(d).Wind_speed;
                    u.Unit = model.ElementAt(d).Unit;
                    u.Visibility = model.ElementAt(d).Visibility;
                    u.Weather = model.ElementAt(d).Present_weather;
                    u.Cloud = model.ElementAt(d).Cloud;
                    u.Temperature = model.ElementAt(d).Air_temperature;
                    u.Humidity = model.ElementAt(d).Humidity;
                    u.Dew = model.ElementAt(d).Dew_temperature;
                    u.Wet = model.ElementAt(d).Wet_bulb;
                    u.Stationhpa = model.ElementAt(d).Station_pressure_hpa;
                    u.Seahpa = model.ElementAt(d).Sea_pressure_hpa;
                    u.Recent = model.ElementAt(d).Recent_weather;
                    u.Users = model.ElementAt(d).User;
                    u.Days = model.ElementAt(d).Day;
                    metList.Add(u);
                }
                List<Metar> metLists = new List<Metar>(metList.Where(c => Convert.ToDateTime(c.Days).Month.ToString() == (monthTxtCbx.SelectedIndex+1).ToString() &&  Convert.ToDateTime(c.Days).Day.ToString() == dayTxtCbx.Text  &&  Convert.ToDateTime(c.Days).Year.ToString() == yearTxtBx.Text ));
         
                MetarGrid.ItemsSource = null;
                MetarGrid.ItemsSource = metLists;                
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message.ToString());
                return;

            }

        }
Ejemplo n.º 2
0
        private string Loading_metar(string station)
        {
            string reply = "";
            try
            {
                string total = "";
                string[] lines = System.IO.File.ReadAllLines(Sending.directoryUrl + station + "-" + "metar" + ".json");
                foreach (string line in lines)
                {

                    total += line;
                }

                List<MetarOnline> model = JsonConvert.DeserializeObject<List<MetarOnline>>(total);

                for (int d = 0; d < model.Count; d++)
                {
                    m = new Metar(null);
                    m.Station = model.ElementAt(d).Station;
                    m.Types = model.ElementAt(d).Type;
                    m.Datetimes = model.ElementAt(d).Datetime;
                    m.Timezones = model.ElementAt(d).Timezone;
                    m.Direction = model.ElementAt(d).Wind_direction;
                    m.Speed = model.ElementAt(d).Wind_speed;
                    m.Unit = model.ElementAt(d).Unit;
                    m.Visibility = model.ElementAt(d).Visibility;
                    m.Weather = model.ElementAt(d).Present_weather;
                    m.Cloud = model.ElementAt(d).Cloud;
                    m.Temperature = model.ElementAt(d).Air_temperature;
                    m.Humidity = model.ElementAt(d).Humidity;
                    m.Dew = model.ElementAt(d).Dew_temperature;
                    m.Wet = model.ElementAt(d).Wet_bulb;
                    m.Stationhpa = model.ElementAt(d).Station_pressure_hpa;
                    m.Seahpa = model.ElementAt(d).Sea_pressure_hpa;
                    m.Recent = model.ElementAt(d).Recent_weather;
                    m.Users = model.ElementAt(d).User;
                    m.Days = model.ElementAt(d).Day;
                    m.Sync = "T";
                    m.Save();

                }
                return "Loaded synoptic information into local database!";

            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message.ToString());
                return "done loading metars";

            }


        }
Ejemplo n.º 3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (MessageBox.Show("confirm this information ?" + typeTxtBx.Text + " " + DatetimeTxtBx.Text + " " + VisibilityTxtBx.Text, "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {

                    u = App.WimeaApp.Metars.Add();

                    u.Station = stationTxtCbx.Text;
                    u.Types = typeTxtBx.Text;
                    u.Datetimes = DatetimeTxtBx.Text;
                    u.Timezones = "GMT";
                    u.Direction = WindDirectionTxtBx.Text;
                    u.Speed = "13";
                    u.Unit = "KT";
                    u.Visibility = VisibilityTxtBx.Text;
                    u.Weather = weatherTxtBx.Text;
                    u.Cloud = CloudTxtBx.Text;
                    u.Temperature = AirTempTxtBx.Text;
                    u.Humidity = HumidityTxtBx.Text;
                    u.Dew = DewTxtBx.Text;
                    u.Wet = WetTxtBx.Text;
                    u.Stationhpa = StationHpaTxtBx.Text;
                    u.Seahpa = SeaHpaTxtBx.Text;
                    u.Recent = RecentTxtBx.Text;
                    u.Users = "test";
                    u.Days = DateTime.Now.Date.ToString();
                    u.Sync = "F";

                    u.Save();
                    RefreshUserList();
                    clear();

                }
                else
                {

                    return;
                }
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message.ToString());
                return;

            }

        }