コード例 #1
0
        public async Task <IHttpActionResult> PutWeatherModel(int id, weather weatherModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != weatherModel.idweather)
            {
                return(BadRequest());
            }

            db.Entry(weatherModel).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WeatherModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #2
0
 void Start()
 {
     SR          = this.GetComponent <SpriteRenderer>();
     lastWeather = WeatherData.getIntance().currentWeather;
     random      = Random.Range(0, 1000);
     noiseTex    = ResourcesManagement.getInstance().getResources <Texture2D>("noise_readable");
 }
コード例 #3
0
        public static weather Zmena()
        {
            Random  nc = new Random();
            weather AP = (weather)nc.Next(Enum.GetNames(typeof(weather)).Length);

            return(AP);
        }
コード例 #4
0
    void Update()
    {
        SR.color = GameFunction.getColor(SR.color.r, SR.color.g, SR.color.b, Weather.instance.SmoothLerp_LightAlpha(Day_Alpha, Night_Alpha) - deltaMinus);      //随时间变化透明度

        if (WeatherData.getIntance().currentWeather != lastWeather && WeatherData.getIntance().currentWeather != weather.Sunny && lastWeather == weather.Sunny) //当天气不为晴天的一刻
        {
            deltaMinus = 0;
            _time0     = 0;
        }
        if (WeatherData.getIntance().currentWeather != lastWeather && WeatherData.getIntance().currentWeather == weather.Sunny)  //当天气为晴天的一刻
        {
            deltaMinus = 1;
            _time0     = 0;
        }
        if (WeatherData.getIntance().currentWeather != weather.Sunny)
        {
            _time0    += Time.deltaTime;
            deltaMinus = Mathf.Lerp(0, 1, _time0 / (WeatherData.getIntance().Weather_duration * 0.1f));
        }
        if (WeatherData.getIntance().currentWeather == weather.Sunny)
        {
            _time0    += Time.deltaTime;
            deltaMinus = Mathf.Lerp(1, 0, _time0 / (WeatherData.getIntance().Weather_duration * 0.1f));
        }

        GameFunction.m_Color    = SR.color;
        GameFunction.m_Color.a *= (1 + Mathf.Lerp(-0.8f, 0.1f, noiseTex.GetPixel(2, ((int)(Time.time * flashSpeed) + random) % noiseTex.width).r * 0.5f + 0.25f));
        SR.color = GameFunction.m_Color;

        lastWeather = WeatherData.getIntance().currentWeather;
    }
コード例 #5
0
        private async Task <string> GetWeatherAsync(weather weather)
        {
            var    APIKEY  = "695544473a2dd8009951c9bddec71282";
            string Lat     = city.Lat;
            string Lon     = city.Lon;
            string request = $"https://api.darksky.net/forecast/{APIKEY}/{Lon},{Lat}";
            HttpResponseMessage response = await client.GetAsync(request);

            string content = await response.Content.ReadAsStringAsync();

            JObject json = JObject.Parse(content);

            weather.Summary = (string)json["currently"]["summary"];
            if (temperature.isFahrenheit())
            {
                weather.TemperatureHigh = (Math.Round((double)json["daily"]["data"][0]["temperatureHigh"]));
                weather.TemperatureLow  = (Math.Round((double)json["daily"]["data"][0]["temperatureLow"]));
                weather.temperature     = (Math.Round((double)json["currently"]["temperature"]));
            }
            else if (temperature.isCelsius())
            {
                weather.TemperatureHigh = FahrenheitToCelsius((double)json["daily"]["data"][0]["temperatureHigh"]);
                weather.TemperatureLow  = FahrenheitToCelsius((double)json["daily"]["data"][0]["temperatureLow"]);
                weather.temperature     = FahrenheitToCelsius((double)json["currently"]["temperature"]);
            }
            return("ok");
        }
コード例 #6
0
ファイル: services.asmx.cs プロジェクト: gmedic1/Initiumhub
        public WeatherInfo GetWeather(string city)
        {
            var weather     = new weather(city);
            var weatherInfo = weather.GetWeather();

            weatherInfo.videoPath = setVideo(weatherInfo.currentTemp, weatherInfo.description);
            var constr       = ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString;
            var cityArr      = city.Split(',');
            var cityLocation = cityArr[0];
            var cityCountry  = cityArr[cityArr.Length - 1];

            using (SqlConnection con = new SqlConnection(constr))
            {
                using (SqlCommand cmd = new SqlCommand("spSaveWeather", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.Add("@city", SqlDbType.VarChar).Value    = cityLocation;
                    cmd.Parameters.Add("@Country", SqlDbType.VarChar).Value = cityCountry;



                    cmd.Parameters.Add("@MaxTemp", SqlDbType.VarChar).Value     = " ";
                    cmd.Parameters.Add("@MinTemp", SqlDbType.VarChar).Value     = " ";
                    cmd.Parameters.Add("@CurrentTemp", SqlDbType.VarChar).Value = weatherInfo.currentTemp;

                    con.Open();
                    cmd.ExecuteNonQuery();
                    con.Close();
                }
            }
            return(weatherInfo);
        }
コード例 #7
0
        public async Task <IActionResult> Index()
        {
            var weather = new weather();

            weather.currentTime = weather.FormateDate(DateTimeOffset.UtcNow.TimeOfDay);
            await GetWeatherAsync(weather);

            weather.city = city.City;
            return(View(weather));
        }
コード例 #8
0
ファイル: WeatherData.cs プロジェクト: Raindropgame/Ev_game
 public void Init()  //获取存档
 {
     currentTime         = PlayerPrefs.GetFloat("currentTime", 0);
     Weather_duration    = PlayerPrefs.GetFloat("Weather_duration", 5);
     Weather_leftTime    = PlayerPrefs.GetFloat("Weather_leftTime", 5);
     currentWeather      = (weather)PlayerPrefs.GetInt("currentWeather");
     Rain_Odds           = PlayerPrefs.GetFloat("Rain_Odds");
     Thunder_Odds        = PlayerPrefs.GetFloat("Thunder_Odds");
     RainAndThunder_Odds = PlayerPrefs.GetFloat("RainAndThunder_Odds");
 }
コード例 #9
0
        public void Saving_Data_function()
        {
            panel2.Visible = true;
            weather x = new weather(Convert.ToInt16(numericUpDownTMMin.Value), Convert.ToInt16(numericUpDownTMM.Value),
                                    Convert.ToInt16(numericUpDownPTM.Value), (Convert.ToInt16(numericUpDownTMM.Value) + Convert.ToInt16(numericUpDownPTM.Value)) / 2);

            meteo[Convert.ToInt16(cb_months.SelectedIndex)] = x;
            listBox1_months.Items.Add(cb_months.SelectedIndex + 1);
            listBox1_Tmin.Items.Add(numericUpDownTMMin.Value);
            listBox1_Tmax.Items.Add(numericUpDownTMM.Value);
            listBox1_PMtotal.Items.Add(numericUpDownPTM.Value);
        }
コード例 #10
0
        public async Task <IHttpActionResult> PostWeatherModel(weather weatherModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Weather.Add(weatherModel);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = weatherModel.idweather }, weatherModel));
        }
コード例 #11
0
        public async Task <IActionResult> detailedForecast(int id)
        {
            var detailedWeather = new weather();

            forecast.SixteenDayForecast = await get16DayForecastAsync();//todo make this persistant

            detailedWeather = forecast.getDetailedForecastByDay(id);
            if (detailedWeather == null)
            {
                return(NotFound());
            }
            return(View(detailedWeather));
        }
コード例 #12
0
        public async Task <IHttpActionResult> DeleteWeatherModel(int id)
        {
            weather weatherModel = await db.Weather.FindAsync(id);

            if (weatherModel == null)
            {
                return(NotFound());
            }

            db.Weather.Remove(weatherModel);
            await db.SaveChangesAsync();

            return(Ok(weatherModel));
        }
コード例 #13
0
        public void ZmenaTrasy(char z)
        {
            if (z == 'M')
            {
                Svetla = false;

                AktualniPocasi = zmenapocasi();
                switch (AktualniPocasi)
                {
                case weather.Clear:
                    AktualniRychlost = 40;
                    break;

                case weather.Rain:
                    AktualniRychlost = 38;
                    break;

                case weather.Storm:
                    AktualniRychlost = 32;
                    break;

                case weather.Winter:
                    AktualniRychlost = 25;
                    break;
                }
            }
            else if (z == 'T')
            {
                Svetla           = true;
                AktualniRychlost = 35;
            }
            else
            {
                AktualniPocasi = zmenapocasi();
                switch (AktualniPocasi)
                {
                case weather.Rain:
                    AktualniRychlost = 100;
                    break;

                case weather.Storm:
                    AktualniRychlost = 70;
                    break;

                case weather.Winter:
                    AktualniRychlost = 50;
                    break;
                }
            }
        }
コード例 #14
0
        public void TestMethod1()
        {
            // arrange
            Weather weather = new weather();
            int     expected;



            // act



            //assert
        }
コード例 #15
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            weather = await _context.weather.FirstOrDefaultAsync(m => m.ID == id);

            if (weather == null)
            {
                return(NotFound());
            }
            return(Page());
        }
コード例 #16
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            weather = await _context.weather.FindAsync(id);

            if (weather != null)
            {
                _context.weather.Remove(weather);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
コード例 #17
0
        private void combo_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            weather = new weather();
            String[]    region      = combo.Text.Split(',');
            WeatherData weatherData = weather.Reading(region[1]);

            if (weatherData != null)
            {
                Pweather.Image = weatherData.icon;
                label1.Text    = weatherData.ToString();
            }
            else
            {
                Pweather.Image = null;
                label1.Text    = "확인 할 수 없는 도시입니다.";
            }
            Pweather.Refresh();
        }
コード例 #18
0
        public IActionResult ChangeCity(string input)
        {
            var weather         = new weather();
            var locationService = new GoogleLocationService("GOOGLEKEY");

            try
            {
                var point = locationService.GetLatLongFromAddress(input);
                city.Lon  = point.Latitude.ToString();
                city.Lat  = point.Longitude.ToString();
                city.City = input + "(" + city.Lon + " , " + city.Lat + ")";;
            }
            catch (Exception e)
            {
                weather.currentTime = weather.FormateDate(DateTimeOffset.UtcNow.TimeOfDay);
                city.setDefault();
            }
            return(RedirectToAction("Index", "Home"));
        }
        public async Task <CurrentWeatherResponse> GetCurrentWeather(GetCurrentWeatherRequest request)
        {
            CurrentWeatherResponse result = null;
            string     content            = "";
            HttpClient client             = new HttpClient();

            client.BaseAddress = new Uri(baseUrl);
            WeatherDbDataContext db = new WeatherDbDataContext(connectString);

            //Create new Employee

            weather weather = db.weathers.FirstOrDefault(x => x.key == request.Key);

            if (weather != null)
            {
                return(new CurrentWeatherResponse {
                    text = weather.WeatherText, value = double.Parse(weather.celsius)
                });
            }
            else
            {
                HttpResponseMessage response = client.GetAsync(baseUrl + "currentconditions/v1/" + request.Key + "?apikey=" + apiKey).Result;
                if (response.IsSuccessStatusCode)
                {
                    content = await response.Content.ReadAsStringAsync();

                    var list = JsonConvert.DeserializeObject <List <CurrentWeather> >(content);
                    if (list.Count > 0)
                    {
                        result = new CurrentWeatherResponse {
                            text = list[0].WeatherText, value = list[0].temperature.metric.Value
                        };
                        db.weathers.InsertOnSubmit(new weather {
                            celsius = result.value.ToString(), key = request.Key, WeatherText = result.text
                        });
                        db.SubmitChanges();
                    }
                }
            }
            return(result);
        }
コード例 #20
0
ファイル: ResetFile.cs プロジェクト: Raindropgame/Ev_game
    public void getFile()   //获取存档数据
    {
        //人物属性
        MaxBreath         = PlayerPrefs.GetInt("MaxBreath", MaxBreath);
        MaxHP             = PlayerPrefs.GetInt("MaxHP", MaxHP);
        expend_run        = PlayerPrefs.GetInt("expend_run", expend_run);
        expend_attack     = PlayerPrefs.GetInt("expend_attack", expend_attack);
        expend_jump       = PlayerPrefs.GetInt("expend_jump", expend_jump);
        expend_dash       = PlayerPrefs.GetInt("expend_dash", expend_dash);
        expend_shoot      = PlayerPrefs.GetInt("expend_shoot", expend_shoot);
        expend_jumpshoot  = PlayerPrefs.GetInt("expend_jumpshoot", expend_jumpshoot);
        expend_jumpshoot  = PlayerPrefs.GetInt("expend_throw", expend_throw);
        Speed_recovery    = PlayerPrefs.GetInt("Speed_recovery", Speed_recovery);
        JumpTimes         = PlayerPrefs.GetInt("JumpTimes", JumpTimes);
        MaxJumpShootTimes = PlayerPrefs.GetInt("MaxJumpShootTimes", MaxJumpShootTimes);
        for (int i = 0; i < isEnable.Length; i++)
        {
            isEnable[i] = PlayerPrefs.GetInt(((state)i).ToString(), isEnable[i] == true ? 1 : 0) == 1 ? true : false;  //true:1  false:0
        }
        //---------

        //场景
        currentScene    = PlayerPrefs.GetString("currentScene", currentScene);
        BornPositionNum = PlayerPrefs.GetInt("BronPositionNum", BornPositionNum);
        //---------

        //天气
        currentTime         = PlayerPrefs.GetFloat("currentTime", 0);
        currentWeather      = (weather)PlayerPrefs.GetInt("currentWeather");
        Weather_duration    = PlayerPrefs.GetFloat("Weather_duration", 5);
        Weather_leftTime    = PlayerPrefs.GetFloat("Weather_leftTime", 5);
        Rain_Odds           = PlayerPrefs.GetFloat("Rain_Odds");
        Thunder_Odds        = PlayerPrefs.GetFloat("Thunder_Odds");
        RainAndThunder_Odds = PlayerPrefs.GetFloat("RainAndThunder_Odds");
        //-------
    }
コード例 #21
0
        private async Task <List <weather> > get16DayForecastAsync()
        {
            var    APIKEY  = "695544473a2dd8009951c9bddec71282";
            String request = $"https://api.darksky.net/forecast/{APIKEY}/{city.Lon},{city.Lat}";
            HttpResponseMessage response = await client.GetAsync(request);

            string content = await response.Content.ReadAsStringAsync();

            JObject json = JObject.Parse(content);

            var forecast = new List <weather>();
            var id       = 0;

            foreach (var dayForecast in json["daily"]["data"])
            {
                weather weather = new weather(dayForecast);

                if (temperatureUnit.isFahrenheit())
                {
                    weather.TemperatureHigh = Math.Round((double)dayForecast["temperatureHigh"]);
                    weather.TemperatureLow  = Math.Round((double)dayForecast["temperatureLow"]);
                }
                else if (temperatureUnit.isCelsius())
                {
                    weather.TemperatureHigh = FahrenheitToCelsius((double)dayForecast["temperatureHigh"]);
                    weather.TemperatureLow  = FahrenheitToCelsius((double)dayForecast["temperatureLow"]);
                }
                weather.Summary     = (string)dayForecast["summary"];
                weather.currentTime = GetDateFromUnixTimestamp((double)dayForecast["time"]).ToString();
                weather.id          = id;
                id++;
                weather.Icon = "/images/" + weather.Icon + ".svg";
                forecast.Add(weather);
            }
            return(forecast);
        }
コード例 #22
0
        public ActionResult Index()
        {
            #region Weather

            #region Current
            string Miasto = "Limanowa";

            if (!Request["Wybrane_miasto"].IsEmpty())
            {
                Miasto = Request["Wybrane_miasto"];
            }



            weatherInfo.WeatherInfo.root checkWeather = new WeatherInfo.root();
            weather weather = new weather();

            checkWeather = weather.DownloadWeather(Miasto);



            bool sprawdz = true;
            if (checkWeather != null)
            {
                sprawdz = true;
                // lastweather.SaveWeather(checkWeather);
                ViewBag.weatherName      = checkWeather.name;
                ViewBag.weatherCountry   = checkWeather.sys.country;
                ViewBag.weatherTemp      = checkWeather.main.temp.ToString();
                ViewBag.weatherfeelsLike = checkWeather.main.feels_like.ToString();
                ViewBag.weatherTempMax   = checkWeather.main.temp_max.ToString();
                ViewBag.weatherTempMin   = checkWeather.main.temp_min.ToString();
                ViewBag.weatherPressure  = checkWeather.main.pressure.ToString();
                ViewBag.weatherHumidity  = checkWeather.main.humidity.ToString();
                ViewBag.weatherWindSpeed = checkWeather.wind.speed.ToString();
            }
            else
            {
                sprawdz       = false;
                ViewBag.error = "Brak miasta " + Miasto + " w bazie danych";
            }

            #endregion

            #region Historia

            weatherInfo.HistoriWeatherInfo.root yeasterdayweater = new weatherInfo.HistoriWeatherInfo.root();
            PastWeather pastWeather = new PastWeather();

            UnixTime wczorajTime = new UnixTime();
            int      time        = wczorajTime.WczorajUnixTime();

            int dtNow = 15;

            if (sprawdz == true)
            {
                yeasterdayweater = pastWeather.DownloandLastWeather(checkWeather.coord.lat, checkWeather.coord.lon, time);
                //dtNow = pastWeather.ActualTime(yeasterdayweater);
            }
            if (yeasterdayweater.hourly != null && dtNow != -1)
            {
                ViewBag.yeasterdayWeaterTemp = yeasterdayweater.hourly[dtNow].temp;
                if (checkWeather.main.temp > yeasterdayweater.hourly[dtNow].temp)
                {
                    int    one = (int)((checkWeather.main.temp - yeasterdayweater.hourly[dtNow].temp) * 100);
                    double two = (double)one / 100;

                    ViewBag.yeasterdayDifferenceTempInt    = two;
                    ViewBag.yeasterdayDifferenceTempString = "cieplej ";
                }
                else if (checkWeather.main.temp < yeasterdayweater.hourly[dtNow].temp)
                {
                    int    one = (int)((yeasterdayweater.hourly[dtNow].temp - checkWeather.main.temp) * 100);
                    double two = (double)one / 100;

                    ViewBag.yeasterdayDifferenceTempInt    = two;
                    ViewBag.yeasterdayDifferenceTempString = "zimniej ";
                }

                ViewBag.yeasterdayWeaterfeelslike = yeasterdayweater.hourly[dtNow].feels_like;
                if (checkWeather.main.feels_like > yeasterdayweater.hourly[dtNow].feels_like)
                {
                    int    one = (int)((checkWeather.main.feels_like - yeasterdayweater.hourly[dtNow].feels_like) * 100);
                    double two = (double)one / 100;

                    ViewBag.yeasterdayDifferencefeelslikeInt    = two;
                    ViewBag.yeasterdayDifferencefeelslikeString = "cieplej ";
                }
                else if (checkWeather.main.feels_like < yeasterdayweater.hourly[dtNow].feels_like)
                {
                    int    one = (int)((yeasterdayweater.hourly[dtNow].feels_like - checkWeather.main.feels_like) * 100);
                    double two = (double)one / 100;

                    ViewBag.yeasterdayDifferencefeelslikeint    = two;
                    ViewBag.yeasterdayDifferencefeelslikeString = "zimniej ";
                }

                ViewBag.yeasterdayWeaterPressure = yeasterdayweater.hourly[dtNow].pressure;
                if (checkWeather.main.pressure > yeasterdayweater.hourly[dtNow].pressure)
                {
                    ViewBag.yeasterdayDifferencePressureInt    = checkWeather.main.pressure - yeasterdayweater.hourly[dtNow].pressure;
                    ViewBag.yeasterdayDifferencePressureString = "wyższe";
                }
                else if (checkWeather.main.pressure < yeasterdayweater.hourly[dtNow].pressure)
                {
                    ViewBag.yeasterdayDifferencePressureInt    = yeasterdayweater.hourly[dtNow].pressure - checkWeather.main.pressure;
                    ViewBag.yeasterdayDifferencePressureString = "niższe";
                }

                ViewBag.yeasterdayWeaterHumidity = yeasterdayweater.hourly[dtNow].humidity;
                if (checkWeather.main.humidity > yeasterdayweater.hourly[dtNow].humidity)
                {
                    ViewBag.yeasterdayDifferenceHumidityInt    = checkWeather.main.humidity - yeasterdayweater.hourly[dtNow].humidity;
                    ViewBag.yeasterdayDifferenceHumidityString = "wyższe";
                }
                else if (checkWeather.main.humidity < yeasterdayweater.hourly[dtNow].humidity)
                {
                    ViewBag.yeasterdayDifferenceHumidityInt    = yeasterdayweater.hourly[dtNow].humidity - checkWeather.main.humidity;
                    ViewBag.yeasterdayDifferenceHumidityString = "niższe";
                }

                ViewBag.yeasterdayWeaterWeaterWindSpeed = yeasterdayweater.hourly[dtNow].wind_speed;
                if (checkWeather.wind.speed > yeasterdayweater.hourly[dtNow].wind_speed)
                {
                    ViewBag.yeasterdayDifferenceWindSpeedInt    = checkWeather.wind.speed - yeasterdayweater.hourly[dtNow].wind_speed;
                    ViewBag.yeasterdayDifferenceWindSpeedString = "mocniejszy";
                }
                else if (checkWeather.wind.speed < yeasterdayweater.hourly[dtNow].wind_speed)
                {
                    ViewBag.yeasterdayDifferenceWindSpeedInt    = yeasterdayweater.hourly[dtNow].wind_speed - checkWeather.wind.speed;
                    ViewBag.yeasterdayDifferenceWindSpeedString = "słabszy";
                }
            }
            else
            {
                ViewBag.lastError = "Nie udało się pobrać danych wczorajszego dnia";
            }
            #endregion

            #region Prognoza


            FutureWeatherInfo.root futureWeather = new FutureWeatherInfo.root();
            FutureWeather          dowloand      = new FutureWeather();

            UnixTime unixTime = new UnixTime();



            if (sprawdz == true)
            {
                futureWeather = dowloand.DownloandFutureWeather(checkWeather.coord.lat, checkWeather.coord.lon);
                Nazwa_Miasta  = checkWeather.name;
                publicLat     = checkWeather.coord.lat;
                publicLon     = checkWeather.coord.lon;
            }
            if (futureWeather.daily != null)
            {
                ViewBag.futureWeatherTemp = futureWeather.daily[0].temp.day;
                if (checkWeather.main.temp > futureWeather.daily[0].temp.day)
                {
                    int    one = (int)((checkWeather.main.temp - futureWeather.daily[0].temp.day) * 100);
                    double two = (double)one / 100;

                    ViewBag.futureDifferenceTempInt    = two;
                    ViewBag.futureDifferenceTempString = "zimniej ";
                }
                else if (checkWeather.main.temp < futureWeather.daily[0].temp.day)
                {
                    int    one = (int)((futureWeather.daily[0].temp.day - checkWeather.main.temp) * 100);
                    double two = (double)one / 100;

                    ViewBag.futureDifferenceTempInt    = two;
                    ViewBag.futureDifferenceTempString = "cieplej ";
                }

                ViewBag.futureWeatherTempMax = futureWeather.daily[0].temp.max;
                if (checkWeather.main.temp_max > futureWeather.daily[0].temp.max)
                {
                    int    one = (int)((checkWeather.main.temp_max - futureWeather.daily[0].temp.max) * 100);
                    double two = (double)one / 100;

                    ViewBag.futureDifferenceTempMaxInt    = two;
                    ViewBag.futureDifferenceTempMaxString = "zimniej";
                }
                else if (checkWeather.main.temp_max < futureWeather.daily[0].temp.max)
                {
                    int    one = (int)((futureWeather.daily[0].temp.max - checkWeather.main.temp_max) * 100);
                    double two = (double)one / 100;

                    ViewBag.futureDifferenceTempMaxInt    = two;
                    ViewBag.futureDifferenceTempMaxString = "cieplej";
                }

                ViewBag.futureWeatherTempMin = futureWeather.daily[0].temp.min;
                if (checkWeather.main.temp_min > futureWeather.daily[0].temp.min)
                {
                    int    one = (int)((checkWeather.main.temp_min - futureWeather.daily[0].temp.min) * 100);
                    double two = (double)one / 100;

                    ViewBag.futureDifferenceTempMinInt    = two;
                    ViewBag.futureDifferenceTempMinString = "zimniej ";
                }
                else if (checkWeather.main.temp_min > futureWeather.daily[0].temp.min)
                {
                    int    one = (int)((futureWeather.daily[0].temp.min - checkWeather.main.temp_min) * 100);
                    double two = (double)one / 100;

                    ViewBag.futureDifferenceTempMinInt    = two;
                    ViewBag.futureDifferenceTempMinString = "cieplej ";
                }

                ViewBag.futureWeatherFeelsLike = futureWeather.daily[0].feels_Like.day;
                if (checkWeather.main.feels_like > futureWeather.daily[0].feels_Like.day)
                {
                    int    one = (int)((checkWeather.main.feels_like - futureWeather.daily[0].feels_Like.day) * 100);
                    double two = (double)one / 100;

                    ViewBag.futureDifferenceFeelsLikeInt    = two;
                    ViewBag.futureDifferenceFeelsLikeString = "zimniej ";
                }
                else if (checkWeather.main.feels_like < futureWeather.daily[0].feels_Like.day)
                {
                    int    one = (int)((futureWeather.daily[0].feels_Like.day - checkWeather.main.feels_like) * 100);
                    double two = (double)one / 100;

                    ViewBag.futureDifferenceFeelsLikeInt    = two;
                    ViewBag.futureDifferenceFeelsLikeString = "cieplej ";
                }

                ViewBag.futureWeatherPressure = futureWeather.daily[0].pressure;
                if (checkWeather.main.pressure > futureWeather.daily[0].pressure)
                {
                    int    one = (int)((checkWeather.main.pressure - futureWeather.daily[0].pressure) * 100);
                    double two = (double)one / 100;

                    ViewBag.futureDifferencePressureInt    = two;
                    ViewBag.futureDifferencePressureString = "niższe ";
                }
                else if (checkWeather.main.pressure < futureWeather.daily[0].pressure)
                {
                    int    one = (int)((futureWeather.daily[0].pressure - checkWeather.main.pressure) * 100);
                    double two = (double)one / 100;

                    ViewBag.futureDifferencePressureInt    = two;
                    ViewBag.futureDifferencePressureString = "wyższe ";
                }

                ViewBag.futureWeatherHumidity = futureWeather.daily[0].humidity;
                if (checkWeather.main.humidity > futureWeather.daily[0].humidity)
                {
                    int    one = (int)((checkWeather.main.humidity - futureWeather.daily[0].humidity) * 100);
                    double two = (double)one / 100;

                    ViewBag.futureDifferenceHumidityInt    = two;
                    ViewBag.futureDifferenceHumidityString = "niższe ";
                }
                else if (checkWeather.main.humidity < futureWeather.daily[0].humidity)
                {
                    int    one = (int)((futureWeather.daily[0].humidity - checkWeather.main.humidity) * 100);
                    double two = (double)one / 100;

                    ViewBag.futureDifferenceHumidityInt    = two;
                    ViewBag.futureDifferenceHumidityString = "wyższe ";
                }

                ViewBag.futureWeatherWindSpeed = futureWeather.daily[0].wind_speed;
                if (checkWeather.wind.speed > futureWeather.daily[0].wind_speed)
                {
                    int    one = (int)((checkWeather.wind.speed - futureWeather.daily[0].wind_speed) * 100);
                    double two = (double)one / 100;

                    ViewBag.futureDifferenceWindSpeedInt    = two;
                    ViewBag.futureDifferenceWindSpeedString = "słabszy ";
                }
                else if (checkWeather.wind.speed < futureWeather.daily[0].wind_speed)
                {
                    int    one = (int)((futureWeather.daily[0].wind_speed - checkWeather.wind.speed) * 100);
                    double two = (double)one / 100;

                    ViewBag.futureDifferenceWindSpeedInt    = two;
                    ViewBag.futureDifferenceWindSpeedString = "mocniejszy ";
                }
            }//szegóły jutrzejszego dnia
            else
            {
                ViewBag.FutureError = "Nie udało się pobrać prognozowanej pogody";
            }
            if (futureWeather.daily != null)
            {
                ViewBag.weatherLon = checkWeather.coord.lon;
                ViewBag.weatherLat = checkWeather.coord.lat;

                string dzień = unixTime.AktualnyDzieńString(futureWeather.daily[0].dt);


                ViewBag.futureWeatherOneDay  = dzień;
                ViewBag.futureWeatherOneTemp = futureWeather.daily[0].temp.day;
                ViewBag.futureWeatherOnePop  = futureWeather.daily[0].pop * 100;

                dzień = unixTime.AktualnyDzieńString(futureWeather.daily[1].dt);
                ViewBag.futureWeatherTwoDay  = dzień;
                ViewBag.futureWeatherTwoTemp = futureWeather.daily[1].temp.day;
                ViewBag.futureWeatherTwoPop  = futureWeather.daily[1].pop * 100;

                dzień = unixTime.AktualnyDzieńString(futureWeather.daily[2].dt);
                ViewBag.futureWeatherThreeDay  = dzień;
                ViewBag.futureWeatherThreeTemp = futureWeather.daily[2].temp.day;
                ViewBag.futureWeatherThreePop  = futureWeather.daily[2].pop * 100;

                dzień = unixTime.AktualnyDzieńString(futureWeather.daily[3].dt);
                ViewBag.futureWeatherFourDay  = dzień;
                ViewBag.futureWeatherFourTemp = futureWeather.daily[3].temp.day;
                ViewBag.futureWeatherFourPop  = futureWeather.daily[3].pop * 100;

                dzień = unixTime.AktualnyDzieńString(futureWeather.daily[4].dt);
                ViewBag.futureWeatherFiveDay  = dzień;
                ViewBag.futureWeatherFiveTemp = futureWeather.daily[4].temp.day;
                ViewBag.futureWeatherFivePop  = futureWeather.daily[4].pop * 100;

                dzień = unixTime.AktualnyDzieńString(futureWeather.daily[5].dt);
                ViewBag.futureWeatherSixDay  = dzień;
                ViewBag.futureWeatherSixTemp = futureWeather.daily[5].temp.day;
                ViewBag.futureWeatherSixPop  = futureWeather.daily[5].pop * 100;


                dzień = unixTime.AktualnyDzieńString(futureWeather.daily[6].dt);
                ViewBag.futureWeatherSevenDay  = dzień;
                ViewBag.futureWeatherSevenTemp = futureWeather.daily[6].temp.day;
                ViewBag.futureWeatherSevenPop  = futureWeather.daily[6].pop * 100;

                dzień = unixTime.AktualnyDzieńString(futureWeather.daily[7].dt);
                ViewBag.futureWeatherEightDay  = dzień;
                ViewBag.futureWeatherEightTemp = futureWeather.daily[7].temp.day;
                ViewBag.futureWeatherEightPop  = futureWeather.daily[7].pop * 100;
            } //Szybka probnoza na 8 dni

            #endregion

            #endregion


            return(View());
        }
コード例 #23
0
    public void setWeather()
    {
        int random = UnityEngine.Random.Range(1, 10);

        if (season == seasons.SPRING)
        {
            if (random >= 1 && random <= 6)
            {
                dayWeather = weather.SUNNY;
            }
            else if (random == 7)
            {
                dayWeather = weather.RAINSTORM;
            }
            else
            {
                dayWeather = weather.RAIN;
            }
        }
        if (season == seasons.SUMMER)
        {
            if (random >= 1 && random <= 7)
            {
                dayWeather = weather.SUNNY;
            }
            else if (random == 8)
            {
                dayWeather = weather.RAINSTORM;
            }
            else
            {
                dayWeather = weather.RAIN;
            }
        }
        if (season == seasons.FALL)
        {
            if (random >= 1 && random <= 6)
            {
                dayWeather = weather.SUNNY;
            }
            else if (random == 7)
            {
                dayWeather = weather.RAINSTORM;
            }
            else
            {
                dayWeather = weather.RAIN;
            }
        }
        if (season == seasons.WINTER)
        {
            if (random >= 1 && random <= 6)
            {
                dayWeather = weather.SNOW;
            }
            else if (random == 7)
            {
                dayWeather = weather.SNOWSTORM;
            }
            else
            {
                dayWeather = weather.SUNNY;
            }
        }
        weatherSystem.weatherParticlesEnabled();
    }
コード例 #24
0
ファイル: App.xaml.cs プロジェクト: Pai026/weatherapp-xamarin
        public App()
        {
            InitializeComponent();

            MainPage = new weather();
        }
コード例 #25
0
        // Helpers
        public async Task DigestLuisResult(DialogContext dc, weather luisResult)
        {
            try
            {
                var state = await Accessor.GetAsync(dc.Context);

                // extract entities and store in state here.
                if (luisResult.Entities.Weather_Location != null && luisResult.Entities.Weather_Location.Length > 0)
                {
                    state.Locations.Clear();
                    foreach (var location in luisResult.Entities.Weather_Location)
                    {
                        if (!state.Locations.Contains(location))
                        {
                            state.Locations.Add(location);
                        }
                    }
                }

                if (luisResult.Entities.datetime != null && luisResult.Entities.datetime.Length > 0)
                {
                    state.ForecastTimes.Clear();
                    foreach (var datespcs in luisResult.Entities.datetime)
                    {
                        switch (datespcs.Type)
                        {
                        case "date":
                            if (datespcs.Expressions.Count > 0)
                            {
                                var forecast = new ForecastTime {
                                    StartTime = null, Type = ForecastType.Day
                                };
                                if (DateTime.TryParse(datespcs.Expressions[0], out DateTime time))
                                {
                                    forecast.StartTime = time;
                                }
                                state.ForecastTimes.Add(forecast);
                            }
                            break;

                        case "datetime":
                            if (datespcs.Expressions.Count > 0)
                            {
                                var forecast = new ForecastTime {
                                    StartTime = null, Type = ForecastType.Hour
                                };
                                if (DateTime.TryParse(datespcs.Expressions[0], out DateTime time))
                                {
                                    forecast.StartTime = time;
                                }
                                state.ForecastTimes.Add(forecast);
                            }
                            break;
                        }
                    }
                }

                if (luisResult.Entities.Wear_Clothes != null && luisResult.Entities.Wear_Clothes.Length > 0)
                {
                    state.Clothes.Clear();
                    foreach (var cloth in luisResult.Entities.Wear_Clothes)
                    {
                        if (!state.Clothes.Contains(cloth))
                        {
                            state.Clothes.Add(cloth);
                        }
                    }
                }
            }
            catch
            {
                // put log here
            }
        }