Esempio n. 1
0
        private string Loading_elements()
        {
            //string reply = "";
            //try
            //{
            string total = "";
            string[] lines = System.IO.File.ReadAllLines(Sending.directoryUrl + "center-" + "elements" + ".json");
            foreach (string line in lines)
            {

                total += line;
            }

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

            for (int d = 0; d < model.Count; d++)
            {
                try
                {
                    e = new Element(null);
                    e.Name = model.ElementAt(d).Name;
                    e.Abbrev = model.ElementAt(d).Abbrev;
                    e.Type = model.ElementAt(d).Type;
                    e.Units = model.ElementAt(d).Units;
                    e.Scale = model.ElementAt(d).Scale;
                    e.Limits = model.ElementAt(d).Limits;
                    e.Description = model.ElementAt(d).Description;
                    e.Submitted = model.ElementAt(d).Submitted;
                    e.Sync = "T";
                    e.Save();

                }
                catch (Exception)
                {
                    e = new Element(null);
                    e.Name = model.ElementAt(d).Name;
                    e.Abbrev = model.ElementAt(d).Abbrev;
                    e.Type = model.ElementAt(d).Type;
                    e.Units = model.ElementAt(d).Units;
                    e.Scale = model.ElementAt(d).Scale;
                    e.Limits = model.ElementAt(d).Limits;
                    e.Description = model.ElementAt(d).Description;
                    e.Submitted = model.ElementAt(d).Submitted;
                    e.Sync = "T";
                    e.Save();

                }

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

            //}
            //catch (Exception ex)
            //{

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

            //}


        }
Esempio n. 2
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (MessageBox.Show("confirm this information ?" + name.Text + " "+ " ", "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    u = App.WimeaApp.Elements.Add();
                  
                    u.Name = name.Text;
                    u.Abbrev = abbrev.Text;
                    u.Type = type.Text;
                    u.Units = units.Text;
                    u.Scale = scale.Text ;
                    u.Limits = limits.Text;
                    u.Description = description.Text;
                    u.Submitted = DateTime.Now.ToString();
                    u.Sync = "F";
                    u.Save();
                    RefreshUserList();
                    clear();

                }
                else
                {

                    return;
                }
            }
            catch (Exception ex)
            {

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

            }
        }