You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.6 KiB
49 lines
1.6 KiB
2 years ago
|
using System.Threading.Tasks;
|
||
|
using Microsoft.Extensions.DependencyInjection;
|
||
|
using Microsoft.Extensions.Logging;
|
||
|
using Microsoft.Extensions.Options;
|
||
|
using Volo.Abp.BackgroundWorkers;
|
||
|
using Volo.Abp.Threading;
|
||
|
using Volo.Abp.Uow;
|
||
|
using Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent.Outgoing;
|
||
|
|
||
|
namespace Win_in.Sfs.Wms.DataExchange.Fawtyg.MesAgent;
|
||
|
|
||
|
public class MesOutgoingBackgroundWorker : AsyncPeriodicBackgroundWorkerBase
|
||
|
{
|
||
|
private readonly string Outgoing = "MES Outgoing";
|
||
|
|
||
|
private readonly IOptions<MesOptions> _options;
|
||
|
|
||
|
public MesOutgoingBackgroundWorker(
|
||
|
AbpAsyncTimer timer
|
||
|
, IOptions<MesOptions> options
|
||
|
, IServiceScopeFactory serviceScopeFactory
|
||
|
) : base(timer, serviceScopeFactory)
|
||
|
{
|
||
|
_options = options;
|
||
|
Timer.Period = options.Value.OutgoingOptions.PeriodSeconds * 1000; //default 10 minutes
|
||
|
|
||
|
}
|
||
|
|
||
|
[UnitOfWork]
|
||
|
protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext)
|
||
|
{
|
||
|
Logger.LogInformation($"Starting: Handling {Outgoing}");
|
||
|
if (!_options.Value.IncomingOptions.Active)
|
||
|
{
|
||
|
Logger.LogInformation($"{Outgoing} is not active!");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
Logger.LogInformation($"Write Issue");
|
||
|
var issueConvert = workerContext.ServiceProvider.GetRequiredService<IssuesConverter>();
|
||
|
var issueNoteList = await issueConvert.ConvertAsync().ConfigureAwait(false);
|
||
|
var issueWriter = workerContext.ServiceProvider.GetRequiredService<IssueNoteWriter>();
|
||
|
await issueWriter.WriteAsync(issueNoteList).ConfigureAwait(false);
|
||
|
|
||
|
Logger.LogInformation($"Completed: Handling {Outgoing}");
|
||
|
}
|
||
|
|
||
|
}
|