Syncher fix
This commit is contained in:
@@ -1,12 +1,24 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using PARR.AIHIT;
|
||||
using PARR.DAL;
|
||||
using PARR.Mail;
|
||||
using PARR.Worker;
|
||||
using PARR.Worker.Settings;
|
||||
using Serilog;
|
||||
using System.Text;
|
||||
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
|
||||
IHost host = Host.CreateDefaultBuilder(args)
|
||||
.ConfigureServices((hostContext, services) =>
|
||||
{
|
||||
IConfiguration configuration = hostContext.Configuration;
|
||||
|
||||
var workerSettings = new WorkerSettings();
|
||||
workerSettings = hostContext.Configuration.GetSection(nameof(WorkerSettings)).Get<WorkerSettings>();
|
||||
services.AddSingleton(workerSettings);
|
||||
|
||||
|
||||
services.InstallMailServices(hostContext.Configuration);
|
||||
services.InstallDalServices(hostContext.Configuration);
|
||||
services.InstallerSyncerServices(hostContext.Configuration);
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace PARR.Worker.Settings
|
||||
{
|
||||
internal class SyncherSettings
|
||||
{
|
||||
public int OccursEvery { get; set; }
|
||||
public string? IncludeAddresses { get; set; }
|
||||
|
||||
public List<string> IncludeAddressesArray => IncludeAddresses == null ? new List<string>() : IncludeAddresses.Split(",").ToList();
|
||||
}
|
||||
}
|
||||
7
PARR.Worker/PARR.Worker/Settings/WorkerSettings.cs
Normal file
7
PARR.Worker/PARR.Worker/Settings/WorkerSettings.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace PARR.Worker.Settings
|
||||
{
|
||||
public class WorkerSettings
|
||||
{
|
||||
public int OccursEvery { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using PARR.AIHIT;
|
||||
using PARR.Worker.Settings;
|
||||
|
||||
namespace PARR.Worker
|
||||
{
|
||||
@@ -6,11 +7,16 @@ namespace PARR.Worker
|
||||
{
|
||||
private readonly ILogger<Worker> logger;
|
||||
private readonly IServiceProvider serviceProvider;
|
||||
private readonly WorkerSettings workerSettings;
|
||||
|
||||
public Worker(ILogger<Worker> logger, IServiceProvider serviceProvider)
|
||||
public Worker(ILogger<Worker> logger,
|
||||
IServiceProvider serviceProvider,
|
||||
WorkerSettings workerSettings
|
||||
)
|
||||
{
|
||||
this.logger = logger;
|
||||
this.serviceProvider = serviceProvider;
|
||||
this.workerSettings = workerSettings;
|
||||
}
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
||||
@@ -30,7 +36,7 @@ namespace PARR.Worker
|
||||
|
||||
//await attachmentUploader.UploadAsync();
|
||||
//logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
|
||||
await Task.Delay(60 * 1000, stoppingToken);
|
||||
await Task.Delay(workerSettings.OccursEvery, stoppingToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,9 +33,11 @@
|
||||
"SSL": false,
|
||||
"UserName": "IVC_Robot"
|
||||
},
|
||||
"AIHITSyncherSettings": {
|
||||
"OccursEvery": 60000,
|
||||
"SyncherSettings": {
|
||||
"IncludeAddresses": "aihit@gvc.rzd"
|
||||
},
|
||||
"WorkerSettings": {
|
||||
"OccursEvery": 60000
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user