Add initial project files.

This commit is contained in:
Jack Hadrill 2021-07-11 14:47:09 +01:00
parent e64bd583a5
commit 6eeaa88776
9 changed files with 172 additions and 0 deletions

25
JackMail.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.808.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JackMail", "JackMail\JackMail.csproj", "{970B9ABF-A628-4804-B7C7-257BC0DF1B56}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{970B9ABF-A628-4804-B7C7-257BC0DF1B56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{970B9ABF-A628-4804-B7C7-257BC0DF1B56}.Debug|Any CPU.Build.0 = Debug|Any CPU
{970B9ABF-A628-4804-B7C7-257BC0DF1B56}.Release|Any CPU.ActiveCfg = Release|Any CPU
{970B9ABF-A628-4804-B7C7-257BC0DF1B56}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AD439AF1-92B7-4026-9249-EF111B6F9E2E}
EndGlobalSection
EndGlobal

14
JackMail/JackMail.csproj Normal file
View File

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>dotnet-JackMail-3363D956-FACF-45AF-9B24-53666388FBC1</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Services\" />
</ItemGroup>
</Project>

23
JackMail/Program.cs Normal file
View File

@ -0,0 +1,23 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using JackMail.Services;
namespace JackMail
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureServices((hostContext, services) =>
{
services.AddHostedService<Send>();
services.AddHostedService<Receive>();
services.AddHostedService<Retrieve>();
});
}
}

View File

@ -0,0 +1,11 @@
{
"profiles": {
"JackMail": {
"commandName": "Project",
"dotnetRunMessages": "true",
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace JackMail.Services
{
public class Receive : BackgroundService
{
private readonly ILogger<Receive> _logger;
public Receive(ILogger<Receive> logger)
{
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
await Task.Delay(1000, stoppingToken);
}
}
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace JackMail.Services
{
public class Retrieve : BackgroundService
{
private readonly ILogger<Retrieve> _logger;
public Retrieve(ILogger<Retrieve> logger)
{
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
await Task.Delay(1000, stoppingToken);
}
}
}
}

27
JackMail/Services/Send.cs Normal file
View File

@ -0,0 +1,27 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace JackMail.Services
{
public class Send : BackgroundService
{
private readonly ILogger<Send> _logger;
public Send(ILogger<Send> logger)
{
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
await Task.Delay(1000, stoppingToken);
}
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}