diff --git a/JackMail.sln b/JackMail.sln new file mode 100644 index 0000000..5457a86 --- /dev/null +++ b/JackMail.sln @@ -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 diff --git a/JackMail/JackMail.csproj b/JackMail/JackMail.csproj new file mode 100644 index 0000000..093ad76 --- /dev/null +++ b/JackMail/JackMail.csproj @@ -0,0 +1,14 @@ + + + + net5.0 + dotnet-JackMail-3363D956-FACF-45AF-9B24-53666388FBC1 + + + + + + + + + diff --git a/JackMail/Program.cs b/JackMail/Program.cs new file mode 100644 index 0000000..261d368 --- /dev/null +++ b/JackMail/Program.cs @@ -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(); + services.AddHostedService(); + services.AddHostedService(); + }); + } +} diff --git a/JackMail/Properties/launchSettings.json b/JackMail/Properties/launchSettings.json new file mode 100644 index 0000000..33a5c24 --- /dev/null +++ b/JackMail/Properties/launchSettings.json @@ -0,0 +1,11 @@ +{ + "profiles": { + "JackMail": { + "commandName": "Project", + "dotnetRunMessages": "true", + "environmentVariables": { + "DOTNET_ENVIRONMENT": "Development" + } + } + } +} diff --git a/JackMail/Services/Receive.cs b/JackMail/Services/Receive.cs new file mode 100644 index 0000000..12a5a9d --- /dev/null +++ b/JackMail/Services/Receive.cs @@ -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 _logger; + + public Receive(ILogger 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); + } + } + } +} diff --git a/JackMail/Services/Retrieve.cs b/JackMail/Services/Retrieve.cs new file mode 100644 index 0000000..5eb36bc --- /dev/null +++ b/JackMail/Services/Retrieve.cs @@ -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 _logger; + + public Retrieve(ILogger 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); + } + } + } +} diff --git a/JackMail/Services/Send.cs b/JackMail/Services/Send.cs new file mode 100644 index 0000000..ade6c7b --- /dev/null +++ b/JackMail/Services/Send.cs @@ -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 _logger; + + public Send(ILogger 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); + } + } + } +} diff --git a/JackMail/appsettings.Development.json b/JackMail/appsettings.Development.json new file mode 100644 index 0000000..8983e0f --- /dev/null +++ b/JackMail/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/JackMail/appsettings.json b/JackMail/appsettings.json new file mode 100644 index 0000000..8983e0f --- /dev/null +++ b/JackMail/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +}