Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Ilka Kistinger
bee-weather
Commits
4c4d1d86
Commit
4c4d1d86
authored
Mar 11, 2020
by
Michael Bellinger
Committed by
thomas.crochemore
Mar 11, 2020
Browse files
Implement Pollen Data Pull
parent
73bb5cf5
Changes
4
Hide whitespace changes
Inline
Side-by-side
BeeWeatherPollenTracker/App.config
View file @
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
>
\ No newline at end of file
</
configuration
>
BeeWeatherPollenTracker/BeeWeatherPollenTracker.csproj
View file @
4c4d1d86
<?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')"
/>
...
...
@@ -178,6 +178,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"
>
...
...
@@ -222,4 +223,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'))"
/>
</Target>
<Import
Project=
"..\packages\EntityFramework.6.4.0\build\EntityFramework.targets"
Condition=
"Exists('..\packages\EntityFramework.6.4.0\build\EntityFramework.targets')"
/>
</Project>
\ No newline at end of file
</Project>
BeeWeatherPollenTracker/PollenData.cs
0 → 100644
View file @
4c4d1d86
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
BeeWeatherPollenTracker/Program.cs
View file @
4c4d1d86
<<<<<<<
HEAD
using
MySql.Data.EntityFramework
;
=======
using
Newtonsoft.Json
;
>>>>>>>
Implement
Pollen
Data
Pull
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 +19,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"
;
private
static
void
Main
(
string
[]
args
)
{
...
...
@@ -32,6 +39,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"
]);
}
}
}
\ No newline at end of file
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment