|
|
@ -30,7 +30,7 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
{ |
|
|
|
public class AsnBackgroundWorker : AsyncPeriodicBackgroundWorkerBase |
|
|
|
{ |
|
|
|
private readonly IOptions<AsnOptions> _options; |
|
|
|
private readonly AsnOptions _options; |
|
|
|
private readonly IObjectMapper _objectMapper; |
|
|
|
|
|
|
|
public AsnBackgroundWorker( |
|
|
@ -40,7 +40,7 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
IObjectMapper objectMapper |
|
|
|
) : base(timer, serviceScopeFactory) |
|
|
|
{ |
|
|
|
_options = options; |
|
|
|
_options = options.Value; |
|
|
|
_objectMapper = objectMapper; |
|
|
|
Timer.Period = options.Value.PeriodSeconds * 1000; //default 5 minutes
|
|
|
|
} |
|
|
@ -49,7 +49,7 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) |
|
|
|
{ |
|
|
|
Logger.LogInformation("Get ASN from SCP: Start"); |
|
|
|
if (!_options.Value.Active) |
|
|
|
if (!_options.Active) |
|
|
|
{ |
|
|
|
Logger.LogInformation("Get ASN from SCP: Switch is closed!"); |
|
|
|
return; |
|
|
@ -64,7 +64,7 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
var dataFilter = workerContext.ServiceProvider.GetRequiredService<IDataFilter>(); |
|
|
|
//Do the work
|
|
|
|
|
|
|
|
foreach (var site in _options.Value.Sites) |
|
|
|
foreach (var site in _options.Sites) |
|
|
|
{ |
|
|
|
var asnX12List = new List<X12Asn>(); |
|
|
|
// var noPoAsnList = new List<AsnMstr>();
|
|
|
@ -93,7 +93,7 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
|
|
|
|
Logger.LogInformation($"{siteCode}: Last UID is {lastUid}"); |
|
|
|
var scpAsns = |
|
|
|
await scpAsnManager.GetUnreadAsnsAsync(siteCode, lastUid, _options.Value.BatchSize); |
|
|
|
await scpAsnManager.GetUnreadAsnsAsync(siteCode, lastUid, _options.BatchSize); |
|
|
|
|
|
|
|
Logger.LogInformation($"{siteCode}: {scpAsns.Count} ASNs were Found"); |
|
|
|
|
|
|
@ -101,16 +101,14 @@ namespace Win_in.Sfs.Scp.WebApi |
|
|
|
{ |
|
|
|
var barcodes = await scpAsnManager.GetBarcodesAsync(siteCode, asn.AsnBillNum); |
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(asn.PoBillNum)) //without PO
|
|
|
|
{ |
|
|
|
var noPoAsn = CreateNoPoAsn(asn, barcodes); |
|
|
|
asnX12List.Add(noPoAsn); |
|
|
|
} |
|
|
|
else //with PO
|
|
|
|
if (asn.AsnBillNum.StartsWith(_options.QadAsnPrefix))//ASN to QAD
|
|
|
|
{ |
|
|
|
var asnX12 = CreateX12Asn(site, asn, barcodes); |
|
|
|
asnX12List.Add(asnX12); |
|
|
|
} |
|
|
|
var noPoAsn = CreateNoPoAsn(asn, barcodes); |
|
|
|
asnX12List.Add(noPoAsn); |
|
|
|
|
|
|
|
Logger.LogInformation($"{siteCode}:{asn.Id} {asn.AsnBillNum} was loaded"); |
|
|
|
} |
|
|
|
} |
|
|
|