Exemple #1
0
        public void Zapisz()
        {
            while (true)
            {
                if (w == null)
                {
                    Thread.Sleep(1000);
                    continue;
                }
                break;
            }
            Baza baza = new Baza();

            w.Main.Temp    = (w.Main.Temp - 273.15);
            w.Main.TempMax = (w.Main.TempMax - 273.15);
            w.Main.TempMin = (w.Main.TempMin - 273.15);
            baza.Weather.Add(w); baza.SaveChanges();
            Console.WriteLine("Zapisano.");
        }
Exemple #2
0
        internal void ShowAH()
        {
            Baza baza = new Baza(); object lista;

            try
            {
                var query = baza.Database.SqlQuery <Weather>("SELECT Weathers.Id, Weathers.MeasurmentDate, Weathers.Visibility, Weathers.Clouds_All, Mains.Temp, Mains.Humidity, Mains.Pressure, Weathers.Base\r\nFROM Mains INNER JOIN Weathers ON Mains.Id = Weathers.Main_Id INNER JOIN Winds ON Weathers.Wind_Id = Winds.Id WHERE (Weathers.Name LIKE N'" + Library.AktuMias + "') ");
                lista = query.ToListAsync().Result;
            }
            catch
            {
                lista = baza.Weather.Include(x => x.Main).Include(x => x.WeatherElements).ToList();
            }
            var table = new ConsoleTable("L.p.", "Data", "Zachmurzenie", "Temperatura", "Wilgotność", "Ciśnienie", "Opis");

            for (int i = 0; i < ((List <Weather>)lista).Count; i++)
            {
                table.AddRow(i, ((List <Weather>)lista)[i].MeasurmentDate, ((List <Weather>)lista)[i].Clouds.All, ((List <Weather>)lista)[i].Main.Temp, ((List <Weather>)lista)[i].Main.Humidity, ((List <Weather>)lista)[i].Main.Pressure, ((List <Weather>)lista)[i].WeatherElements.FirstOrDefault()?.Description);
            }
            table.Write();
        }
Exemple #3
0
        public override void Display()
        {
            var res = Input.ReadString("Podaj nazwę pliku: ");

            if (!string.IsNullOrWhiteSpace(res))
            {
                Baza         baza = new Baza();
                FileStream   fs   = new FileStream("dupa.txt", FileMode.Create);
                StreamWriter wr   = new StreamWriter(fs);
                foreach (Weather item in baza.Weather.Include(x => x.Main).Include(x => x.Wind))
                {
                    wr.WriteLineAsync(item.Id + ";" + item.Base + ";" + item.Visibility + ";" + item.Clouds.All + ";" + item.Dt +
                                      ";" + item.Name + ";" + item.MeasurmentDate + ";" + item.Main.TempMin + ";" +
                                      item.Main.Temp + ";" + item.Main.TempMax + ";" + item.Main.Humidity + ";" +
                                      item.Main.Pressure + ";" + item.Wind.Speed + ";" + item.Wind.Deg);
                }

                Output.WriteLine(ConsoleColor.Blue, "Zapisano.");
                Input.ReadString("Press [Enter] to navigate home");
                Program.NavigateHome();
            }
        }