public WeatherDataModel GetWeather(string cityCode) { var responseAccuWeather = Webber.Get <AccuWeather>( $"http://dataservice.accuweather.com/forecasts/v1/daily/1day/{cityCode}" + $"?apikey={_apiKey}" + "&details=true" + "&metric=true" ); var weather = responseAccuWeather.Result.DailyForecasts.FirstOrDefault(); if (weather == null) { return(null); } return(new WeatherDataModel { MinimumTemperature = weather.Temperature.Minimum.Value, MaximumTemperature = weather.Temperature.Maximum.Value, SunlightDuration = DateTime.Parse(weather.Sun.Set) - DateTime.Parse(weather.Sun.Rise), RealFeelTemperature = (weather.RealFeelTemperature.Minimum.Value + weather.RealFeelTemperature.Maximum.Value) / 2, WindSpeed = weather.Day.Wind.Speed.Value, WindDirection = weather.Day.Wind.Direction.English, PrecipitationProbability = weather.Day.PrecipitationProbability }); }
private void btnSearchSym_Click(object sender, EventArgs e) { txtQuery.Text = string.Empty; string[] syml = txtSym.Text.Trim().Split('-'); string sym = syml[0]; string ex = syml[1]; { txtQuery.Text += "select * from pr where pr.rt = trim('" + sym + "'); " + Environment.NewLine; txtQuery.Text += "select * from ar_view where ar_view.rt = trim('" + sym + "');" + Environment.NewLine; txtQuery.Text += "select * from per where per.rt = trim('" + sym + "');" + Environment.NewLine; if (ex.Trim().ToLower() == "x") { txtQuery.Text += "select * from tx_sec_view where root_ticker = trim('" + sym + "');" + Environment.NewLine; txtQuery.Text += "select * from tx_res_view where root_ticker = trim('" + sym + "');" + Environment.NewLine; txtQuery.Text += "select * from tx_region_view where root_ticker = trim('" + sym + "');" + Environment.NewLine; } else { txtQuery.Text += "select * from t_sec_view where root__ticker = trim('" + sym + "');" + Environment.NewLine; txtQuery.Text += "select * from t_res_view where root__ticker = trim('" + sym + "');" + Environment.NewLine; txtQuery.Text += "select * from t_region_view where root__ticker = trim('" + sym + "');" + Environment.NewLine; } } if (chkDb.Checked) { if (this.db == null) { this.db = new SSIS.DashBoard(); } this.db.Hide(); SSIS.tsEntities alDb = new SSIS.tsEntities(); this.db.SetSymbol(sym, ex); this.db.Show(); } txtQuery.SelectionStart = 0; txtQuery.SelectionLength = txtQuery.Text.Length; chkSqlServer.Checked = true; chkSqlServer.CheckState = CheckState.Checked; btnExecuteQuery_Click(null, null); Debug.WriteLine(Webber.GetMStarOwnershipInfo(sym, ex)); }
public CityDataModel GetCityInformation(string cityName) { var citiesResponse = Webber.Get <Location[]>( "http://dataservice.accuweather.com/locations/v1/cities/search" + $"?apikey={_apiKey}" + $"&q={cityName}" + "&details=true" ); var city = citiesResponse .Result .OrderBy(x => x.Rank) .FirstOrDefault(); return(city != null ? CityDataModel.BuildSuccess(city) : CityDataModel.BuildFailed()); }