Skip to content

Commit bec9ec8

Browse files
authored
Add files via upload
1 parent 636a2fd commit bec9ec8

13 files changed

+14411
-0
lines changed

HTTP ECGridOS API v4.1 .NET 6 Worker Service/ECGridOSClient.cs

Lines changed: 10223 additions & 0 deletions
Large diffs are not rendered by default.

HTTP ECGridOS API v4.1 .NET 6 Worker Service/ECGridOS_Classes.cs

Lines changed: 2484 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Worker">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<UserSecretsId>dotnet-HTTP_ECGridOS_API_v4._1_.NET_6_Worker_Service-1274D83A-3A20-4BF3-87C8-490E1D9ED71A</UserSecretsId>
8+
<RootNamespace>HTTP_ECGridOS_API_v4._1_.NET_6_Worker_Service</RootNamespace>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
13+
<PackageReference Include="Microsoft.Extensions.Http" Version="6.0.0" />
14+
</ItemGroup>
15+
</Project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using HTTP_ECGridOS_API_v4._1_.NET_6_Worker_Service;
2+
3+
IHost host = Host.CreateDefaultBuilder(args)
4+
.ConfigureServices(services =>
5+
{
6+
services.AddHttpClient<IECGridOSClient, ECGridOSClient>(client =>
7+
{
8+
client.BaseAddress = new Uri("https://os.ecgrid.io/v4.1/prod/ECGridOS.asmx/");
9+
client.Timeout = TimeSpan.FromMinutes(10);
10+
}).SetHandlerLifetime(TimeSpan.FromMinutes(720)); // Reuse connection pool for 12 hour before getting a new one
11+
12+
services.AddHostedService<Worker>();
13+
})
14+
.Build();
15+
16+
await host.RunAsync();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"profiles": {
3+
"HTTP_ECGridOS_API_v4._1_.NET_6_Worker_Service": {
4+
"commandName": "Project",
5+
"dotnetRunMessages": true,
6+
"environmentVariables": {
7+
"DOTNET_ENVIRONMENT": "Development"
8+
}
9+
}
10+
}
11+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
namespace HTTP_ECGridOS_API_v4._1_.NET_6_Worker_Service;
2+
3+
public class Worker : BackgroundService
4+
{
5+
private readonly ILogger<Worker> _logger;
6+
private readonly IConfiguration _Configuration;
7+
private readonly IECGridOSClient _ECGridOSClient;
8+
private readonly string APIKey = String.Empty;
9+
10+
public Worker(ILogger<Worker> logger, IConfiguration Configuration, IECGridOSClient ECGridOSClient)
11+
{
12+
_logger = logger;
13+
_Configuration = Configuration;
14+
_ECGridOSClient = ECGridOSClient;
15+
APIKey = _Configuration["ECGridOS:APIKey"];
16+
}
17+
18+
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
19+
{
20+
while (!stoppingToken.IsCancellationRequested)
21+
{
22+
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
23+
24+
string APIVersion = await _ECGridOSClient.Version();
25+
if (!string.IsNullOrEmpty(APIVersion))
26+
{
27+
_logger.LogInformation($"ECGridOS API is Running Version {APIVersion} at: {DateTimeOffset.Now}");
28+
}
29+
30+
SessionInfo sessionInfo = await _ECGridOSClient.WhoAmI(APIKey);
31+
if (sessionInfo != null)
32+
{
33+
_logger.LogInformation($"ECGridOS Session ID: {sessionInfo.SessionID} at: {DateTimeOffset.Now}");
34+
}
35+
36+
_logger.LogInformation(Environment.NewLine);
37+
38+
await Task.Delay(10000, stoppingToken);
39+
}
40+
}
41+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.Hosting.Lifetime": "Information"
6+
}
7+
},
8+
"ECGridOS": {
9+
"Host": "https://os.ecgrid.io/v4.1/prod/ECGridOS.asmx/",
10+
"APIKey": "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft.Hosting.Lifetime": "Information"
6+
}
7+
},
8+
"ECGridOS": {
9+
"Host": "https://os.ecgrid.io/v4.1/prod/ECGridOS.asmx/",
10+
"APIKey": "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"
11+
}
12+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"format": 1,
3+
"restore": {
4+
"F:\\LD_Code\\HTTP ECGridOS API v4.1 .NET 6 Worker Service\\HTTP ECGridOS API v4.1 .NET 6 Worker Service\\HTTP ECGridOS API v4.1 .NET 6 Worker Service.csproj": {}
5+
},
6+
"projects": {
7+
"F:\\LD_Code\\HTTP ECGridOS API v4.1 .NET 6 Worker Service\\HTTP ECGridOS API v4.1 .NET 6 Worker Service\\HTTP ECGridOS API v4.1 .NET 6 Worker Service.csproj": {
8+
"version": "1.0.0",
9+
"restore": {
10+
"projectUniqueName": "F:\\LD_Code\\HTTP ECGridOS API v4.1 .NET 6 Worker Service\\HTTP ECGridOS API v4.1 .NET 6 Worker Service\\HTTP ECGridOS API v4.1 .NET 6 Worker Service.csproj",
11+
"projectName": "HTTP ECGridOS API v4.1 .NET 6 Worker Service",
12+
"projectPath": "F:\\LD_Code\\HTTP ECGridOS API v4.1 .NET 6 Worker Service\\HTTP ECGridOS API v4.1 .NET 6 Worker Service\\HTTP ECGridOS API v4.1 .NET 6 Worker Service.csproj",
13+
"packagesPath": "C:\\Users\\gkolinski\\.nuget\\packages\\",
14+
"outputPath": "F:\\LD_Code\\HTTP ECGridOS API v4.1 .NET 6 Worker Service\\HTTP ECGridOS API v4.1 .NET 6 Worker Service\\obj\\",
15+
"projectStyle": "PackageReference",
16+
"fallbackFolders": [
17+
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
18+
],
19+
"configFilePaths": [
20+
"C:\\Users\\gkolinski\\AppData\\Roaming\\NuGet\\NuGet.Config",
21+
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
22+
],
23+
"originalTargetFrameworks": [
24+
"net6.0"
25+
],
26+
"sources": {
27+
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
28+
"https://api.nuget.org/v3/index.json": {}
29+
},
30+
"frameworks": {
31+
"net6.0": {
32+
"targetAlias": "net6.0",
33+
"projectReferences": {}
34+
}
35+
},
36+
"warningProperties": {
37+
"warnAsError": [
38+
"NU1605"
39+
]
40+
}
41+
},
42+
"frameworks": {
43+
"net6.0": {
44+
"targetAlias": "net6.0",
45+
"dependencies": {
46+
"Microsoft.Extensions.Hosting": {
47+
"target": "Package",
48+
"version": "[6.0.1, )"
49+
},
50+
"Microsoft.Extensions.Http": {
51+
"target": "Package",
52+
"version": "[6.0.0, )"
53+
}
54+
},
55+
"imports": [
56+
"net461",
57+
"net462",
58+
"net47",
59+
"net471",
60+
"net472",
61+
"net48",
62+
"net481"
63+
],
64+
"assetTargetFallback": true,
65+
"warn": true,
66+
"frameworkReferences": {
67+
"Microsoft.NETCore.App": {
68+
"privateAssets": "all"
69+
}
70+
},
71+
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\6.0.400\\RuntimeIdentifierGraph.json"
72+
}
73+
}
74+
}
75+
}
76+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
4+
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
5+
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
6+
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
7+
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
8+
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\gkolinski\.nuget\packages\;C:\Program Files\dotnet\sdk\NuGetFallbackFolder</NuGetPackageFolders>
9+
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
10+
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.3.0</NuGetToolVersion>
11+
</PropertyGroup>
12+
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
13+
<SourceRoot Include="C:\Users\gkolinski\.nuget\packages\" />
14+
<SourceRoot Include="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\" />
15+
</ItemGroup>
16+
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
17+
<Import Project="$(NuGetPackageRoot)microsoft.extensions.configuration.usersecrets\6.0.1\buildTransitive\netstandard2.0\Microsoft.Extensions.Configuration.UserSecrets.props" Condition="Exists('$(NuGetPackageRoot)microsoft.extensions.configuration.usersecrets\6.0.1\buildTransitive\netstandard2.0\Microsoft.Extensions.Configuration.UserSecrets.props')" />
18+
</ImportGroup>
19+
</Project>

0 commit comments

Comments
 (0)