private void Form1_Load(object sender, EventArgs e) { timer = new Timer(); timer.Interval = 1000; timer.Tick += Timer_Tick; timer.Start(); weatherData = new WeatherData(); currentCondition = new CurrentCondition(weatherData); }
private void GetCurrentCondition() { var client = new RestClient("http://dataservice.accuweather.com/currentconditions/v1/" + locationCode + "?apikey=SyQbb4hIuNveRnj4NLzAWrRWBPMyv53q&details=true"); var request = new RestRequest(Method.GET); request.AddHeader("Postman-Token", "23acb8fb-c16a-4064-b29c-7d55d782675e"); request.AddHeader("Cache-Control", "no-cache"); IRestResponse response = client.Execute(request); currentCondition = new CurrentCondition(response.Content.ToString()); }
public void Edit(CurrentCondition currentCondition) { try { _currentConditionRepository.Edit(currentCondition); _logger.LogInformation("The condition was updated!"); } catch (Exception exception) { _logger.LogError("An error occurred while updating the condition" + " | " + exception); throw; } }
public void Add(CurrentCondition currentCondition) { try { _currentConditionRepository.Add(currentCondition); _logger.LogInformation("New condition was added!"); } catch (Exception exception) { _logger.LogError("An error occurred while adding the condition" + " | " + exception); throw; } }
public bool IsLoopFixedPoint() { if (Transitions == null || !Transitions.Any()) { return(true); } var nextCondition = Transitions.First().Node.CurrentCondition; return(CurrentCondition.Count == nextCondition.Count && CurrentCondition.All(a => nextCondition.ContainsKey(a.Key) && nextCondition[a.Key] == a.Value) && Transitions.First().Node.IsLoopFixedPoint()); }
private void webclient_DownloadJSONCompleted(object Sender, DownloadStringCompletedEventArgs e) { string TempDataJSON = e.Result; var root = JsonConvert.DeserializeObject <RootObject>(TempDataJSON); // Deserialize json object CurrentCondition currentCondition = root.data.current_condition[0]; Weather weather = root.data.weather[0]; //Display current info in the text filed. AllText.Text = "Current Temp = " + currentCondition.temp_C + "Min " + weather.tempMinC + " Max " + weather.tempMaxC + " Wind " + currentCondition.windspeedKmph; AllText.SetText(Html.FromHtml("<bold>Current Temp = " + currentCondition.temp_C + "</bold>"), TextView.BufferType.Normal); }
public void Edit(CurrentCondition currentCondition) { try { _dataContext.CurrentConditions.Update(currentCondition); _dataContext.SaveChanges(); _logger.LogInformation("The conditions were updated!"); } catch (Exception exception) { _logger.LogError("An error occurred while updating the condition" + " | " + exception); throw; } }
public void Delete(CurrentCondition currentCondition) { try { _dataContext.CurrentConditions.Remove(currentCondition); _dataContext.SaveChanges(); _logger.LogInformation("The condition was deleted!"); } catch (Exception exception) { _logger.LogError("An error occurred while deleting the condition" + " | " + exception); throw; } }
public void Add(CurrentCondition currentCondition) { try { _dataContext.CurrentConditions.Add(currentCondition); _dataContext.SaveChanges(); _logger.LogInformation("New condition was added!"); } catch (Exception exception) { _logger.LogError("An error occurred while adding the condition" + " | " + exception); throw; } }
static void Main(string[] args) { Console.WriteLine("Hello World!"); WeatherObservable weatherObservable = new WeatherObservable(); CurrentCondition currentCondition = new CurrentCondition(weatherObservable); weatherObservable.GetMeasurements(new Measurements(10, 60, 760)); weatherObservable.GetMeasurements(null); #if (!vscode) // Add this for run from VS in order to console window will keep open Console.WriteLine("Press Enter for exit"); Console.ReadLine(); #endif }
public static async Task <CurrentCondition> GetCurrentCondition(string location) { CurrentCondition currentCondition = new CurrentCondition(); string url = BASE_URL + String.Format(CURRENTCONDITIONS_ENDPOINT, location, API_KEY); using (HttpClient http = new HttpClient()) { var response = await http.GetAsync(url); string json = await response.Content.ReadAsStringAsync(); currentCondition = (JsonConvert.DeserializeObject <List <CurrentCondition> >(json)).FirstOrDefault(); } return(currentCondition); }
public static async Task <CurrentCondition> GetCurrentConditions(string locationKey) { CurrentCondition currentConditions = new CurrentCondition(); string url = BASE_URL + String.Format(CURRENT_CONDITIONS_ENDPOINT, locationKey, API_KEY); using (HttpClient client = new HttpClient()) { var responce = await client.GetAsync(url); string json = await responce.Content.ReadAsStringAsync(); // отримуємо дані у вигляді json-рядка currentConditions = JsonConvert.DeserializeObject <List <CurrentCondition> >(json)[0]; } return(currentConditions); }
static void Main(string[] args) { WeatherData weatherData = new WeatherData(); CurrentConditionsDisplay currentDisplay = new CurrentConditionsDisplay(weatherData); ForecastDisplay forecastDisplay = new ForecastDisplay(weatherData); weatherData.setMeasurements(1, 2, 3f); weatherData.setMeasurements(2, 3, 4f); weatherData.setMeasurements(30, 4, 5f); WeatherMonitor monitor = new WeatherMonitor(); CurrentCondition condit = new CurrentCondition(); condit.Subscribe(monitor); monitor.SetWeatherMonitor(23, 80, 1000); }
public async void GetTemperature() { await MyLocalization.GetCurrentLocation(); Latitude = MyLocalization.latitude; Longitude = MyLocalization.longitude; if (!useGPS) { Latitude = 40.416775; Longitude = -3.703790; } var url = "/data/2.5/forecast/daily?lat=" + Latitude + "&lon=" + Longitude + "&cnt=5&units=" + units + "&appid=" + apiKey; forecast = await apiService.GetForecast(url); if (apiService.SuccessConnection) { Temperature = Math.Round(forecast.list[0].temp.day); Description = forecast.list[0].weather[0].main; City = forecast.city.name.ToUpper(); CountryCode = forecast.city.country; Humidity = forecast.list[0].humidity + "%"; var windAux = 0.0; windAux = (forecast.list[0].speed * 60 * 60) / 1000; Wind = string.Format("{0:0.00}", windAux); Wind += " km/h"; Clouds = forecast.list[0].clouds + "%"; Pressure = forecast.list[0].pressure.ToString(); Pressure = Pressure.Substring(0, 4) + " pHa"; CurrentCondition = forecast.list[0].weather[0].description; CurrentCondition = char.ToUpper(CurrentCondition[0]) + CurrentCondition.Substring(1); CurrentRange = forecast.list[0].temp.max + "º / " + forecast.list[0].temp.min + "º"; GetCountryName(); AddForecast(); } if (Latitude == 0 && Longitude == 0) { { await Application.Current.MainPage.DisplayAlert("Error", "Can't access to GPS", "Accept"); } } }
public async static Task <CurrentCondition> GetCondition(string citykey) { CurrentCondition cond = new CurrentCondition(); string url = BASE_URL + string.Format(CONDITION, citykey, KEY); using (HttpClient client = new HttpClient()) { var response = await client.GetAsync(url); var json = await response.Content.ReadAsStringAsync(); cond = JsonConvert.DeserializeObject <List <CurrentCondition> >(json).FirstOrDefault(); } return(cond); }
public static async Task <CurrentCondition> CurrentConditionsAsync(string cityKey) { CurrentCondition current = new CurrentCondition(); string url = Base_url + string.Format(CurrentCondition_EndPoint, cityKey, API); using (HttpClient httpClient = new HttpClient()) { var response = await httpClient.GetAsync(url); string json = await response.Content.ReadAsStringAsync(); var currentt = CurrentCondition.FromJson(json); current = (CurrentCondition)currentt.First(); } return(current); }
public static CurrentCondition GetCurrentCondition() { var currentCondition = new CurrentCondition(); currentCondition.DewPointF = 66.9m; currentCondition.ID = 1; currentCondition.Latitude = 35.22m; currentCondition.Longitude = -101.71722m; currentCondition.ObsTime = DateTime.Now; currentCondition.PressureIn = 30.09m; currentCondition.RelHumidity = 84; currentCondition.StationID = "KAMA"; currentCondition.TempF = 72.0m; currentCondition.VisibilityMiles = 10; currentCondition.Weather = "A Few Clouds"; currentCondition.WindDegrees = 150; currentCondition.WindDir = "Southeast"; currentCondition.WindMPH = 10.4m; currentCondition.WindString = $"{currentCondition.WindDir} at {currentCondition.WindMPH}mph"; return(currentCondition); }
public static void Run() { var station = new StationWheader(); var condition = new CurrentCondition(); var forecast = new Forecast(); System.Console.WriteLine("First readings data..."); station.SetReading(26.6f, 54, 1012.1f); condition.Subscribe(station); System.Console.WriteLine("Second readings data..."); station.SetReading(16.6f, 64, 912.2f); forecast.Subscribe(station); System.Console.WriteLine("Third readings data..."); station.SetReading(11.6f, 154, 612.1f); condition.Unsubscribe(); System.Console.WriteLine("Fourth readings data..."); station.SetReading(30.6f, 74, 1112.1f); }
public WeatherVM() { SearchCommand = new SearchCommand(this); Cities = new ObservableCollection <City>(); if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) { SelectedCity = new City { LocalizedName = "Rivne" }; currentCondition = new CurrentCondition { WeatherText = "Sunny", Temperature = new Temperature { Metric = new Units { Value = 11 } } }; } }
public WeatherVM() { if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) { SelectedLocation = new Location { LocalizedName = "Boston" }; CurrentCondition = new CurrentCondition { WeatherText = "Sunny", Temperature = new Temperature { Imperial = new TempSystem { Value = 65 } } }; } SearchCommand = new SearchCommand(this); Locations = new ObservableCollection <Location>(); }
/// <summary> /// Prepare the airplane and contact the Tower /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ContactTower(object sender, ElapsedEventArgs e) { if(_startCondition == StartCondition.Flying) { _currentCondition = CurrentCondition.Landing; } else { _currentCondition = CurrentCondition.TakingOff; } Console.WriteLine("---"); Console.WriteLine(); Console.WriteLine("Airplane " + this.CallSign + ": Requesting runway for " + this.CurrentCondition); Console.WriteLine(); _tower.ReciveInitialRequestFromAirplane(this); }
/// <summary> /// Set airplane status and inform Tower that runway is no longer in use /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CompleteUseOfRunway(object sender, ElapsedEventArgs e) { if(this._currentCondition == CurrentCondition.TakingOff) { this._currentCondition = CurrentCondition.TakenOff; } if(this._currentCondition == CurrentCondition.Landing) { this._currentCondition = CurrentCondition.Landed; } Console.WriteLine("---"); Console.WriteLine(); Console.WriteLine("Airplane " + this.CallSign + ": Has " + this._currentCondition); Console.WriteLine(); _tower.ResetRunway(this.AssignedRunway); }
/// <summary> /// Рассчет получения конкретного статуса /// </summary> /// <param name="Condition"></param> private void ConditionChance(CurrentCondition Condition) { //НЕТ РОЛЕВОЙ СИСТЕМЫ!!! conditions.Conditions.ChangeConditionStatus(Condition.Name, true); }
public void CheckStats() { if (this.ConditionCounter > 3) { this.Controller.updateConsole("Your Goku died lol."); // El personaje muere Running = false; Controller.Finish(); // Mensaje para el GUI de que murio } if (CurrentCondition != null) { this.Controller.updateConsole("Time: " + Time.GetCurrentTime().ToString() + " Day: " + Time.GetCurrentDay().ToString() + " Year: " + Time.GetCurrentYear().ToString()); Console.WriteLine("Random Event: " + CurrentActivity.Name); if (CurrentCondition.Cured((Character)this.CurrentCharacter)) { this.Controller.updateConsole("*** Your goku was cured! ***"); CurrentCondition = null; ConditionCounter = 0; } else { this.Controller.updateConsole("*** Be careful your goku is still sick ***"); CurrentCharacter = CurrentCondition.ExecuteStrat(CurrentCharacter); ConditionCounter++; this.Controller.updateConsole("Sick day coutner: " + this.ConditionCounter.ToString()); } } else { ICondition condition = null; Character character = (Character)CurrentCharacter; this.Controller.updateConsole("Time: " + Time.GetCurrentTime().ToString() + " Day: " + Time.GetCurrentDay().ToString() + " Year: " + Time.GetCurrentYear().ToString()); Console.WriteLine("Random Event: " + CurrentActivity.Name); if (character.Hp < 30 && character.Hunger < 30 && character.Thirst < 30 && newCondition()) { Console.WriteLine("Sick"); this.Controller.updateConditionAppearance("sick"); condition = ConditionController.findCondition("sick"); } else if (character.Energy < 30 && newCondition()) { Console.WriteLine("Tired"); this.Controller.updateConditionAppearance("tired"); condition = ConditionController.findCondition("tired"); } else if (character.Hunger > 100 && character.Thirst > 100 && newCondition()) { Console.WriteLine("Fat"); this.Controller.updateConditionAppearance("fat"); condition = ConditionController.findCondition("fat"); } else if (character.Hp < 30 && newCondition()) { Console.WriteLine("Beatup"); this.Controller.updateConditionAppearance("beatup"); condition = ConditionController.findCondition("beatup"); } CurrentCondition = condition; } if (this.CurrentCondition != null) { this.Controller.updateConditionAppearance(this.CurrentCondition.Name); this.Controller.updateConsole(((Character)this.CurrentCharacter).Name + " is currently " + this.CurrentCondition.Name); } }
public async void currcon() { //Query = string.Empty; //Cities.Clear(); CurrCond = await AccWetherHelper.GetCondition(selectedCity.Key); }