Browse Source

[fix]填写Reader和ReadTime

master
贾荣国 3 years ago
parent
commit
fd791fe659
  1. 19
      WebApiService/src/Win_in.Sfs.Scp.WebApi.Domain/Asns/X12Asn.cs
  2. 9
      WebApiService/src/Win_in.Sfs.Scp.WebApi.EntityFrameworkCore/Repositories/X12AsnRepository.cs
  3. 8
      WebApiService/src/Win_in.Sfs.Scp.WebApi.HttpApi.Host/AsnBackgroundWorker/AsnBackgroundWorker.cs

19
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<Guid>
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<Guid>
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;

9
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<WebApiDbContext, X12Asn, Guid>, IX12AsnRepository
{
private const string Reader = "QAD Agent";
public X12AsnRepository(IDbContextProvider<WebApiDbContext> dbContextProvider) : base(dbContextProvider)
{
}
@ -28,7 +31,7 @@ public class X12AsnRepository : EfCoreRepository<WebApiDbContext, X12Asn, Guid>,
{
foreach (var entity in list)
{
entity.SetSuccess();
entity.SetSuccess(Reader);
await UpdateAsync(entity);
}
}
@ -49,13 +52,13 @@ public class X12AsnRepository : EfCoreRepository<WebApiDbContext, X12Asn, Guid>,
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);

8
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");
}
}
Loading…
Cancel
Save