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
0e147fc0
Commit
0e147fc0
authored
Mar 10, 2020
by
COLOMBO Benjamin
Browse files
Implement Open Weather Map API data pull
parent
dcf5b071
Pipeline
#31916
failed with stages
in 26 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
BeeWeatherPollenTracker/App.config
View file @
0e147fc0
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
configuration
>
<
configSections
>
<!--
For
more
information
on
Entity
Framework
configuration
,
visit
http
://
go
.
microsoft
.
com
/
fwlink
/?
LinkID
=
237468
-->
<
section
name
=
"entityFramework"
type
=
"System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission
=
"false"
/>
</
configSections
>
<
startup
>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.7.2"
/>
</
startup
>
<
entityFramework
>
<
providers
>
<
provider
invariantName
=
"System.Data.SqlClient"
type
=
"System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"
/>
</
providers
>
</
entityFramework
>
<!--
For
more
information
on
Entity
Framework
configuration
,
visit
http
://
go
.
microsoft
.
com
/
fwlink
/?
LinkID
=
237468
-->
<
section
name
=
"entityFramework"
type
=
"System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
requirePermission
=
"false"
/>
</
configSections
>
<
startup
>
<
supportedRuntime
version
=
"v4.0"
sku
=
".NETFramework,Version=v4.7.2"
/>
</
startup
>
<
entityFramework
>
<
providers
>
<
provider
invariantName
=
"System.Data.SqlClient"
type
=
"System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"
/>
</
providers
>
</
entityFramework
>
<
appSettings
>
<!-- ... -->
<
add
key
=
"CityId"
value
=
"2925533"
/>
<!-- ... -->
</
appSettings
>
</
configuration
>
\ No newline at end of file
BeeWeatherPollenTracker/BeeWeatherPollenTracker.csproj
View file @
0e147fc0
...
...
@@ -42,8 +42,12 @@
<Reference
Include=
"EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
>
<HintPath>
..\packages\EntityFramework.6.4.0\lib\net45\EntityFramework.SqlServer.dll
</HintPath>
</Reference>
<Reference
Include=
"Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"
>
<HintPath>
..\packages\WeatherNet.2.1\lib\Newtonsoft.Json.dll
</HintPath>
</Reference>
<Reference
Include=
"System"
/>
<Reference
Include=
"System.ComponentModel.DataAnnotations"
/>
<Reference
Include=
"System.Configuration"
/>
<Reference
Include=
"System.Core"
/>
<Reference
Include=
"System.Xml.Linq"
/>
<Reference
Include=
"System.Data.DataSetExtensions"
/>
...
...
@@ -51,6 +55,9 @@
<Reference
Include=
"System.Data"
/>
<Reference
Include=
"System.Net.Http"
/>
<Reference
Include=
"System.Xml"
/>
<Reference
Include=
"WeatherNet, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
..\packages\WeatherNet.2.1\lib\WeatherNet.dll
</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile
Include=
"Program.cs"
/>
...
...
BeeWeatherPollenTracker/Program.cs
View file @
0e147fc0
using
System
;
using
System.Collections.Generic
;
using
System.Configuration
;
using
System.Linq
;
using
System.Tex
t
;
using
System.Threading.Task
s
;
using
WeatherNe
t
;
using
WeatherNet.Client
s
;
namespace
BeeWeatherPollenTracker
{
class
Program
internal
static
class
Program
{
static
void
Main
(
string
[]
args
)
private
const
string
OPEN_WEATHER_MAP_API_KEY
=
"3f80e65ed0609e7e52737e65d522aed8"
;
private
const
double
FORECAST_LENGTH
=
3.0
;
private
static
void
Main
(
string
[]
args
)
{
// Set up API KEY
ClientSettings
.
SetApiKey
(
OPEN_WEATHER_MAP_API_KEY
);
// Retrieve forecast data from from OWM API
var
cityId
=
int
.
Parse
(
ConfigurationManager
.
AppSettings
[
"CityId"
]);
var
apiResults
=
FiveDaysForecast
.
GetByCityId
(
cityId
);
if
(!
apiResults
.
Success
)
{
throw
new
ApplicationException
(
apiResults
.
Message
);
}
// Filter: keep only 3 next days forecast
var
forecast
=
apiResults
.
Items
.
Where
(
x
=>
x
.
Date
<
DateTime
.
Now
.
AddDays
(
FORECAST_LENGTH
))
.
ToList
();
}
}
}
}
\ No newline at end of file
BeeWeatherPollenTracker/packages.config
View file @
0e147fc0
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"EntityFramework"
version
=
"6.4.0"
targetFramework
=
"net472"
/>
<
package
id
=
"WeatherNet"
version
=
"2.1"
targetFramework
=
"net472"
/>
</
packages
>
\ 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