Commit dcfa5cb7 authored by Charles Still's avatar Charles Still
Browse files

Fiw merge

parents 24b200e9 4c4d1d86
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
......@@ -77,6 +77,7 @@
<appSettings>
<!-- ... -->
<add key="CityId" value="2925533" />
<add key="PartregionId" value="91" />
<!-- ... -->
</appSettings>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\EntityFramework.6.4.0\build\EntityFramework.props" Condition="Exists('..\packages\EntityFramework.6.4.0\build\EntityFramework.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
......@@ -180,7 +180,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>BeesWeatherModel.edmx</DependentUpon>
</Compile>
<Compile Include="PollenData.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ref_beehive_poll_forecast.cs">
......
using System.Collections.Generic;
using Newtonsoft.Json;
namespace BeeWeatherPollenTracker
{
public partial class ClimateEnvironment
{
[JsonProperty("next_update")]
public string NextUpdate { get; set; }
[JsonProperty("last_update")]
public string LastUpdate { get; set; }
[JsonProperty("sender")]
public string Sender { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("content")]
public List<Content> Content { get; set; }
}
public partial class Content
{
[JsonProperty("region_id")]
public long RegionId { get; set; }
[JsonProperty("partregion_name")]
public string PartregionName { get; set; }
[JsonProperty("region_name")]
public string RegionName { get; set; }
[JsonProperty("Pollen")]
public Pollen Pollen { get; set; }
[JsonProperty("partregion_id")]
public long PartregionId { get; set; }
}
public partial class Pollen
{
[JsonProperty("Birke")]
public PollenForecast Birke { get; set; }
[JsonProperty("Graeser")]
public PollenForecast Graeser { get; set; }
[JsonProperty("Beifuss")]
public PollenForecast Beifuss { get; set; }
[JsonProperty("Ambrosia")]
public PollenForecast Ambrosia { get; set; }
[JsonProperty("Erle")]
public PollenForecast Erle { get; set; }
[JsonProperty("Roggen")]
public PollenForecast Roggen { get; set; }
[JsonProperty("Esche")]
public PollenForecast Esche { get; set; }
[JsonProperty("Hasel")]
public PollenForecast Hasel { get; set; }
}
public partial class PollenForecast
{
[JsonProperty("today")]
public string Today { get; set; }
[JsonProperty("dayafter_to")]
public string DayafterTo { get; set; }
[JsonProperty("tomorrow")]
public string Tomorrow { get; set; }
}
}
\ No newline at end of file
using MySql.Data.EntityFramework;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.Entity;
using System.Linq;
using System.Net.Http;
using WeatherNet;
using WeatherNet.Clients;
......@@ -14,6 +16,8 @@ namespace BeeWeatherPollenTracker
{
private const string OPEN_WEATHER_MAP_API_KEY = "3f80e65ed0609e7e52737e65d522aed8";
private const double FORECAST_LENGTH = 3.0;
private const string POLLEN_FORECAST_URL =
"https://opendata.dwd.de/climate_environment/health/alerts/s31fg.json";
static LoggerManager logs = null;
private static void Main(string[] args)
......@@ -38,6 +42,20 @@ namespace BeeWeatherPollenTracker
var forecast = apiResults.Items
.Where(x => x.Date < DateTime.Now.AddDays(FORECAST_LENGTH))
.ToList();
// Get Pollen Data
ClimateEnvironment pollenData;
using (HttpClient pollenClient = new HttpClient())
{
var pollenResults = pollenClient.GetAsync(POLLEN_FORECAST_URL).Result;
var pollenJson = pollenResults.Content.ReadAsStringAsync().Result;
pollenData = JsonConvert.DeserializeObject<ClimateEnvironment>(pollenJson);
}
var pollenRegionForecast = pollenData.Content
.First(p => p.PartregionId.ToString() == ConfigurationManager.AppSettings["PartregionId"]);
}
catch (Exception e)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment