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