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> <configuration>
<configSections> <configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
...@@ -77,6 +77,7 @@ ...@@ -77,6 +77,7 @@
<appSettings> <appSettings>
<!-- ... --> <!-- ... -->
<add key="CityId" value="2925533" /> <add key="CityId" value="2925533" />
<add key="PartregionId" value="91" />
<!-- ... --> <!-- ... -->
</appSettings> </appSettings>
</configuration> </configuration>
\ No newline at end of file
<?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"> <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="..\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')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
...@@ -180,7 +180,7 @@ ...@@ -180,7 +180,7 @@
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<DependentUpon>BeesWeatherModel.edmx</DependentUpon> <DependentUpon>BeesWeatherModel.edmx</DependentUpon>
</Compile> </Compile>
<Compile Include="PollenData.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ref_beehive_poll_forecast.cs"> <Compile Include="ref_beehive_poll_forecast.cs">
...@@ -225,4 +225,4 @@ ...@@ -225,4 +225,4 @@
<Error Condition="!Exists('..\packages\EntityFramework.6.4.0\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.0\build\EntityFramework.targets'))" /> <Error Condition="!Exists('..\packages\EntityFramework.6.4.0\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\EntityFramework.6.4.0\build\EntityFramework.targets'))" />
</Target> </Target>
<Import Project="..\packages\EntityFramework.6.4.0\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.0\build\EntityFramework.targets')" /> <Import Project="..\packages\EntityFramework.6.4.0\build\EntityFramework.targets" Condition="Exists('..\packages\EntityFramework.6.4.0\build\EntityFramework.targets')" />
</Project> </Project>
\ No newline at end of file
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 MySql.Data.EntityFramework;
using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration; using System.Configuration;
using System.Data.Entity; using System.Data.Entity;
using System.Linq; using System.Linq;
using System.Net.Http;
using WeatherNet; using WeatherNet;
using WeatherNet.Clients; using WeatherNet.Clients;
...@@ -14,6 +16,8 @@ namespace BeeWeatherPollenTracker ...@@ -14,6 +16,8 @@ namespace BeeWeatherPollenTracker
{ {
private const string OPEN_WEATHER_MAP_API_KEY = "3f80e65ed0609e7e52737e65d522aed8"; private const string OPEN_WEATHER_MAP_API_KEY = "3f80e65ed0609e7e52737e65d522aed8";
private const double FORECAST_LENGTH = 3.0; 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; static LoggerManager logs = null;
private static void Main(string[] args) private static void Main(string[] args)
...@@ -23,7 +27,7 @@ namespace BeeWeatherPollenTracker ...@@ -23,7 +27,7 @@ namespace BeeWeatherPollenTracker
// Set up the logger manager // Set up the logger manager
logs = LoggerManager.GetInstance(); logs = LoggerManager.GetInstance();
// Retrieve forecast data from from OWM API // Retrieve forecast data from from OWM API
try try
{ {
...@@ -38,6 +42,20 @@ namespace BeeWeatherPollenTracker ...@@ -38,6 +42,20 @@ namespace BeeWeatherPollenTracker
var forecast = apiResults.Items var forecast = apiResults.Items
.Where(x => x.Date < DateTime.Now.AddDays(FORECAST_LENGTH)) .Where(x => x.Date < DateTime.Now.AddDays(FORECAST_LENGTH))
.ToList(); .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) catch (Exception e)
{ {
...@@ -45,4 +63,4 @@ namespace BeeWeatherPollenTracker ...@@ -45,4 +63,4 @@ namespace BeeWeatherPollenTracker
} }
} }
} }
} }
\ No newline at end of file
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