diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/X12Asn.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/X12Asn.cs index 3a01b3d..a2cf419 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/X12Asn.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/X12Asn.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.Reflection.PortableExecutable; using System.Threading.Tasks; using Volo.Abp.Domain.Services; +using Volo.Abp.Timing; using Win_in.Sfs.Scp.WebApi.Domain.Shared; namespace Win_in.Sfs.Scp.WebApi.Asns; @@ -108,9 +110,11 @@ public class X12Asn: EntityBase EffectiveDate = newDate; } - public void SetError(EnumExchangeDataErrorCode errorCode, string errorMessage, string remark = null) + public void SetError(string reader,EnumExchangeDataErrorCode errorCode, string errorMessage, string remark = null) { Status = EnumExchangeDataStatus.Error; + ReadTime = DateTime.Now; + Reader = reader; ErrorCode = (int)errorCode; ErrorMessage = errorMessage; Remark = remark; @@ -127,22 +131,19 @@ public class X12Asn: EntityBase public virtual void Reset(string remark = null) { Status = EnumExchangeDataStatus.New; + ReadTime = null; + Reader = null; ErrorCode = (int)EnumExchangeDataErrorCode.None; ErrorMessage = ""; Remark = remark; RetryTimes = 0; } - - public void Take(string remark = null) - { - Status = EnumExchangeDataStatus.Processing; - Remark = remark; - } - - public void SetSuccess(string remark = null) + public void SetSuccess(string reader,string remark = null) { Status = EnumExchangeDataStatus.Finish; + ReadTime = DateTime.Now; + Reader = reader; ErrorCode = (int)EnumExchangeDataErrorCode.None; ErrorMessage = ""; Remark = remark; diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Repositories/X12AsnRepository.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Repositories/X12AsnRepository.cs index ca9f374..9d66bc2 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Repositories/X12AsnRepository.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Repositories/X12AsnRepository.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; + using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Win_in.Sfs.Scp.WebApi.Asns; @@ -11,6 +12,8 @@ namespace Win_in.Sfs.Scp.WebApi.EntityFrameworkCore; public class X12AsnRepository : EfCoreRepository, IX12AsnRepository { + private const string Reader = "QAD Agent"; + public X12AsnRepository(IDbContextProvider dbContextProvider) : base(dbContextProvider) { } @@ -28,7 +31,7 @@ public class X12AsnRepository : EfCoreRepository, { foreach (var entity in list) { - entity.SetSuccess(); + entity.SetSuccess(Reader); await UpdateAsync(entity); } } @@ -49,13 +52,13 @@ public class X12AsnRepository : EfCoreRepository, entity.SetProcessing(); break; case EnumExchangeDataStatus.Finish: - entity.SetSuccess(); + entity.SetSuccess(Reader); break; case EnumExchangeDataStatus.Hold: entity.SetHold(); break; case EnumExchangeDataStatus.Error: - entity.SetError(EnumExchangeDataErrorCode.Exception,""); + entity.SetError(Reader, EnumExchangeDataErrorCode.Exception,""); break; default: throw new ArgumentOutOfRangeException(nameof(status), status, null); diff --git a/WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/AsnBackgroundWorker.cs b/WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/AsnBackgroundWorker.cs index 16bcfde..dc909fd 100644 --- a/WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/AsnBackgroundWorker.cs +++ b/WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/AsnBackgroundWorker.cs @@ -39,10 +39,10 @@ public class AsnBackgroundWorker : AsyncPeriodicBackgroundWorkerBase [UnitOfWork] protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) { - Logger.LogInformation("Starting: Handling Scp Asn data..."); + Logger.LogInformation("Starting: Get ASN from SCP"); if (!_options.Value.Active) { - Logger.LogInformation("Scp Asn is not active!"); + Logger.LogInformation("Switch is closed!"); return; } //Resolve dependencies @@ -71,7 +71,7 @@ public class AsnBackgroundWorker : AsyncPeriodicBackgroundWorkerBase { var scpAsns = await scpAsnManager.GetUnreadAsnsAsync(site,maxUid, _options.Value.BatchSize); - Logger.LogInformation($"{site}: {scpAsns.Count} Scp ASN records were Found"); + Logger.LogInformation($"{site}: {scpAsns.Count} records were Found"); if (scpAsns.Count <= 0) { @@ -117,7 +117,7 @@ public class AsnBackgroundWorker : AsyncPeriodicBackgroundWorkerBase await x12AsnRepository.InsertManyAsync(asnX12List, true); - Logger.LogInformation("Completed: Handling Scp Asn data..."); + Logger.LogInformation("Completed: Get ASN from SCP"); } } \ No newline at end of file