blob: 8aebee92a57dadff622feaea607aeb35f7e7ff05 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using VSH.Data.Static;
namespace VSH.BackgroundServices;
public class StartupTasksBackgroundService : BackgroundService
{
private readonly ILogger<StartupTasksBackgroundService> _logger;
private static IEnumerable<string> PathsToEnsureCreated => new List<string> {
AppPaths.ProductImages.HostPath,
AppPaths.DocumentImages.HostPath,
};
public StartupTasksBackgroundService(ILogger<StartupTasksBackgroundService> logger) {
_logger = logger;
}
protected override Task ExecuteAsync(CancellationToken stoppingToken) {
EnsureCreated();
return Task.CompletedTask;
}
private void EnsureCreated() {
foreach (var path in PathsToEnsureCreated) {
Directory.CreateDirectory(path);
_logger.LogInformation("EnsuredCreated: " + path);
}
}
}
|