Adding
This commit is contained in:
@@ -29,6 +29,7 @@ RUN dotnet publish ./source/LCU.API.Internal.MemberPreferencesApi/LCU.API.Intern
|
||||
# ASP.NET Core
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine3.20
|
||||
RUN apk add --no-cache icu-libs && apk add --no-cache tzdata;
|
||||
ENV TZ America/Chicago
|
||||
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
|
||||
ENV ASPNETCORE_ENVIRONMENT=Development
|
||||
|
||||
|
||||
+2
-3
@@ -13,9 +13,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LCU.Api.Internal.FTPLib" Version="2.11.2" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||
<PackageReference Include="nunit" Version="4.1.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
|
||||
<PackageReference Include="FluentAssertions" Version="5.10.3" />
|
||||
<PackageReference Include="Moq" Version="4.13.1" />
|
||||
|
||||
+16
-35
@@ -4,61 +4,42 @@ using Moq;
|
||||
using NUnit.Framework;
|
||||
using LCU.API.Internal.MemberPreferencesApiLib.Repositories;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.XdiServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Configuration;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
using LCU.Library.Internal.LcuMassTransitModels;
|
||||
using LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.IntegrationTests
|
||||
{
|
||||
public class XdiTransferTest
|
||||
public class XdiBatchItemTest
|
||||
{
|
||||
private IXdiBatchService _xdiBatchItemService;
|
||||
private Mock<IXdiBatchItemsRepository> _mockBatchItemsRepository;
|
||||
private Mock<IUnitOfWork> _mockUnitOfWork;
|
||||
private XdiSftpApiConfiguration _xdiSftpConfiguration;
|
||||
private FtpApiConfiguration _ftpConfiguration;
|
||||
private Mock<IUnifiedOptInRepository> _mockUnifiedOptinRepository;
|
||||
private Mock<IMemberPreferenceRepository> _mockMemberPreferenceRepository;
|
||||
private Mock<IFtpApiService> _mockFtpApiService;
|
||||
private ConnectionConfiguration _connectionConfiguration;
|
||||
private ReceiveEndpointConfiguration _completionReceiveEndpoint;
|
||||
private ReceiveEndpointConfigurations _endpointConfiguration;
|
||||
private Mock<IFileOperationsApiService> _mockFileOperationsApiService;
|
||||
private IMock<IXdiBatchProcessInfoRepository> _mockXdiBatchProcessInfoRepository;
|
||||
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_mockFtpApiService = new Mock<IFtpApiService>();
|
||||
_connectionConfiguration = new ConnectionConfiguration();
|
||||
_mockBatchItemsRepository = new Mock<IXdiBatchItemsRepository>();
|
||||
_mockMemberPreferenceRepository = new Mock<IMemberPreferenceRepository>();
|
||||
_endpointConfiguration = new ReceiveEndpointConfigurations();
|
||||
_completionReceiveEndpoint = _endpointConfiguration.XdiBatchConfirmEndpoint;
|
||||
_mockUnitOfWork = new Mock<IUnitOfWork>();
|
||||
_ftpConfiguration = new FtpApiConfiguration()
|
||||
{
|
||||
Url = "https://qa-ftpapi.lcu-internal.com/api/"
|
||||
};
|
||||
_xdiSftpConfiguration = new XdiSftpApiConfiguration()
|
||||
|
||||
{
|
||||
HostName = "sftp.xdi.com",
|
||||
UserName = "LANDMARKCU",
|
||||
PortNumber = 22,
|
||||
Password = "FILLMEIN",
|
||||
Fingerprint = "ssh-dss 2048 12:78:33:0a:cf:71:21:e2:8b:0e:ef:6a:8a:c6:8e:4f"
|
||||
};
|
||||
|
||||
_mockFileOperationsApiService = new Mock<IFileOperationsApiService>();
|
||||
_mockUnifiedOptinRepository = new Mock<IUnifiedOptInRepository>();
|
||||
_mockBatchItemsRepository = new Mock<IXdiBatchItemsRepository>();
|
||||
_mockXdiBatchProcessInfoRepository = new Mock<IXdiBatchProcessInfoRepository>();
|
||||
_mockUnitOfWork = new Mock<IUnitOfWork>();
|
||||
_mockUnifiedOptinRepository = new Mock<IUnifiedOptInRepository>();
|
||||
_mockMemberPreferenceRepository = new Mock<IMemberPreferenceRepository>();
|
||||
_mockFileOperationsApiService = new Mock<IFileOperationsApiService>();
|
||||
|
||||
_xdiBatchItemService = new XdiBatchService(_mockBatchItemsRepository.Object, _mockUnitOfWork.Object,
|
||||
_xdiSftpConfiguration, _mockUnifiedOptinRepository.Object, _mockMemberPreferenceRepository.Object,
|
||||
_connectionConfiguration, _endpointConfiguration, _mockFtpApiService.Object);
|
||||
_mockUnifiedOptinRepository.Object, _mockMemberPreferenceRepository.Object,
|
||||
_mockFileOperationsApiService.Object, _mockXdiBatchProcessInfoRepository.Object);
|
||||
}
|
||||
|
||||
|
||||
[Ignore("This will actually create the items and FTP them to XDI Test Folder. Be Careful. Fill in password.")]
|
||||
public void Test_Send_Test_Files()
|
||||
[Test]
|
||||
public void Test_XdiBatchItem_Setup()
|
||||
{
|
||||
IReadOnlyCollection<XdiBatchItem> items = new List<XdiBatchItem>()
|
||||
{
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
@@ -9,11 +9,11 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FluentAssertions" Version="6.8.0" />
|
||||
<PackageReference Include="LCU.Api.Internal.FTPLib" Version="2.11.2" />
|
||||
<PackageReference Include="LCU.Library.Internal.CoreApiWrapperModel" Version="2.27.14" />
|
||||
<PackageReference Include="LCU.Library.Internal.LcuClassPatterns.CrudTests" Version="1.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.5" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||
<PackageReference Include="Moq" Version="4.18.3" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
|
||||
<PackageReference Include="Moq" Version="4.18.4" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
+14
-109
@@ -1,130 +1,35 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.Interfaces;
|
||||
using LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
using LCU.API.Internal.MemberPreferencesApiLib.Repositories;
|
||||
using LCU.Library.Internal.LCUServiceFactory.Services;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Interfaces;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Configuration;
|
||||
using LCU.API.Internal.MemberPreferencesApiLib.Repositories;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.UnitTests.Services
|
||||
{
|
||||
public class DNADataAuditProcessServiceTest
|
||||
{
|
||||
private Mock<ICoreApiWrapperService> _coreApiWrapperServiceMock;
|
||||
private Mock<IQueueDnaAccountAuditService> _queueAccountMock;
|
||||
private Mock<IQueueDnaAgreementAuditService> _queueAgreementMock;
|
||||
private Mock<IQueueDnaOrganizationAuditService> _queueOrganizationMock;
|
||||
private Mock<IScanBiCoreApiWrapperService> _scanBiCoreApiWrapperServiceMock;
|
||||
private Mock<IDnaAuditProcessRepository> _dnaAuditProcessRepositoryMock;
|
||||
private DNADataAuditProcessService _service;
|
||||
private Mock<IDateTime> _dateTimeMock;
|
||||
private DnaAuditProcessConfiguration _config;
|
||||
private Mock<ILcuServiceFactory<IDNAAuditCheckService>> _serviceFactoryMock;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_dateTimeMock = new Mock<IDateTime>();
|
||||
_config = new DnaAuditProcessConfiguration();
|
||||
_coreApiWrapperServiceMock = new Mock<ICoreApiWrapperService>();
|
||||
_queueAccountMock = new Mock<IQueueDnaAccountAuditService>();
|
||||
_queueAgreementMock = new Mock<IQueueDnaAgreementAuditService>();
|
||||
_queueOrganizationMock = new Mock<IQueueDnaOrganizationAuditService>();
|
||||
_scanBiCoreApiWrapperServiceMock = new Mock<IScanBiCoreApiWrapperService>();
|
||||
_dnaAuditProcessRepositoryMock = new Mock<IDnaAuditProcessRepository>();
|
||||
_service = new DNADataAuditProcessService(_queueAccountMock.Object, _queueAgreementMock.Object, _queueOrganizationMock.Object,
|
||||
_coreApiWrapperServiceMock.Object, _dateTimeMock.Object, _dnaAuditProcessRepositoryMock.Object, _config);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task RunDnaAuditProcessesChange_HandleProcessUpdate_Ok()
|
||||
{
|
||||
|
||||
var processlistAccount = new List<DnaAuditProcess>
|
||||
{
|
||||
new DnaAuditProcess()
|
||||
{
|
||||
ConsecutiveFailures = 0,
|
||||
DnaProcessType = DnaAuditProcessType.DNAAccounts,
|
||||
LastUpdated = DateTime.Now,
|
||||
ProcessId = 0,
|
||||
}
|
||||
};
|
||||
|
||||
var processlistAgreement = new List<DnaAuditProcess>
|
||||
{
|
||||
new DnaAuditProcess()
|
||||
{
|
||||
ConsecutiveFailures = 0,
|
||||
DnaProcessType = DnaAuditProcessType.DNAAgreement,
|
||||
LastUpdated = DateTime.Now,
|
||||
ProcessId = 0,
|
||||
}
|
||||
};
|
||||
|
||||
var processlistOrg = new List<DnaAuditProcess>
|
||||
{
|
||||
new DnaAuditProcess()
|
||||
{
|
||||
ConsecutiveFailures = 0,
|
||||
DnaProcessType = DnaAuditProcessType.DNAOrganization,
|
||||
LastUpdated = DateTime.Now,
|
||||
ProcessId = 0,
|
||||
}
|
||||
};
|
||||
|
||||
await _service.RunDataAuditProcesses();
|
||||
await _service.AuditDNAAccountsForTimePeriod(DateTime.Now, processlistAccount.First());
|
||||
var resultAccount = _service.HandleDnaAuditProcessSuccess(processlistAccount.First());
|
||||
|
||||
await _service.AuditDNAAgreementForTimePeriod(DateTime.Now, processlistAgreement.First());
|
||||
var resultAgreement = _service.HandleDnaAuditProcessSuccess(processlistAgreement.First());
|
||||
|
||||
await _service.AuditDNAOrganizationForTimePeriod(DateTime.Now, processlistOrg.First());
|
||||
var resultOrg = _service.HandleDnaAuditProcessSuccess(processlistOrg.First());
|
||||
|
||||
//assert
|
||||
Assert.NotNull(resultAccount);
|
||||
Assert.AreEqual(resultAccount.DnaProcessType, DnaAuditProcessType.DNAAccounts);
|
||||
Assert.AreEqual(resultAccount.ConsecutiveFailures, 0);
|
||||
|
||||
Assert.NotNull(resultAgreement);
|
||||
Assert.AreEqual(resultAgreement.DnaProcessType, DnaAuditProcessType.DNAAgreement);
|
||||
Assert.AreEqual(resultAgreement.ConsecutiveFailures, 0);
|
||||
|
||||
Assert.NotNull(resultOrg);
|
||||
Assert.AreEqual(resultOrg.DnaProcessType, DnaAuditProcessType.DNAOrganization);
|
||||
Assert.AreEqual(resultOrg.ConsecutiveFailures, 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task RunDnaAuditProcessesChange_HandleProcessUpdateException_Ok()
|
||||
{
|
||||
|
||||
var processlistAccount = new List<DnaAuditProcess>
|
||||
{
|
||||
new DnaAuditProcess()
|
||||
{
|
||||
ConsecutiveFailures = 0,
|
||||
DnaProcessType = DnaAuditProcessType.DNAAccounts,
|
||||
LastUpdated = DateTime.Now,
|
||||
ProcessId = 0,
|
||||
}
|
||||
};
|
||||
|
||||
var ex = new Exception();
|
||||
await _service.RunDataAuditProcesses();
|
||||
await _service.AuditDNAAccountsForTimePeriod(DateTime.Now, processlistAccount.First());
|
||||
var resultAccount = _service.HandleDnaAuditProcessException(processlistAccount.First(), ex);
|
||||
|
||||
//assert
|
||||
Assert.NotNull(resultAccount);
|
||||
Assert.AreEqual(resultAccount.DnaProcessType, DnaAuditProcessType.DNAAccounts);
|
||||
Assert.AreEqual(resultAccount.ConsecutiveFailures, 1);
|
||||
_serviceFactoryMock = new Mock<ILcuServiceFactory<IDNAAuditCheckService>>();
|
||||
_service = new DNADataAuditProcessService(_coreApiWrapperServiceMock.Object,
|
||||
_scanBiCoreApiWrapperServiceMock.Object,
|
||||
_dateTimeMock.Object,
|
||||
_dnaAuditProcessRepositoryMock.Object,
|
||||
_serviceFactoryMock.Object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-223
@@ -1,223 +0,0 @@
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Agreements;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Models.Requests;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.UnitTests.Services
|
||||
{
|
||||
public class DNADataAuditServiceTest
|
||||
{
|
||||
private Mock<ICoreApiWrapperService> _coreApiWrapperServiceMock;
|
||||
private Mock<IOptinService> _optinServiceMock;
|
||||
private DNADataAuditService _service;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_coreApiWrapperServiceMock = new Mock<ICoreApiWrapperService>();
|
||||
_optinServiceMock = new Mock<IOptinService>();
|
||||
_service = new DNADataAuditService(_coreApiWrapperServiceMock.Object, _optinServiceMock.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task HandleChangedFields_AccountChange_OK_UPDATE()
|
||||
{
|
||||
|
||||
var account = new AgreementAccount
|
||||
{
|
||||
AccountNumber = 123456,
|
||||
OvrDeliveryMethCD = "PRNT",
|
||||
AccountOwner = new AgreementAccountOwner
|
||||
{
|
||||
AccountNumber = 123456,
|
||||
AgreementNumber = 222,
|
||||
PersonNumber = 123,
|
||||
UserId = "1234"
|
||||
}
|
||||
};
|
||||
|
||||
var memberOptinSettings = new MemberOptInSettings
|
||||
{
|
||||
EStatements = null,
|
||||
UniversalOptIn = "Electronic"
|
||||
};
|
||||
|
||||
//setup
|
||||
_coreApiWrapperServiceMock.Setup(x => x.GetAgreementAccountByAccountId(123456)).ReturnsAsync(account).Verifiable();
|
||||
|
||||
_optinServiceMock.Setup(x => x.GetMemberOptInSettings("1234")).ReturnsAsync(memberOptinSettings).Verifiable();
|
||||
|
||||
var request = new DnaFieldChangeRequest()
|
||||
{
|
||||
ConsecutiveFailures = 0,
|
||||
DnaFieldIdInformation = 123456L,
|
||||
DnaProcessType = DnaAuditProcessType.DNAAgreement,
|
||||
LastUpdated = DateTime.Now,
|
||||
ProcessId = 1
|
||||
};
|
||||
|
||||
await _service.HandleAccountAuditCheck(request);
|
||||
|
||||
//assert
|
||||
_coreApiWrapperServiceMock.Verify(x => x.UpdateAgreementAccountsDeliveryMethod(It.Is<List<long>>(list => list.Contains(123456)), It.Is<string>(x => x.Equals("WWW")), It.Is<string>(x => x.Equals("1234"))), Times.Once);
|
||||
_coreApiWrapperServiceMock.Verify();
|
||||
_optinServiceMock.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task HandleChangedFields_AccountChange_OK_DONTUPDATE()
|
||||
{
|
||||
var account = new AgreementAccount
|
||||
{
|
||||
AccountNumber = 123456,
|
||||
OvrDeliveryMethCD = "PRNT",
|
||||
AccountOwner = new AgreementAccountOwner
|
||||
{
|
||||
AccountNumber = 123456,
|
||||
AgreementNumber = 222,
|
||||
PersonNumber = 123,
|
||||
UserId = "1234"
|
||||
}
|
||||
};
|
||||
|
||||
var memberOptinSettings = new MemberOptInSettings
|
||||
{
|
||||
EStatements = null,
|
||||
UniversalOptIn = "Paper"
|
||||
};
|
||||
|
||||
//setup
|
||||
_coreApiWrapperServiceMock.Setup(x => x.GetAgreementAccountByAccountId(123456)).ReturnsAsync(account).Verifiable();
|
||||
|
||||
_optinServiceMock.Setup(x => x.GetMemberOptInSettings("1234"))
|
||||
.ReturnsAsync(memberOptinSettings).Verifiable();
|
||||
|
||||
var request = new DnaFieldChangeRequest()
|
||||
{
|
||||
ConsecutiveFailures = 0,
|
||||
DnaFieldIdInformation = 123456L,
|
||||
DnaProcessType = DnaAuditProcessType.DNAAccounts,
|
||||
LastUpdated = DateTime.Now,
|
||||
ProcessId = 1
|
||||
};
|
||||
|
||||
await _service.HandleAccountAuditCheck(request);
|
||||
|
||||
//assert
|
||||
_coreApiWrapperServiceMock.Verify(x => x.UpdateAgreementAccountsDeliveryMethod(It.IsAny<List<long>>(), It.IsAny<string>(), It.IsAny<string>()), Times.Never);
|
||||
_coreApiWrapperServiceMock.Verify();
|
||||
_optinServiceMock.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task HandleChangedFields_AgreementChange_OK_UPDATE()
|
||||
{
|
||||
var agreement = new Agreement
|
||||
{
|
||||
AgreementNumber = 1127,
|
||||
PersonNumber = 123,
|
||||
UserId = "1234"
|
||||
};
|
||||
|
||||
var accounts = new List<AgreementAccount>
|
||||
{
|
||||
new AgreementAccount{
|
||||
AccountNumber = 123456,
|
||||
OvrDeliveryMethCD = "PRNT",
|
||||
TaxReportForPersonNumber = 123,
|
||||
AccountOwner = new AgreementAccountOwner{
|
||||
AccountNumber = 123456,
|
||||
AgreementNumber = 1127,
|
||||
PersonNumber = 123,
|
||||
UserId = "1234"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var memberOptinSettings = new MemberOptInSettings
|
||||
{
|
||||
EStatements = null,
|
||||
UniversalOptIn = "Electronic"
|
||||
};
|
||||
|
||||
//setup
|
||||
_coreApiWrapperServiceMock.Setup(x => x.GetAgreementByAgreementId(1127)).ReturnsAsync(agreement).Verifiable();
|
||||
_coreApiWrapperServiceMock.Setup(x => x.GetAgreementAccountsByUserId("1234")).ReturnsAsync(accounts).Verifiable();
|
||||
|
||||
_optinServiceMock.Setup(x => x.GetMemberOptInSettings("1234")).ReturnsAsync(memberOptinSettings).Verifiable();
|
||||
|
||||
var request = new DnaFieldChangeRequest()
|
||||
{
|
||||
ConsecutiveFailures = 0,
|
||||
DnaFieldIdInformation = 1127L,
|
||||
DnaProcessType = DnaAuditProcessType.DNAAgreement,
|
||||
LastUpdated = DateTime.Now,
|
||||
ProcessId = 1
|
||||
};
|
||||
|
||||
await _service.HandleAgreementAuditCheck(request);
|
||||
|
||||
//assert
|
||||
_coreApiWrapperServiceMock.Verify(x => x.UpdateAgreementAccountsDeliveryMethod(It.Is<List<long>>(list => list.Contains(123456)), It.Is<string>(x => x.Equals("WWW")), It.Is<string>(x => x.Equals("1234"))), Times.Once);
|
||||
_coreApiWrapperServiceMock.Verify();
|
||||
_optinServiceMock.Verify();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task HandleChangedFields_OrganizationChange_OK_UPDATE()
|
||||
{
|
||||
var accounts = new List<AgreementAccount>
|
||||
{
|
||||
new AgreementAccount{
|
||||
AccountNumber = 123456,
|
||||
TaxReportForOrgNumber = 11267,
|
||||
OvrDeliveryMethCD = "PRNT",
|
||||
AccountOwner = new AgreementAccountOwner
|
||||
{
|
||||
AccountNumber = 123456,
|
||||
AgreementNumber = 222,
|
||||
PersonNumber = 123,
|
||||
UserId = "1234"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var memberOptinSettings = new MemberOptInSettings
|
||||
{
|
||||
EStatements = null,
|
||||
UniversalOptIn = "Electronic"
|
||||
};
|
||||
|
||||
//setup
|
||||
|
||||
_coreApiWrapperServiceMock.Setup(x => x.GetAgreementAccountsByOrganizationId(1126)).ReturnsAsync(accounts).Verifiable();
|
||||
|
||||
_optinServiceMock.Setup(x => x.GetMemberOptInSettings("1234")).ReturnsAsync(memberOptinSettings).Verifiable();
|
||||
|
||||
var request = new DnaFieldChangeRequest()
|
||||
{
|
||||
ConsecutiveFailures = 0,
|
||||
DnaFieldIdInformation = 1126L,
|
||||
DnaProcessType = DnaAuditProcessType.DNAAgreement,
|
||||
LastUpdated = DateTime.Now,
|
||||
ProcessId = 1
|
||||
};
|
||||
|
||||
//act
|
||||
await _service.HandleOrganizationAuditCheck(request);
|
||||
|
||||
//assert
|
||||
_coreApiWrapperServiceMock.Verify(x => x.UpdateAgreementAccountsDeliveryMethod(It.Is<List<long>>(list => list.Contains(123456)), It.Is<string>(x => x.Equals("WWW")), It.Is<string>(x => x.Equals("1234"))), Times.Once);
|
||||
_coreApiWrapperServiceMock.Verify();
|
||||
_optinServiceMock.Verify();
|
||||
}
|
||||
}
|
||||
}
|
||||
+65
-30
@@ -1,48 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Configuration;
|
||||
using LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Models;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Models.Requests;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.XdiServices;
|
||||
using LCU.API.Internal.MemberPreferencesApiLib.Repositories;
|
||||
using LCU.Library.Internal.LcuClassPatterns.CrudTests.Tests;
|
||||
using LCU.Library.Internal.LcuClassPatterns.CrudTests.Utilities;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
using LCU.Library.Internal.LcuMassTransitModels;
|
||||
using LCU.API.Internal.MemberPreferencesApiLib.Repositories;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.XdiServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
using Moq;
|
||||
using Newtonsoft.Json;
|
||||
using NUnit.Framework;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.UnitTests.Services
|
||||
{
|
||||
public class XdiBatchItemServiceTest
|
||||
public class XdiBatchItemServiceTest : CrudServiceTest<XdiBatchProcessInfo>
|
||||
{
|
||||
private IXdiBatchService _xdiBatchItemService;
|
||||
private Mock<IXdiBatchItemsRepository> _mockBatchItemsRepository;
|
||||
private Mock<IXdiBatchProcessInfoRepository> _mockXdiBatchProcessInfoRepository;
|
||||
private Mock<IUnitOfWork> _mockUnitOfWork;
|
||||
private XdiSftpApiConfiguration _ftpConfiguration;
|
||||
private Mock<IUnifiedOptInRepository> _mockUnifiedOptinRepository;
|
||||
private Mock<IMemberPreferenceRepository> _mockMemberPreferenceRepository;
|
||||
private Mock<IFtpApiService> _mockFtpApiService;
|
||||
private ConnectionConfiguration _connectionConfiguration;
|
||||
private ReceiveEndpointConfiguration _completionReceiveEndpoint;
|
||||
private ReceiveEndpointConfigurations _endpointConfiguration;
|
||||
private Mock<IFileOperationsApiService> _mockFileOperationsApiService;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_mockBatchItemsRepository = new Mock<IXdiBatchItemsRepository>();
|
||||
_mockXdiBatchProcessInfoRepository = new Mock<IXdiBatchProcessInfoRepository>();
|
||||
_mockUnitOfWork = new Mock<IUnitOfWork>();
|
||||
_ftpConfiguration = new XdiSftpApiConfiguration();
|
||||
_mockUnifiedOptinRepository = new Mock<IUnifiedOptInRepository>();
|
||||
_mockMemberPreferenceRepository = new Mock<IMemberPreferenceRepository>();
|
||||
_mockFtpApiService = new Mock<IFtpApiService>();
|
||||
_endpointConfiguration = new ReceiveEndpointConfigurations();
|
||||
_completionReceiveEndpoint = _endpointConfiguration.XdiBatchConfirmEndpoint;
|
||||
_mockFileOperationsApiService = new Mock<IFileOperationsApiService>();
|
||||
|
||||
_xdiBatchItemService = new XdiBatchService(_mockBatchItemsRepository.Object, _mockUnitOfWork.Object,
|
||||
_ftpConfiguration, _mockUnifiedOptinRepository.Object, _mockMemberPreferenceRepository.Object,
|
||||
_connectionConfiguration, _endpointConfiguration, _mockFtpApiService.Object);
|
||||
_mockUnifiedOptinRepository.Object, _mockMemberPreferenceRepository.Object,
|
||||
_mockFileOperationsApiService.Object, _mockXdiBatchProcessInfoRepository.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -226,7 +223,7 @@ namespace LCU.API.Internal.MemberPreferencesApi.UnitTests.Services
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateFtpQueryPayload_Ok()
|
||||
public async Task CreateXdiBatchExport_MultipleResults_Ok()
|
||||
{
|
||||
var testFile = new XdiBatchFile
|
||||
{
|
||||
@@ -308,7 +305,26 @@ namespace LCU.API.Internal.MemberPreferencesApi.UnitTests.Services
|
||||
UniversalOptIn = DeliveryPreference.Hold
|
||||
});
|
||||
|
||||
var results = await _xdiBatchItemService.CreateFtpPayload(testFile);
|
||||
var xdiBatchProcessInfo = new List<XdiBatchProcessInfo>
|
||||
{
|
||||
new()
|
||||
{
|
||||
XdiBatchProcessInfoId = (int)typeof(int).GetRandomValue(),
|
||||
StartTimeStamp = DateTime.Now,
|
||||
XdiBatchProcessStatus = XdiBatchProcessStatus.InProgress,
|
||||
ApiResponse = "Started"
|
||||
}
|
||||
};
|
||||
|
||||
var request = new XdiBatchRequest()
|
||||
{
|
||||
XdiAppendFileRootBasePath = "test/test"
|
||||
};
|
||||
|
||||
_mockXdiBatchProcessInfoRepository.Setup(x => x.FindBatchProcessInfoByStatus(XdiBatchProcessStatus.InProgress)).ReturnsAsync(xdiBatchProcessInfo)
|
||||
.Verifiable();
|
||||
|
||||
var results = await _xdiBatchItemService.BuildXdiFiles(testFile, request.XdiAppendFileRootBasePath, xdiBatchProcessInfo.FirstOrDefault());
|
||||
|
||||
Assert.AreEqual(4, results.Count);
|
||||
Assert.True(results.Exists(x => x.UserId == "100" && x.Value == "[email protected]"));
|
||||
@@ -318,7 +334,7 @@ namespace LCU.API.Internal.MemberPreferencesApi.UnitTests.Services
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task CreateFtpQueryPayload_No_Result_Ok()
|
||||
public async Task CreateXdiBatchExport_Result_Ok()
|
||||
{
|
||||
var testFile = new XdiBatchFile
|
||||
{
|
||||
@@ -331,6 +347,17 @@ namespace LCU.API.Internal.MemberPreferencesApi.UnitTests.Services
|
||||
}
|
||||
};
|
||||
|
||||
var xdiBatchProcessInfo = new List<XdiBatchProcessInfo>
|
||||
{
|
||||
new()
|
||||
{
|
||||
XdiBatchProcessInfoId = (int)typeof(int).GetRandomValue(),
|
||||
StartTimeStamp = DateTime.Now,
|
||||
XdiBatchProcessStatus = XdiBatchProcessStatus.InProgress,
|
||||
ApiResponse = "Started"
|
||||
}
|
||||
};
|
||||
|
||||
_mockUnifiedOptinRepository
|
||||
.Setup(x => x.GetMemberOptInSettingsNoTracking("100")).ReturnsAsync(new MemberOptInSettings
|
||||
{
|
||||
@@ -342,7 +369,15 @@ namespace LCU.API.Internal.MemberPreferencesApi.UnitTests.Services
|
||||
.Setup(x => x.GetMemberOptInSettingsNoTracking(It.Is<string>(userId => int.Parse(userId) > 100)))
|
||||
.Returns(Task.FromResult<MemberOptInSettings>(null));
|
||||
|
||||
var results = await _xdiBatchItemService.CreateFtpPayload(testFile);
|
||||
_mockXdiBatchProcessInfoRepository.Setup(x => x.FindBatchProcessInfoByStatus(XdiBatchProcessStatus.InProgress)).ReturnsAsync(xdiBatchProcessInfo)
|
||||
.Verifiable();
|
||||
|
||||
var request = new XdiBatchRequest()
|
||||
{
|
||||
XdiAppendFileRootBasePath = "test/test"
|
||||
};
|
||||
|
||||
var results = await _xdiBatchItemService.BuildXdiFiles(testFile, request.XdiAppendFileRootBasePath, xdiBatchProcessInfo.FirstOrDefault());
|
||||
|
||||
Assert.AreEqual(1, results.Count);
|
||||
Assert.True(results.Exists(x => x.UserId == "100" && x.Value == DeliveryPreference.Paper));
|
||||
@@ -351,20 +386,20 @@ namespace LCU.API.Internal.MemberPreferencesApi.UnitTests.Services
|
||||
[Test]
|
||||
public async Task MarkPendingSuccessful_OK()
|
||||
{
|
||||
var payload = new List<FtpQueuePayloadItem>()
|
||||
var batchFileExportList = new List<XdiBatchFileExport>()
|
||||
{
|
||||
new FtpQueuePayloadItem()
|
||||
new XdiBatchFileExport()
|
||||
{
|
||||
UserId = "100",
|
||||
Value = DeliveryPreference.Paper
|
||||
},
|
||||
new FtpQueuePayloadItem()
|
||||
new XdiBatchFileExport()
|
||||
{
|
||||
UserId = "101",
|
||||
Value = "[email protected]"
|
||||
}
|
||||
};
|
||||
var payloadString = JsonConvert.SerializeObject(payload);
|
||||
var payloadString = JsonConvert.SerializeObject(batchFileExportList);
|
||||
|
||||
var response = new LCU.Library.Internal.ApiResponse.Models.Response()
|
||||
{
|
||||
@@ -381,7 +416,7 @@ namespace LCU.API.Internal.MemberPreferencesApi.UnitTests.Services
|
||||
_mockBatchItemsRepository.Setup(x => x.MarkPendingSuccessful(It.IsAny<List<string>>())).ReturnsAsync(true)
|
||||
.Verifiable();
|
||||
|
||||
var result = await _xdiBatchItemService.MarkPendingSuccessful(response);
|
||||
var result = await _xdiBatchItemService.MarkPendingSuccessful(batchFileExportList);
|
||||
|
||||
Assert.True(result);
|
||||
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ namespace LCU.API.Internal.MemberPreferencesApi.UnitTests.XdiBatch
|
||||
var results = newFile.ConvertToDataFile();
|
||||
|
||||
Assert.NotNull(fileName);
|
||||
Assert.AreEqual("Enrollment_AddElectronic_LMCU.txt", fileName);
|
||||
Assert.AreEqual("Enrollment_AddElectronic_LMCU", fileName);
|
||||
|
||||
Assert.NotNull(results);
|
||||
Assert.NotNull(stringResults);
|
||||
|
||||
-1
@@ -11,6 +11,5 @@ public class CoreApiWrapperConfiguration
|
||||
public string CoreApiGetAgreementAccountsByOrganizationId { get; set; }
|
||||
public string CoreApiGetAuditAccountsFromDateLastMaintained { get; set; }
|
||||
public string CoreApiGetAuditAgreementFromDateLastMaintained { get; set; }
|
||||
public string CoreApiGetAuditOrganizationFromDateLastMaintained { get; set; }
|
||||
public string CoreApiUpdateAccountsMaintenanceRequest { get; set; }
|
||||
}
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Configuration;
|
||||
|
||||
public class DnaAuditProcessConfiguration
|
||||
{
|
||||
public int LookBackMinutes { get; set; }
|
||||
public int NumberOfAllowedConsecutiveFailures { get; set; }
|
||||
}
|
||||
+1
-5
@@ -2,10 +2,6 @@ namespace LCU.API.Internal.MemberPreferencesApi.Configuration;
|
||||
|
||||
public class FeatureFlags
|
||||
{
|
||||
public bool RunHostedServices { get; set; }
|
||||
public bool RunXdiBatchProcessConsumer { get; set; }
|
||||
public bool RunXdiSshResponseConsumer { get; set; }
|
||||
public bool RunAccountDnaFieldChangeConsumer { get; set; }
|
||||
public bool RunAgreementDnaFieldChangeConsumer { get; set; }
|
||||
public bool RunOrganizationDnaFieldChangeConsumer { get; set; }
|
||||
public bool RunDnaAuditProcessConsumer { get; set; }
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Configuration;
|
||||
|
||||
public class FileOperationsApiConfiguration
|
||||
{
|
||||
public string Url { get; set; }
|
||||
public string AppendFile { get; set; }
|
||||
[NotMapped]
|
||||
public string AppendFileUrl => Url + AppendFile;
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Configuration;
|
||||
|
||||
public class FtpApiConfiguration
|
||||
{
|
||||
public string Url { get; set; }
|
||||
public string QueueSshFtpRequestEndpoint { get; set; }
|
||||
[NotMapped]
|
||||
public string QueueSshFtpRequestEndpointUrl => Url + QueueSshFtpRequestEndpoint;
|
||||
}
|
||||
+1
-3
@@ -6,8 +6,6 @@ public class ReceiveEndpointConfigurations
|
||||
{
|
||||
public ReceiveEndpointConfiguration XdiBatchProcessEndpoint { get; set; }
|
||||
public ReceiveEndpointConfiguration XdiBatchConfirmEndpoint { get; set; }
|
||||
public ReceiveEndpointConfiguration DnaAccountAuditEndpoint { get; set; }
|
||||
public ReceiveEndpointConfiguration DnaOrganizationAuditEndpoint { get; set; }
|
||||
public ReceiveEndpointConfiguration DnaAgreementAuditEndpoint { get; set; }
|
||||
public ReceiveEndpointConfiguration DnaAuditProcessEndpoint { get; set; }
|
||||
}
|
||||
|
||||
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Configuration
|
||||
{
|
||||
public class ScanBiCoreApiWrapperConfiguration
|
||||
{
|
||||
public string ScanBiCoreApiWrapperUrl { get; set; }
|
||||
public string GetAuditOrganizationFromDateLastMaintainedEndpoint { get; set; }
|
||||
[NotMapped]
|
||||
public string GetAuditOrganizationFromDateLastMaintainedUrl => ScanBiCoreApiWrapperUrl + GetAuditOrganizationFromDateLastMaintainedEndpoint;
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Configuration;
|
||||
|
||||
public class XdiSftpApiConfiguration
|
||||
{
|
||||
public string HostName { get; set; }
|
||||
public int PortNumber { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Fingerprint { get; set; }
|
||||
public string SftpRootBasePath { get; set; }
|
||||
}
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Consumers;
|
||||
|
||||
public class AccountDnaFieldChangeConsumer : IConsumer<DnaFieldChangeRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public AccountDnaFieldChangeConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<DnaFieldChangeRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Debug("Starting AccountDnaFieldChangeConsumer.");
|
||||
Log.Information($"New Account Received for: {context.Message.DnaProcessType} Process - {context.Message.DnaFieldIdInformation}");
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(async () => await scope.ServiceProvider.GetRequiredService<IDNADataAuditService>().HandleAccountAuditCheck(context.Message));
|
||||
Log.Debug("Ending DnaAccountAuditServiceConsumer.");
|
||||
}
|
||||
catch (ServiceException serviceException)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(serviceException, $"AccountDnaFieldChangeConsumer Failure. " +
|
||||
$"The request is placed on AccountDnaFieldChangeConsumer_error.");
|
||||
throw serviceException;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Unexpected AccountDnaFieldChangeConsumer Failure. " +
|
||||
$"The request is placed on AccountDnaFieldChangeConsumer_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Consumers;
|
||||
|
||||
public class AgreementDnaFieldChangeConsumer : IConsumer<DnaFieldChangeRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public AgreementDnaFieldChangeConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<DnaFieldChangeRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Debug("Starting AgreementDnaFieldChangeConsumer.");
|
||||
Log.Information($"New Agreement Received for : {context.Message.DnaProcessType} Process - {context.Message.DnaFieldIdInformation}");
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(async () => await scope.ServiceProvider.GetRequiredService<IDNADataAuditService>().HandleAgreementAuditCheck(context.Message));
|
||||
Log.Debug("Ending AgreementDnaFieldChangeConsumer.");
|
||||
}
|
||||
catch (ServiceException serviceException)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(serviceException, $"AgreementDnaFieldChangeConsumer Failure. " +
|
||||
$"The request is placed on AgreementDnaFieldChangeConsumer_error.");
|
||||
throw;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Unexpected AgreementDnaFieldChangeConsumer Failure. " +
|
||||
$"The TransactionRequest is placed on AgreementDnaFieldChangeConsumer_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Consumers;
|
||||
|
||||
public class DnaAuditProcessConsumer : IConsumer<DnaAuditProcessRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public DnaAuditProcessConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<DnaAuditProcessRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Debug("Starting DnaAuditProcessConsumer.");
|
||||
using var scope = _scopeFactory.CreateAsyncScope();
|
||||
await scope.ServiceProvider.GetRequiredService<IDNADataAuditProcessService>().HandleDnaAuditProcessRequest(context.Message);
|
||||
Log.Debug("Ending DnaAuditProcessConsumer.");
|
||||
}
|
||||
catch (ServiceException serviceException)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(serviceException, $"DnaAuditProcess Failure. " +
|
||||
$"The request is placed on DnaAuditProcess_error.");
|
||||
throw;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Unexpected DnaAuditProcess Failure. " +
|
||||
$"The TransactionRequest is placed on DnaAuditProcess_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Consumers;
|
||||
|
||||
public class OrganizationDnaFieldChangeConsumer : IConsumer<DnaFieldChangeRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public OrganizationDnaFieldChangeConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<DnaFieldChangeRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Debug("Starting OrganizationDnaFieldChangeConsumer.");
|
||||
Log.Information($"New Organization Received for: {context.Message.DnaProcessType} Process - {context.Message.DnaFieldIdInformation}");
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(async () => await scope.ServiceProvider.GetRequiredService<IDNADataAuditService>().HandleOrganizationAuditCheck(context.Message));
|
||||
Log.Debug("Ending OrganizationDnaFieldChangeConsumer.");
|
||||
}
|
||||
catch (ServiceException serviceException)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(serviceException, $"OrganizationDnaFieldChangeConsumer Failure. " +
|
||||
$"The request is placed on OrganizationDnaFieldChangeConsumer_error.");
|
||||
throw;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Unexpected OrganizationDnaFieldChangeConsumer Consumer Failure. " +
|
||||
$"The request is placed on OrganizationDnaFieldChangeConsumer_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -3,26 +3,26 @@ using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Consumers;
|
||||
|
||||
public class XdiBatchProcessConsumer : IConsumer<XdiBatchRequest>
|
||||
public class XdiBatchProcessConsumer : IConsumer<XdiBatchProcessRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
public XdiBatchProcessConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
public async Task Consume(ConsumeContext<XdiBatchRequest> context)
|
||||
public async Task Consume(ConsumeContext<XdiBatchProcessRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(async () => await scope.ServiceProvider.GetRequiredService<IXdiBatchService>().CreateXdiBatchFiles(context.Message));
|
||||
await Task.Run(async () => await scope.ServiceProvider.GetRequiredService<IXdiBatchProcessService>().HandleXdiBatchProcess(context.Message));
|
||||
}
|
||||
catch (ServiceException ex)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error($"XdiBatchProcessConsumer Failure. " +
|
||||
$"The response is placed on LCU.MemberPreferencesApi.XdiAuditProcess_error. " +
|
||||
$"The response is placed on LCU.MemberPreferencesApi.XdiBatchProcess_error. " +
|
||||
$"Error Message: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class XdiBatchProcessConsumer : IConsumer<XdiBatchRequest>
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Unexpected XdiBatchProcessConsumer Failure. " +
|
||||
$"The response is placed on LCU.MemberPreferencesApi.XdiAuditProcess_error.");
|
||||
$"The response is placed on LCU.MemberPreferencesApi.XdiBatchProcess_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
using ApiResponse = LCU.Library.Internal.ApiResponse.Models;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.XdiServices;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Consumers;
|
||||
|
||||
public class XdiSshResponseConsumer : IConsumer<ApiResponse.Response>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
public XdiSshResponseConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
public async Task Consume(ConsumeContext<ApiResponse.Response> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(async () => await scope.ServiceProvider.GetRequiredService<IXdiBatchService>().MarkPendingSuccessful(context.Message));
|
||||
}
|
||||
catch (ServiceException ex)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error($"XdiSshResponseConsumer Failure. " +
|
||||
$"The ApiResponse.Response is placed on LCU.MemberPreferencesApi.XdiBatchConfirm_error. " +
|
||||
$"Error Message: {ex.Message}");
|
||||
throw;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Unexpected XdiSshResponseConsumer Failure. " +
|
||||
$"The ApiResponse.Response is placed on LCU.MemberPreferencesApi.XdiBatchConfirm_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
-79
@@ -1,79 +0,0 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class AuditController : ControllerBase
|
||||
{
|
||||
private readonly IQueueDnaAccountAuditService _dnaAccountAuditService;
|
||||
private readonly IQueueDnaOrganizationAuditService _dnaOrganizationAuditService;
|
||||
private readonly IQueueDnaAgreementAuditService _dnaAgreementAuditService;
|
||||
|
||||
public AuditController(IQueueDnaAccountAuditService dnaAccountAuditService,
|
||||
IQueueDnaOrganizationAuditService dnaOrganizationAuditService,
|
||||
IQueueDnaAgreementAuditService dnaAgreementAuditService)
|
||||
{
|
||||
_dnaAccountAuditService = dnaAccountAuditService;
|
||||
_dnaOrganizationAuditService = dnaOrganizationAuditService;
|
||||
_dnaAgreementAuditService = dnaAgreementAuditService;
|
||||
}
|
||||
|
||||
[HttpPost("EnqueueDNAOrganizationAuditRecords")]
|
||||
[ProducesResponseType(200)]
|
||||
[ProducesResponseType(400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> EnqueueDNAOrganizationAuditRecords([FromBody] List<long> organizationIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Information($"Forced {organizationIds.Count} DNAOrganizationAuditRecords to be queued");
|
||||
await _dnaOrganizationAuditService.QueueDataAuditForOrganizations(organizationIds);
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name}");
|
||||
return StatusCode((int) System.Net.HttpStatusCode.InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("EnqueueDNAAgreementAuditRecords")]
|
||||
[ProducesResponseType(200)]
|
||||
[ProducesResponseType(400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> EnqueueDNAAgreementAuditRecords([FromBody] List<long> agreementIds)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Information($"Forced {agreementIds.Count} DNAAgreementAuditRecords to be queued");
|
||||
await _dnaAgreementAuditService.QueueDataAuditForAgreements(agreementIds);
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name}");
|
||||
return StatusCode((int) System.Net.HttpStatusCode.InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("EnqueueDNAAccountAuditRecords")]
|
||||
[ProducesResponseType(200)]
|
||||
[ProducesResponseType(400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> EnqueueDNAAccountAuditRecords([FromBody] List<long> accountNumbers)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Information($"Forced {accountNumbers.Count} DNAAccountAuditRecords to be queued");
|
||||
await _dnaAccountAuditService.QueueDataAuditForAccounts(accountNumbers);
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure in {GetType().Name}");
|
||||
return StatusCode((int) System.Net.HttpStatusCode.InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.FeatureManagement.Mvc;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Controllers;
|
||||
|
||||
[FeatureGate(FeatureGates.EnableControllers)]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class QueueDnaAuditProcessController : ControllerBase
|
||||
{
|
||||
private readonly IQueueDnaAuditProcessService _queueDnaAuditProcessService;
|
||||
|
||||
public QueueDnaAuditProcessController(IQueueDnaAuditProcessService queueDnaAuditProcessService)
|
||||
{
|
||||
_queueDnaAuditProcessService = queueDnaAuditProcessService;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ProducesResponseType(200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> QueueDnaAuditProcessRequest(DnaAuditProcessRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _queueDnaAuditProcessService.QueueDnaAuditProcessRequest(request);
|
||||
return Ok();
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class QueueXdiBatchProcessController : ControllerBase
|
||||
{
|
||||
private readonly IQueueXdiBatchProcessService _queueXdiBatchProcessService;
|
||||
|
||||
public QueueXdiBatchProcessController(IQueueXdiBatchProcessService queueXdiBatchProcessService)
|
||||
{
|
||||
_queueXdiBatchProcessService = queueXdiBatchProcessService;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ProducesResponseType(200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> QueueXdiBatchRequest(XdiBatchProcessRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _queueXdiBatchProcessService.QueueXdiBatchProcess(request);
|
||||
return Ok();
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.XdiServices;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class XdiController : ControllerBase
|
||||
{
|
||||
private readonly IXdiBatchService _xdiBatchService;
|
||||
|
||||
public XdiController(IXdiBatchService xdiBatchService)
|
||||
{
|
||||
_xdiBatchService = xdiBatchService;
|
||||
}
|
||||
|
||||
[HttpPost("SaveRange")]
|
||||
[ProducesResponseType(200)]
|
||||
[ProducesResponseType(typeof(IEnumerable<XdiBatchItem>), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> SaveRange([FromBody] List<XdiBatchItem> xdiBatchItems)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (xdiBatchItems is null || !xdiBatchItems.Any())
|
||||
{
|
||||
return BadRequest("XdiBatchItems cannot be null or empty.");
|
||||
}
|
||||
Log.Information($"Save {xdiBatchItems.Count} Xdi Batch Items attempted.");
|
||||
await _xdiBatchService.SaveRangeAsync(xdiBatchItems);
|
||||
return Ok();
|
||||
}
|
||||
catch (ServiceException exception)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, exception.Message);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-8
@@ -41,7 +41,8 @@ public class CoreApiWrapperDao : ICoreApiWrapperDao
|
||||
public async Task<IEnumerable<Agreement>> GetAgreementsByAccountId(long accountId)
|
||||
{
|
||||
var path = $"{_coreApiWrapperConfig.CoreApiBaseUrl}{_coreApiWrapperConfig.CoreApiGetAgreementsByAccountId.Replace("{accountId}", accountId.ToString())}";
|
||||
return await _getRequest.Async<IEnumerable<Agreement>>(path, 0);
|
||||
|
||||
return await _getRequest.AsyncWithNewton<IEnumerable<Agreement>>(new Uri(path), null, 0);
|
||||
}
|
||||
|
||||
public async Task<AgreementAccount> GetAgreementAccountByAccountId(long accountId)
|
||||
@@ -85,13 +86,6 @@ public class CoreApiWrapperDao : ICoreApiWrapperDao
|
||||
return await _getRequest.Async<IEnumerable<long>>(path, 0, 240);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<long>> GetAuditOrganizationFromDateLastMaintained(DateTime dateTime)
|
||||
{
|
||||
var dtString = dateTime.ToString("s").Replace(":", "%3A");
|
||||
var path = $"{_coreApiWrapperConfig.CoreApiBaseUrl}{_coreApiWrapperConfig.CoreApiGetAuditOrganizationFromDateLastMaintained}?dateLastMaintained={dtString}";
|
||||
return await _getRequest.Async<IEnumerable<long>>(path, 0, 240);
|
||||
}
|
||||
|
||||
public async Task UpdateAgreementAccountsDeliveryMethod(IEnumerable<long> accountIds, string deliveryMethod, string userId)
|
||||
{
|
||||
var path = $"{_coreApiWrapperConfig.CoreApiBaseUrl}{_coreApiWrapperConfig.CoreApiUpdateAccountsMaintenanceRequest}";
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
using LCU.Library.Internal.FileOperationsModels.Models;
|
||||
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.DataAccess;
|
||||
|
||||
public class FileOperationsApiDao : IFileOperationsApiDao
|
||||
{
|
||||
private readonly FileOperationsApiConfiguration _fileOperationsApiConfiguration;
|
||||
private readonly IPostRequest _postRequest;
|
||||
|
||||
public FileOperationsApiDao(FileOperationsApiConfiguration fileOperationsApiConfiguration, IPostRequest postRequest)
|
||||
{
|
||||
_fileOperationsApiConfiguration = fileOperationsApiConfiguration;
|
||||
_postRequest = postRequest;
|
||||
}
|
||||
|
||||
public async Task<RequestResponse> AppendFileAsync(AppendFileRequest request)
|
||||
{
|
||||
var url = new Uri($"{_fileOperationsApiConfiguration.AppendFileUrl}");
|
||||
var result = await _postRequest.AsyncWithNewton<AppendFileRequest, RequestResponse>(url, request, 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
using LCU.Api.Internal.FTPLib.Models;
|
||||
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.DataAccess;
|
||||
|
||||
public class FtpApiDao : IFtpApiDao
|
||||
{
|
||||
private readonly FtpApiConfiguration _ftpApiConfiguration;
|
||||
private readonly IPostRequest _postRequest;
|
||||
|
||||
public FtpApiDao(FtpApiConfiguration ftpApiConfiguration, IPostRequest postRequest)
|
||||
{
|
||||
_ftpApiConfiguration = ftpApiConfiguration;
|
||||
_postRequest = postRequest;
|
||||
}
|
||||
|
||||
public async Task SendFtpAsync(SshFtpRequest request)
|
||||
{
|
||||
await _postRequest.Async(new Uri(_ftpApiConfiguration.QueueSshFtpRequestEndpointUrl), request, 0);
|
||||
}
|
||||
}
|
||||
-1
@@ -12,6 +12,5 @@ public interface ICoreApiWrapperDao
|
||||
public Task<IEnumerable<AgreementAccount>> GetAgreementAccountsByOrganizationId(long organizationId);
|
||||
public Task<IEnumerable<long>> GetAuditAccountsFromDateLastMaintained(DateTime dateTime);
|
||||
public Task<IEnumerable<long>> GetAuditAgreementFromDateLastMaintained(DateTime dateTime);
|
||||
public Task<IEnumerable<long>> GetAuditOrganizationFromDateLastMaintained(DateTime dateTime);
|
||||
public Task UpdateAgreementAccountsDeliveryMethod(IEnumerable<long> accountIds, string deliveryMethod, string userId);
|
||||
}
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
using LCU.Library.Internal.FileOperationsModels.Models;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.DataAccess;
|
||||
|
||||
public interface IFileOperationsApiDao
|
||||
{
|
||||
public Task<RequestResponse> AppendFileAsync(AppendFileRequest request);
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
using LCU.Api.Internal.FTPLib.Models;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.DataAccess;
|
||||
|
||||
public interface IFtpApiDao
|
||||
{
|
||||
public Task SendFtpAsync(SshFtpRequest sftpRequest);
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.DataAccess
|
||||
{
|
||||
public interface IScanBiCoreApiWrapperDao
|
||||
{
|
||||
public Task<IEnumerable<long>> GetAuditOrganizationFromDateLastMaintained(DateTime dateTime);
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
using LCU.Library.Internal.LcuHttpClient.HttpRequest;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.DataAccess;
|
||||
|
||||
public class ScanBiCoreApiWrapperDao : IScanBiCoreApiWrapperDao
|
||||
{
|
||||
private readonly ScanBiCoreApiWrapperConfiguration _scanBiCoreApiWrapperConfig;
|
||||
private readonly IGetRequest _getRequest;
|
||||
|
||||
public ScanBiCoreApiWrapperDao(ScanBiCoreApiWrapperConfiguration scanBiCoreApiWrapperConfig, IGetRequest getRequest)
|
||||
{
|
||||
_scanBiCoreApiWrapperConfig = scanBiCoreApiWrapperConfig;
|
||||
_getRequest = getRequest;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<long>> GetAuditOrganizationFromDateLastMaintained(DateTime dateTime)
|
||||
{
|
||||
var dtString = dateTime.ToString("s").Replace(":", "%3A");
|
||||
var path = $"{_scanBiCoreApiWrapperConfig.GetAuditOrganizationFromDateLastMaintainedUrl}?dateLastMaintained={dtString}";
|
||||
return await _getRequest.Async<IEnumerable<long>>(path, 0, 360);
|
||||
}
|
||||
}
|
||||
+7
-4
@@ -6,17 +6,20 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LCU.Api.Internal.FTPLib" Version="2.11.2" />
|
||||
<PackageReference Include="LCU.Library.Internal.ApiResponse" Version="3.4.1" />
|
||||
<PackageReference Include="LCU.Library.Internal.ApiSecurity" Version="1.0.2" />
|
||||
<PackageReference Include="LCU.Library.Internal.Configuration" Version="1.0.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.CoreApiWrapperModel" Version="2.27.14" />
|
||||
<PackageReference Include="LCU.Api.Internal.MaidBotLib" Version="1.0.2" />
|
||||
<PackageReference Include="LCU.Library.Internal.Exceptions" Version="1.1.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.Exceptions" Version="2.0.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.FileOperationsModels" Version="4.1.5" />
|
||||
<PackageReference Include="LCU.Library.Internal.LcuClassPatterns.Crud" Version="1.0.2" />
|
||||
<PackageReference Include="LCU.Library.Internal.LcuHttpClient" Version="1.21.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.LcuMassTransit" Version="1.0.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.LcuMassTransitModels" Version="1.1.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.Logging" Version="1.1.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.Status" Version="1.1.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.LCUServiceFactory" Version="4.0.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.Logging" Version="2.2.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.Status" Version="2.0.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.StatusModels" Version="1.1.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
||||
+1
-1
@@ -6,5 +6,5 @@ public class XdiBatchRequest
|
||||
{
|
||||
public List<XdiBatchItem> XdiBatchItems { get; set; }
|
||||
public XdiBatch XdiBatch { get; set; }
|
||||
public string SftpRootBasePath { get; set; }
|
||||
public string XdiAppendFileRootBasePath { get; set; }
|
||||
}
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Models.Requests;
|
||||
|
||||
public class XdiBatchRequests
|
||||
{
|
||||
public List<XdiBatchRequest> XdiBatchRequestList { get; set; }
|
||||
}
|
||||
+1
-5
@@ -77,30 +77,26 @@ public class XdiBatch
|
||||
return false;
|
||||
}
|
||||
|
||||
public IReadOnlyCollection<XdiBatchFile> GetNonEmptyFiles(string pathPrefix = "")
|
||||
public IReadOnlyCollection<XdiBatchFile> GetNonEmptyFiles()
|
||||
{
|
||||
var list = new List<XdiBatchFile>();
|
||||
if (_updateMemberEmail.HasRows())
|
||||
{
|
||||
_updateMemberEmail.FolderPrefix = pathPrefix;
|
||||
list.Add(_updateMemberEmail);
|
||||
}
|
||||
|
||||
if (_addMemberElectronic.HasRows())
|
||||
{
|
||||
_addMemberElectronic.FolderPrefix = pathPrefix;
|
||||
list.Add(_addMemberElectronic);
|
||||
}
|
||||
|
||||
if (_updateMemberToElectronic.HasRows())
|
||||
{
|
||||
_updateMemberToElectronic.FolderPrefix = pathPrefix;
|
||||
list.Add(_updateMemberToElectronic);
|
||||
}
|
||||
|
||||
if (_updateMemberToPrint.HasRows())
|
||||
{
|
||||
_updateMemberToPrint.FolderPrefix = pathPrefix;
|
||||
list.Add(_updateMemberToPrint);
|
||||
}
|
||||
|
||||
|
||||
+6
-11
@@ -5,20 +5,16 @@ namespace LCU.API.Internal.MemberPreferencesApi.Models;
|
||||
|
||||
public class XdiBatchFile
|
||||
{
|
||||
private const string Ext = "LMCU.txt";
|
||||
public XdiFileType Type { get; set; }
|
||||
public List<XdiBatchFileRow> Data { get; set; } = new List<XdiBatchFileRow>();
|
||||
public string FolderPrefix { get; set; } = "";
|
||||
|
||||
public string GetFileName()
|
||||
{
|
||||
switch (Type)
|
||||
{
|
||||
case XdiFileType.AddMemberElectronic: return $"{FolderPrefix}Enrollment_AddElectronic_{Ext}";
|
||||
case XdiFileType.DeleteMember: return $"{FolderPrefix}Enrollment_Delete_{Ext}";
|
||||
case XdiFileType.UpdateMemberEmail: return $"{FolderPrefix}Enrollment_UpdateEmail_{Ext}";
|
||||
case XdiFileType.UpdateMemberToElectronic: return $"{FolderPrefix}Enrollment_UpdateToElectronic_{Ext}";
|
||||
case XdiFileType.UpdateMemberToPrint: return $"{FolderPrefix}Enrollment_UpdateToPrint_{Ext}";
|
||||
case XdiFileType.AddMemberElectronic: return $"Enrollment_AddElectronic_LMCU";
|
||||
case XdiFileType.UpdateMemberEmail: return $"Enrollment_UpdateEmail_LMCU";
|
||||
case XdiFileType.UpdateMemberToElectronic: return $"Enrollment_UpdateToElectronic_LMCU";
|
||||
case XdiFileType.UpdateMemberToPrint: return $"Enrollment_UpdateToPrint_LMCU";
|
||||
default: throw new Exception($"Unknown File Type in XDI BatchFile: {Type}");
|
||||
}
|
||||
}
|
||||
@@ -39,11 +35,10 @@ public class XdiBatchFile
|
||||
return Data.Select(batchRow => batchRow.ConvertToRow(Type));
|
||||
}
|
||||
|
||||
public byte[] ConvertToDataFile()
|
||||
public string ConvertToDataFile()
|
||||
{
|
||||
var allRows = ConvertToDataRows();
|
||||
var file = string.Join("\n", allRows);
|
||||
return Encoding.UTF8.GetBytes(file);
|
||||
return string.Join("\n", allRows);
|
||||
}
|
||||
|
||||
public bool HasRows()
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Models;
|
||||
|
||||
public class FtpQueuePayloadItem
|
||||
public class XdiBatchFileExport
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
public string Value { get; set; }
|
||||
-1
@@ -13,7 +13,6 @@ public class XdiBatchFileRow
|
||||
switch (type)
|
||||
{
|
||||
case XdiFileType.UpdateMemberToPrint:
|
||||
case XdiFileType.DeleteMember: return UserId + "|";
|
||||
case XdiFileType.AddMemberElectronic:
|
||||
case XdiFileType.UpdateMemberEmail:
|
||||
case XdiFileType.UpdateMemberToElectronic: return UserId + "|" + Email + "|";
|
||||
|
||||
+58
-92
@@ -1,31 +1,33 @@
|
||||
using LCU.Library.Internal.Logging.Models;
|
||||
using LCU.Library.Internal.Logging;
|
||||
using LCU.Library.Internal.ApiSecurity;
|
||||
using LCU.Library.Internal.LcuHttpClient;
|
||||
using LCU.Library.Internal.Status;
|
||||
using LCU.Library.Internal.Configuration;
|
||||
using LCU.Library.Internal.LcuMassTransit;
|
||||
using LCU.Library.Internal.Logging.Middleware;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Consumers;
|
||||
using LCU.API.Internal.MemberPreferencesApi.HostedServices;
|
||||
using LCU.API.Internal.MemberPreferencesApiLib.Persistence;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.XdiServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Interfaces;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.DataAccess;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Models;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Models.EmailPolicies;
|
||||
using LCU.API.Internal.MemberPreferencesApiLib.Repositories;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using LCU.Library.Internal.LcuMassTransitModels;
|
||||
using Infrastructure.Services;
|
||||
using Microsoft.FeatureManagement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Consumers;
|
||||
using LCU.API.Internal.MemberPreferencesApi.DataAccess;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Interfaces;
|
||||
using LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Models.EmailPolicies;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.XdiServices;
|
||||
using LCU.API.Internal.MemberPreferencesApiLib.Persistence;
|
||||
using LCU.API.Internal.MemberPreferencesApiLib.Repositories;
|
||||
using LCU.Library.Internal.ApiSecurity;
|
||||
using LCU.Library.Internal.Configuration;
|
||||
using LCU.Library.Internal.LcuClassPatterns.Crud;
|
||||
using LCU.Library.Internal.LcuHttpClient;
|
||||
using LCU.Library.Internal.LcuMassTransit;
|
||||
using LCU.Library.Internal.LcuMassTransitModels;
|
||||
using LCU.Library.Internal.LCUServiceFactory;
|
||||
using LCU.Library.Internal.LCUServiceFactory.Configurations;
|
||||
using LCU.Library.Internal.Logging;
|
||||
using LCU.Library.Internal.Logging.Middleware;
|
||||
using LCU.Library.Internal.Logging.Models;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Models;
|
||||
using LCU.Library.Internal.Status;
|
||||
using MassTransit;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.FeatureManagement;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
|
||||
string MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
|
||||
@@ -37,11 +39,9 @@ BuildAppAndRun(builder);
|
||||
WebApplicationBuilder BuildBuilder(string[] args)
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Configuration.AddJsonFile("/app/config/mapped-appsettings/primary.json", optional: true, reloadOnChange: true);
|
||||
builder.Configuration.AddJsonFile("/app/config/environment-appsettings/appsettings.json", optional: true, reloadOnChange: true);
|
||||
builder.Configuration.AddJsonFile("/app/config/workload-appsettings/appsettings.json", optional: true, reloadOnChange: true);
|
||||
builder.Configuration.AddJsonFile("/vault/secrets/member-preferences-api-member-preferences-api-key.json", optional: true, reloadOnChange: true);
|
||||
builder.Configuration.AddJsonFile("/vault/secrets/member-preferences-api-ftp-fingerprint.json", optional: true, reloadOnChange: true);
|
||||
builder.Configuration.AddJsonFile("/vault/secrets/member-preferences-api-ftp-password.json", optional: true, reloadOnChange: true);
|
||||
builder.Configuration.AddJsonFile("/vault/secrets/member-preferences-api-ftp-username.json", optional: true, reloadOnChange: true);
|
||||
builder.Configuration.AddJsonFile("/vault/secrets/member-preferences-api-queue-password.json", optional: true, reloadOnChange: true);
|
||||
builder.Configuration.AddJsonFile("/vault/secrets/member-preferences-api-queue-username.json", optional: true, reloadOnChange: true);
|
||||
builder.Configuration.AddJsonFile("/vault/secrets/member-preferences-api-db-connection.json", optional: true, reloadOnChange: true);
|
||||
@@ -55,12 +55,12 @@ void BuildServicesAndConfigurations(WebApplicationBuilder builder)
|
||||
{
|
||||
var services = builder.Services;
|
||||
var configuration = builder.Configuration;
|
||||
var servicesFactoryConfiguration = configuration.Bind<ServicesFactoryConfiguration>(services);
|
||||
var apiConfiguration = configuration.Bind<ApiConfiguration>(services, "Primary");
|
||||
configuration.Bind<XdiSftpApiConfiguration>(services);
|
||||
configuration.Bind<FtpApiConfiguration>(services);
|
||||
configuration.Bind<FileOperationsApiConfiguration>(services);
|
||||
configuration.Bind<NotificationApiConfiguration>(services);
|
||||
configuration.Bind<CoreApiWrapperConfiguration>(services);
|
||||
configuration.Bind<DnaAuditProcessConfiguration>(services);
|
||||
configuration.Bind<ScanBiCoreApiWrapperConfiguration>(services);
|
||||
|
||||
var loggerConfiguration = new LoggingConfiguration(apiConfiguration.AppName,
|
||||
apiConfiguration.SeqKey,
|
||||
@@ -82,10 +82,11 @@ void BuildServicesAndConfigurations(WebApplicationBuilder builder)
|
||||
|
||||
services.AddHttpContextAccessor();
|
||||
services.AddHttpClient();
|
||||
services.AddLcuCrudServices();
|
||||
|
||||
var databaseSettings = configuration.Bind<SqlConnectionConfiguration>(services, "SqlConnectionConfiguration");
|
||||
|
||||
services.AddDbContext<ApplicationDbContext>(options =>
|
||||
services.AddDbContextPool<ApplicationDbContext>(options =>
|
||||
{
|
||||
options.UseSqlServer
|
||||
(
|
||||
@@ -94,6 +95,7 @@ void BuildServicesAndConfigurations(WebApplicationBuilder builder)
|
||||
);
|
||||
});
|
||||
|
||||
AddServiceFactoryServices(services);
|
||||
services.AddLCUStatusServicesWithApiHealthCheck(configuration);
|
||||
services.AddLCUHttpServices();
|
||||
services.AddControllers();
|
||||
@@ -103,12 +105,6 @@ void BuildServicesAndConfigurations(WebApplicationBuilder builder)
|
||||
c.SwaggerDoc("v1", new OpenApiInfo { Title = $"{apiConfiguration.AppName}", Version = "v1" });
|
||||
});
|
||||
|
||||
if (apiConfiguration.FeatureFlags.RunHostedServices)
|
||||
{
|
||||
services.AddHostedService<HostedXdiBatchProcessService>();
|
||||
services.AddHostedService<HostedDnaDataAuditProcessService>();
|
||||
}
|
||||
|
||||
services.AddFeatureManagement(configuration.GetSection("Primary:FeatureGates"));
|
||||
|
||||
services.AddScoped<IApplicationDbContext>(provider => provider.GetService<ApplicationDbContext>());
|
||||
@@ -122,13 +118,7 @@ void BuildServicesAndConfigurations(WebApplicationBuilder builder)
|
||||
{
|
||||
XdiBatchProcessEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration, "XdiBatchProcessEndpoint"),
|
||||
|
||||
XdiBatchConfirmEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration, "XdiBatchConfirmEndpoint"),
|
||||
|
||||
DnaAccountAuditEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration, "DnaAccountAuditEndpoint"),
|
||||
|
||||
DnaAgreementAuditEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration, "DnaAgreementAuditEndpoint"),
|
||||
|
||||
DnaOrganizationAuditEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration, "DnaOrganizationAuditEndpoint"),
|
||||
DnaAuditProcessEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration, "DnaAuditProcessEndpoint")
|
||||
};
|
||||
|
||||
services.AddSingleton(receiveEndpointConfigurations);
|
||||
@@ -137,6 +127,7 @@ void BuildServicesAndConfigurations(WebApplicationBuilder builder)
|
||||
AddMemberPreferencesApiServices(services);
|
||||
AddMemberPreferencesDaos(services);
|
||||
AddMemberPreferencesLib(ref services);
|
||||
services.AddLCUServiceFactoryAndValidateServiceRegistration<IDNAAuditCheckService>(servicesFactoryConfiguration);
|
||||
}
|
||||
|
||||
void AddMassTransitServices(ref IServiceCollection services,
|
||||
@@ -147,10 +138,7 @@ void AddMassTransitServices(ref IServiceCollection services,
|
||||
services.AddMassTransit(x =>
|
||||
{
|
||||
x.AddConsumer<XdiBatchProcessConsumer>();
|
||||
x.AddConsumer<XdiSshResponseConsumer>();
|
||||
x.AddConsumer<AccountDnaFieldChangeConsumer>();
|
||||
x.AddConsumer<AgreementDnaFieldChangeConsumer>();
|
||||
x.AddConsumer<OrganizationDnaFieldChangeConsumer>();
|
||||
x.AddConsumer<DnaAuditProcessConsumer>();
|
||||
|
||||
x.UsingRabbitMq((context, cfg) =>
|
||||
{
|
||||
@@ -170,43 +158,13 @@ void AddMassTransitServices(ref IServiceCollection services,
|
||||
});
|
||||
}
|
||||
|
||||
if (configuration.FeatureFlags.RunXdiSshResponseConsumer)
|
||||
if (configuration.FeatureFlags.RunDnaAuditProcessConsumer)
|
||||
{
|
||||
cfg.ReceiveEndpoint(receiveEndpointConfigurations.XdiBatchConfirmEndpoint.ReceiveEndpoint, e =>
|
||||
cfg.ReceiveEndpoint(receiveEndpointConfigurations.DnaAuditProcessEndpoint.ReceiveEndpoint, e =>
|
||||
{
|
||||
e.ConfigureConsumer<XdiSshResponseConsumer>(context);
|
||||
e.ConfigureConsumer<DnaAuditProcessConsumer>(context);
|
||||
e.SetQuorumQueue();
|
||||
e.PrefetchCount = receiveEndpointConfigurations.XdiBatchConfirmEndpoint.PrefetchLimit;
|
||||
});
|
||||
}
|
||||
|
||||
if (configuration.FeatureFlags.RunAccountDnaFieldChangeConsumer)
|
||||
{
|
||||
cfg.ReceiveEndpoint(receiveEndpointConfigurations.DnaAccountAuditEndpoint.ReceiveEndpoint, e =>
|
||||
{
|
||||
e.ConfigureConsumer<AccountDnaFieldChangeConsumer>(context);
|
||||
e.SetQuorumQueue();
|
||||
e.PrefetchCount = receiveEndpointConfigurations.DnaAccountAuditEndpoint.PrefetchLimit;
|
||||
});
|
||||
}
|
||||
|
||||
if (configuration.FeatureFlags.RunAgreementDnaFieldChangeConsumer)
|
||||
{
|
||||
cfg.ReceiveEndpoint(receiveEndpointConfigurations.DnaAgreementAuditEndpoint.ReceiveEndpoint, e =>
|
||||
{
|
||||
e.ConfigureConsumer<AgreementDnaFieldChangeConsumer>(context);
|
||||
e.SetQuorumQueue();
|
||||
e.PrefetchCount = receiveEndpointConfigurations.DnaAgreementAuditEndpoint.PrefetchLimit;
|
||||
});
|
||||
}
|
||||
|
||||
if (configuration.FeatureFlags.RunOrganizationDnaFieldChangeConsumer)
|
||||
{
|
||||
cfg.ReceiveEndpoint(receiveEndpointConfigurations.DnaOrganizationAuditEndpoint.ReceiveEndpoint, e =>
|
||||
{
|
||||
e.ConfigureConsumer<OrganizationDnaFieldChangeConsumer>(context);
|
||||
e.SetQuorumQueue();
|
||||
e.PrefetchCount = receiveEndpointConfigurations.DnaOrganizationAuditEndpoint.PrefetchLimit;
|
||||
e.PrefetchCount = receiveEndpointConfigurations.DnaAuditProcessEndpoint.PrefetchLimit;
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -214,6 +172,13 @@ void AddMassTransitServices(ref IServiceCollection services,
|
||||
services.AddMassTransitHostedService();
|
||||
}
|
||||
|
||||
void AddServiceFactoryServices(IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<IDNAAuditCheckService, DNADataAccountAuditCheckService>();
|
||||
services.AddScoped<IDNAAuditCheckService, DNADataAgreementAuditCheckService>();
|
||||
services.AddScoped<IDNAAuditCheckService, DNADataOrganizationAuditService>();
|
||||
}
|
||||
|
||||
void AddMemberPreferencesApiServices(IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<IOptinService, OptinService>();
|
||||
@@ -230,7 +195,7 @@ void AddMemberPreferencesApiServices(IServiceCollection services)
|
||||
|
||||
void AddDnaAuditServices(IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<IDNADataAuditService, DNADataAuditService>();
|
||||
services.AddScoped<IDNAAuditHelperService, DNAAuditHelperService>();
|
||||
services.AddScoped<IDNADataAuditProcessService, DNADataAuditProcessService>();
|
||||
}
|
||||
|
||||
@@ -253,24 +218,24 @@ void AddEmailUndeliverableServices(IServiceCollection services)
|
||||
|
||||
void AddQueueServices(IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<IQueueDnaAccountAuditService, QueueDnaAccountAuditService>();
|
||||
services.AddScoped<IQueueDnaOrganizationAuditService, QueueDnaOrganizationService>();
|
||||
services.AddScoped<IQueueDnaAgreementAuditService, QueueDnaAgreementAuditService>();
|
||||
services.AddScoped<IQueueXdiBatchService, QueueXdiBatchService>();
|
||||
services.AddScoped<IQueueXdiBatchProcessService, QueueXdiBatchProcessService>();
|
||||
services.AddScoped<IQueueDnaAuditProcessService, QueueDnaAuditProcessService>();
|
||||
}
|
||||
|
||||
void AddMicroApiServices(IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<ICoreApiWrapperService, CoreApiWrapperService>();
|
||||
services.AddScoped<IFtpApiService, FtpApiService>();
|
||||
services.AddScoped<IScanBiCoreApiWrapperService, ScanBiCoreApiWrapperService>();
|
||||
services.AddScoped<INotificationService, NotificationService>();
|
||||
services.AddScoped<IFileOperationsApiService, FileOperationsApiService>();
|
||||
}
|
||||
|
||||
void AddMemberPreferencesDaos(IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<INotificationApiDao, NotificationApiDao>();
|
||||
services.AddScoped<IFtpApiDao, FtpApiDao>();
|
||||
services.AddScoped<ICoreApiWrapperDao, CoreApiWrapperDao>();
|
||||
services.AddScoped<IScanBiCoreApiWrapperDao, ScanBiCoreApiWrapperDao>();
|
||||
services.AddScoped<IFileOperationsApiDao, FileOperationsApiDao>();
|
||||
}
|
||||
|
||||
void AddMemberPreferencesLib(ref IServiceCollection services)
|
||||
@@ -280,6 +245,7 @@ void AddMemberPreferencesLib(ref IServiceCollection services)
|
||||
services.AddScoped<IMemberPreferenceRepository, MemberPreferenceRepository>();
|
||||
services.AddScoped<IMemberPreferences, MemberPreferenceRepository>();
|
||||
services.AddScoped<IXdiBatchItemsRepository, XdiBatchItemsRepository>();
|
||||
services.AddScoped<IXdiBatchProcessInfoRepository, XdiBatchProcessInfoRepository>();
|
||||
services.AddScoped<IDnaAuditProcessRepository, DnaAuditProcessRepository>();
|
||||
}
|
||||
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
using LCU.Library.Internal.LCUServiceFactory.Configurations;
|
||||
using LCU.Library.Internal.LCUServiceFactory.Services;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
|
||||
public abstract class DNAAuditCheckService(ServicesFactoryConfiguration servicesFactoryConfiguration)
|
||||
: LcuAbstractService(servicesFactoryConfiguration.GetServiceFactoryRegistrationByInterface<IDNAAuditCheckService>())
|
||||
{
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Agreements;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
|
||||
public class DNAAuditHelperService : IDNAAuditHelperService
|
||||
{
|
||||
private readonly ICoreApiWrapperService _coreApiWrapperService;
|
||||
private readonly IOptinService _optinService;
|
||||
|
||||
private const string MemberPreferencePrint = "PRNT";
|
||||
private const string MemberPreferenceElectronic = "WWW";
|
||||
|
||||
public DNAAuditHelperService(ICoreApiWrapperService coreApiWrapperService, IOptinService optinService)
|
||||
{
|
||||
_optinService = optinService;
|
||||
_coreApiWrapperService = coreApiWrapperService;
|
||||
}
|
||||
|
||||
public async Task UpdateAccountDeliveryMethodIfNotEqualToMemberPreference(AgreementAccount account)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (account.AccountOwner?.UserId == null)
|
||||
{
|
||||
await _coreApiWrapperService.UpdateAgreementAccountsDeliveryMethod(new List<long> { account.AccountNumber }, "PRNT", "None Found During Audit");
|
||||
return;
|
||||
}
|
||||
|
||||
var currentAccountDeliveryMethod = account.OvrDeliveryMethCD;
|
||||
|
||||
var memberOptinSettings = await _optinService.GetMemberOptInSettings(account.AccountOwner.UserId);
|
||||
var memberPreferenceDeliveryMethod = DetermineMemberPreference(memberOptinSettings);
|
||||
|
||||
if (!string.Equals(currentAccountDeliveryMethod, memberPreferenceDeliveryMethod, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
await _coreApiWrapperService.UpdateAgreementAccountsDeliveryMethod(new List<long> { account.AccountNumber }, memberPreferenceDeliveryMethod, account.AccountOwner.UserId);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = $"Failed to UpdateAccountDeliveryMethodIfNotEqualToMemberPreference for account number: {account.AccountNumber}";
|
||||
Log.Error(ex, error);
|
||||
throw new ServiceException(error);
|
||||
}
|
||||
}
|
||||
|
||||
private string DetermineMemberPreference(MemberOptInSettings optinSettings)
|
||||
{
|
||||
if (optinSettings == null)
|
||||
{
|
||||
return MemberPreferencePrint;
|
||||
}
|
||||
|
||||
if (optinSettings.IsUnifiedElectronicEnrolled())
|
||||
{
|
||||
return MemberPreferenceElectronic;
|
||||
}
|
||||
|
||||
if (optinSettings.IsUnifiedPaperEnrolled())
|
||||
{
|
||||
return MemberPreferencePrint;
|
||||
}
|
||||
|
||||
if (string.Equals(optinSettings.EStatements, "Paper", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
return MemberPreferencePrint;
|
||||
}
|
||||
|
||||
if (string.Equals(optinSettings.EStatements, "Electronic", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
return MemberPreferenceElectronic;
|
||||
}
|
||||
|
||||
return MemberPreferencePrint;
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
using LCU.Library.Internal.LCUServiceFactory.Configurations;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Responses;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
|
||||
public class DNADataAccountAuditCheckService : DNAAuditCheckService, IDNAAuditCheckService
|
||||
{
|
||||
|
||||
private readonly ICoreApiWrapperService _coreApiWrapperService;
|
||||
private readonly IDNAAuditHelperService _auditHelperService;
|
||||
public DNADataAccountAuditCheckService(ServicesFactoryConfiguration servicesFactoryConfiguration,
|
||||
ICoreApiWrapperService coreApiWrapperService,
|
||||
IDNAAuditHelperService auditHelperService)
|
||||
: base(servicesFactoryConfiguration)
|
||||
{
|
||||
_coreApiWrapperService = coreApiWrapperService;
|
||||
_auditHelperService = auditHelperService;
|
||||
}
|
||||
|
||||
public async Task<RequestResponse> ProcessRequest(DnaAuditProcessRequest request, DnaAuditProcess dnaAuditProcess)
|
||||
{
|
||||
try
|
||||
{
|
||||
var accountAuditRecords = await AuditDNAAccountsForTimePeriod(dnaAuditProcess.LastUpdated.AddMinutes(request.LookBackMinutes));
|
||||
|
||||
await HandleAccountAuditCheck(accountAuditRecords);
|
||||
|
||||
return new RequestResponse(request, true, new List<string>() { $"DNAAccountAudit ran successfully for {accountAuditRecords.Count} records" });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = $"Failure During ProcessRequest in DNADataAccountAuditCheckService. Exception Message: {ex.Message}";
|
||||
return new RequestResponse(request, false, new List<string>() { error });
|
||||
}
|
||||
}
|
||||
|
||||
public async Task HandleAccountAuditCheck(List<long> accountAuditRecords)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var record in accountAuditRecords)
|
||||
{
|
||||
var account = await _coreApiWrapperService.GetAgreementAccountByAccountId(record);
|
||||
|
||||
if (account == null)
|
||||
{
|
||||
Log.Information($"During audit process account with ID: {record} could not be found, and will not be processed.");
|
||||
continue;
|
||||
}
|
||||
|
||||
await _auditHelperService.UpdateAccountDeliveryMethodIfNotEqualToMemberPreference(account);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failed to process DNA Audit for member preferences Account.");
|
||||
throw new ServiceException(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<long>> AuditDNAAccountsForTimePeriod(DateTime timeToSearchFrom)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dnaAccountAuditRecords = await _coreApiWrapperService.GetAuditAccountsFromDateLastMaintained(timeToSearchFrom);
|
||||
return dnaAccountAuditRecords.ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ServiceException(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Agreements;
|
||||
using LCU.Library.Internal.LCUServiceFactory.Configurations;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Responses;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
|
||||
public class DNADataAgreementAuditCheckService : DNAAuditCheckService, IDNAAuditCheckService
|
||||
{
|
||||
private readonly ICoreApiWrapperService _coreApiWrapperService;
|
||||
private readonly IDNAAuditHelperService _auditHelperService;
|
||||
public DNADataAgreementAuditCheckService(ServicesFactoryConfiguration servicesFactoryConfiguration,
|
||||
ICoreApiWrapperService coreApiWrapperService,
|
||||
IDNAAuditHelperService auditHelperService)
|
||||
: base(servicesFactoryConfiguration)
|
||||
{
|
||||
_coreApiWrapperService = coreApiWrapperService;
|
||||
_auditHelperService = auditHelperService;
|
||||
}
|
||||
|
||||
public async Task<RequestResponse> ProcessRequest(DnaAuditProcessRequest request, DnaAuditProcess dnaAuditProcess)
|
||||
{
|
||||
try
|
||||
{
|
||||
var agreementAuditRecords = await AuditDNAAgreementForTimePeriod(dnaAuditProcess.LastUpdated.AddMinutes(request.LookBackMinutes));
|
||||
|
||||
await HandleAgreementAuditCheck(agreementAuditRecords);
|
||||
|
||||
return new RequestResponse(request, true, new List<string>() { $"DNAAgreementAudit ran successfully for {agreementAuditRecords.Count} records" });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = $"Failure During ProcessRequest in DNADataAgreementAuditCheckService. Exception Message: {ex.Message}";
|
||||
return new RequestResponse(request, false, new List<string>() { error });
|
||||
}
|
||||
}
|
||||
|
||||
public async Task HandleAgreementAuditCheck(List<long> agreementAuditRecords)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var record in agreementAuditRecords)
|
||||
{
|
||||
var agreement = await _coreApiWrapperService.GetAgreementByAgreementId(record);
|
||||
|
||||
if (agreement == null)
|
||||
{
|
||||
Log.Information($"During audit process agreement with ID: {record} could not be found, and will not be processed.");
|
||||
continue;
|
||||
}
|
||||
|
||||
IEnumerable<AgreementAccount> agreementAccounts;
|
||||
|
||||
if (agreement.ByOrgNbr != 0)
|
||||
{
|
||||
agreementAccounts = await _coreApiWrapperService.GetAgreementAccountsByOrganizationId(agreement.ByOrgNbr);
|
||||
}
|
||||
else
|
||||
{
|
||||
agreementAccounts = await _coreApiWrapperService.GetAgreementAccountsByUserId(agreement.UserId);
|
||||
agreementAccounts = agreementAccounts.Where(account => account.TaxReportForPersonNumber != null && account.AccountOwner.AgreementNumber == agreement.AgreementNumber);
|
||||
}
|
||||
|
||||
foreach (var agreementAccount in agreementAccounts)
|
||||
{
|
||||
await _auditHelperService.UpdateAccountDeliveryMethodIfNotEqualToMemberPreference(agreementAccount);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failed to process DNA Audit for member preferences Agreement.");
|
||||
throw new ServiceException(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<long>> AuditDNAAgreementForTimePeriod(DateTime timeToSearchFrom)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dnaAgreementAuditRecords = await _coreApiWrapperService.GetAuditAgreementFromDateLastMaintained(timeToSearchFrom);
|
||||
return dnaAgreementAuditRecords.ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ServiceException(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
+44
-92
@@ -1,9 +1,10 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.Interfaces;
|
||||
using LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
using LCU.API.Internal.MemberPreferencesApiLib.Repositories;
|
||||
using LCU.Library.Internal.ApiResponse.Services;
|
||||
using LCU.Library.Internal.LCUServiceFactory.Services;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Responses;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
|
||||
@@ -11,135 +12,86 @@ public class DNADataAuditProcessService : IDNADataAuditProcessService
|
||||
{
|
||||
private readonly IDateTime _dateTime;
|
||||
private readonly ICoreApiWrapperService _coreApiWrapperService;
|
||||
private readonly IScanBiCoreApiWrapperService _scanBiCoreApiWrapperService;
|
||||
private readonly IDnaAuditProcessRepository _dnaAuditProcessRepository;
|
||||
private readonly DnaAuditProcessConfiguration _dnaAuditProcessConfig;
|
||||
private readonly IQueueDnaAccountAuditService _queueDnaAccountAuditService;
|
||||
private readonly IQueueDnaAgreementAuditService _queueDnaAgreementAuditService;
|
||||
private readonly IQueueDnaOrganizationAuditService _queueDnaOrganizationAuditService;
|
||||
private readonly ILcuServiceFactory<IDNAAuditCheckService> _lcuServiceFactory;
|
||||
|
||||
public DNADataAuditProcessService(IQueueDnaAccountAuditService queueDnaAccountAuditService,
|
||||
IQueueDnaAgreementAuditService queueDnaAgreementAuditService,
|
||||
IQueueDnaOrganizationAuditService queueDnaOrganizationAuditService,
|
||||
ICoreApiWrapperService coreApiWrapperService, IDateTime dateTime,
|
||||
IDnaAuditProcessRepository dnaAuditProcessRepository, DnaAuditProcessConfiguration dnaAuditProcessConfig)
|
||||
public DNADataAuditProcessService(ICoreApiWrapperService coreApiWrapperService,
|
||||
IScanBiCoreApiWrapperService scanBiCoreApiWrapperService,
|
||||
IDateTime dateTime,
|
||||
IDnaAuditProcessRepository dnaAuditProcessRepository,
|
||||
ILcuServiceFactory<IDNAAuditCheckService> lcuServiceFactory)
|
||||
{
|
||||
_queueDnaAccountAuditService = queueDnaAccountAuditService;
|
||||
_queueDnaAgreementAuditService = queueDnaAgreementAuditService;
|
||||
_queueDnaOrganizationAuditService = queueDnaOrganizationAuditService;
|
||||
_coreApiWrapperService = coreApiWrapperService;
|
||||
_scanBiCoreApiWrapperService = scanBiCoreApiWrapperService;
|
||||
_dateTime = dateTime;
|
||||
_dnaAuditProcessRepository = dnaAuditProcessRepository;
|
||||
_dnaAuditProcessConfig = dnaAuditProcessConfig;
|
||||
_lcuServiceFactory = lcuServiceFactory;
|
||||
}
|
||||
|
||||
public async Task RunDataAuditProcesses()
|
||||
public async Task HandleDnaAuditProcessRequest(DnaAuditProcessRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dnaProcesses = await _dnaAuditProcessRepository.GetAllDnaAuditProcesses();
|
||||
|
||||
foreach (var dnaProcess in dnaProcesses)
|
||||
var dnaAuditProcess = await _dnaAuditProcessRepository.GetDnaAuditProcessByDnaProcessType(request.DnaAuditProcessType);
|
||||
if (dnaAuditProcess == null)
|
||||
{
|
||||
var timeToSearchFrom = dnaProcess.LastUpdated.AddMinutes(_dnaAuditProcessConfig.LookBackMinutes);
|
||||
throw new Exception($"DnaAuditProcess not found for requested type: {request.DnaAuditProcessType.ToString()}");
|
||||
}
|
||||
|
||||
switch (dnaProcess.DnaProcessType)
|
||||
{
|
||||
case DnaAuditProcessType.DNAOrganization:
|
||||
await AuditDNAOrganizationForTimePeriod(timeToSearchFrom, dnaProcess);
|
||||
break;
|
||||
case DnaAuditProcessType.DNAAgreement:
|
||||
await AuditDNAAgreementForTimePeriod(timeToSearchFrom, dnaProcess);
|
||||
break;
|
||||
case DnaAuditProcessType.DNAAccounts:
|
||||
await AuditDNAAccountsForTimePeriod(timeToSearchFrom, dnaProcess);
|
||||
break;
|
||||
default:
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error($"DnaAuditProcessType not found for ProcessId: {dnaProcess.ProcessId}. ProcessType: {dnaProcess.DnaProcessType}");
|
||||
break;
|
||||
}
|
||||
}
|
||||
var result = await PerformDNAAuditCheck(request, dnaAuditProcess);
|
||||
// Return successful as True so Dispatcher job never stops running.
|
||||
result.IsSuccessful = true;
|
||||
|
||||
await QueueReturnResponse.QueueResponse(request, result.IsSuccessful, result.MessageStack);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group), Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(ex, "Failed to Queue Last 5 Minutes of MemberPreference DNA DataAudit Activity");
|
||||
Log.Error(ex.Message);
|
||||
// Return successful as True so Dispatcher job never stops running.
|
||||
await QueueReturnResponse.QueueResponse(request, true, new List<string>() { ex.Message });
|
||||
throw new ServiceException($"Failed to handled Consumed DnaAuditProcessRequest. ExceptionMessage: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task AuditDNAOrganizationForTimePeriod(DateTime timeToSearchFrom, DnaAuditProcess dnaProcess)
|
||||
public async Task<RequestResponse> PerformDNAAuditCheck(DnaAuditProcessRequest request, DnaAuditProcess dnaAuditProcess)
|
||||
{
|
||||
var requestResponse = new RequestResponse(request);
|
||||
try
|
||||
{
|
||||
var dnaOrganizationAuditRecords = await _coreApiWrapperService.GetAuditOrganizationFromDateLastMaintained(timeToSearchFrom);
|
||||
var organizationAuditRecords = dnaOrganizationAuditRecords.ToList();
|
||||
await _queueDnaOrganizationAuditService.QueueDataAuditForOrganizations(organizationAuditRecords, dnaProcess.ConsecutiveFailures);
|
||||
var dnaAuditCheckService = _lcuServiceFactory.GetService(request.DnaAuditProcessType);
|
||||
|
||||
Log.Information($"Queued {organizationAuditRecords.Count} DataAudit Organization Changes Since Last DNADataAuditProducerService Run.");
|
||||
dnaProcess = HandleDnaAuditProcessSuccess(dnaProcess);
|
||||
requestResponse = await dnaAuditCheckService.ProcessRequest(request, dnaAuditProcess);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
dnaProcess = HandleDnaAuditProcessException(dnaProcess, ex);
|
||||
var failureMessage = $"Failed to perform DNA Data Audit Process. Exception Message: {ex.Message}";
|
||||
Log.Error(failureMessage);
|
||||
requestResponse.MessageStack.Add(failureMessage);
|
||||
requestResponse.IsSuccessful = false;
|
||||
}
|
||||
await _dnaAuditProcessRepository.Update(dnaProcess);
|
||||
await _dnaAuditProcessRepository.Update(requestResponse.IsSuccessful ?
|
||||
HandleDnaAuditProcessSuccess(dnaAuditProcess) :
|
||||
HandleDnaAuditProcessException(dnaAuditProcess, request));
|
||||
return requestResponse;
|
||||
}
|
||||
|
||||
public async Task AuditDNAAgreementForTimePeriod(DateTime timeToSearchFrom, DnaAuditProcess dnaProcess)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dnaAgreementAuditRecords = await _coreApiWrapperService.GetAuditAgreementFromDateLastMaintained(timeToSearchFrom);
|
||||
var agreementAuditRecords = dnaAgreementAuditRecords.ToList();
|
||||
await _queueDnaAgreementAuditService.QueueDataAuditForAgreements(agreementAuditRecords, dnaProcess.ConsecutiveFailures);
|
||||
|
||||
Log.Information($"Queued {agreementAuditRecords.Count} DataAudit Agreement Changes Since Last DNADataAuditProducerService Run.");
|
||||
dnaProcess = HandleDnaAuditProcessSuccess(dnaProcess);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
dnaProcess = HandleDnaAuditProcessException(dnaProcess, ex);
|
||||
}
|
||||
|
||||
await _dnaAuditProcessRepository.Update(dnaProcess);
|
||||
}
|
||||
|
||||
public async Task AuditDNAAccountsForTimePeriod(DateTime timeToSearchFrom, DnaAuditProcess dnaProcess)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dnaAccountAuditRecords = await _coreApiWrapperService.GetAuditAccountsFromDateLastMaintained(timeToSearchFrom);
|
||||
var accountAuditRecords = dnaAccountAuditRecords.ToList();
|
||||
await _queueDnaAccountAuditService.QueueDataAuditForAccounts(accountAuditRecords, dnaProcess.ConsecutiveFailures);
|
||||
|
||||
Log.Information($"Queued {accountAuditRecords.Count} DataAudit Account Changes Since Last DNADataAuditProducerService Run.");
|
||||
dnaProcess = HandleDnaAuditProcessSuccess(dnaProcess);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
dnaProcess = HandleDnaAuditProcessException(dnaProcess, ex);
|
||||
}
|
||||
|
||||
await _dnaAuditProcessRepository.Update(dnaProcess);
|
||||
}
|
||||
|
||||
public DnaAuditProcess HandleDnaAuditProcessException(DnaAuditProcess process, Exception ex)
|
||||
public DnaAuditProcess HandleDnaAuditProcessException(DnaAuditProcess process, DnaAuditProcessRequest request)
|
||||
{
|
||||
process.ConsecutiveFailures++;
|
||||
|
||||
if (process.ConsecutiveFailures >= _dnaAuditProcessConfig.NumberOfAllowedConsecutiveFailures)
|
||||
if (process.ConsecutiveFailures >= request.NumberOfAllowedConsecutiveFailures)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error($"DnaAuditProcess for {process.DnaProcessType} has failed {process.ConsecutiveFailures} consecutive times. " +
|
||||
$"Last succesful runtime: {process.LastUpdated} CST. " +
|
||||
$"This process needs to checked on to determine why failure is occuring.");
|
||||
$"Last successful runtime: {process.LastUpdated} CST. " +
|
||||
$"This process needs to be checked on to determine why failure is occurring.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Warning($"Exception and Failure occured for DnaAuditProcess: {process.DnaProcessType}. ConsecutiveFailures: {process.ConsecutiveFailures}. " +
|
||||
$"Last succesful runtime: {process.LastUpdated} CST. Exception: {ex}");
|
||||
Log.Warning($"Exception and Failure occurred for DnaAuditProcess: {process.DnaProcessType}. ConsecutiveFailures: {process.ConsecutiveFailures}. " +
|
||||
$"Last successful runtime: {process.LastUpdated} CST.");
|
||||
}
|
||||
|
||||
return process;
|
||||
|
||||
-161
@@ -1,161 +0,0 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Agreements;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
|
||||
public class DNADataAuditService : IDNADataAuditService
|
||||
{
|
||||
private readonly ICoreApiWrapperService _coreApiWrapperService;
|
||||
private readonly IOptinService _optinService;
|
||||
|
||||
private const string MemberPreferencePrint = "PRNT";
|
||||
private const string MemberPreferenceElectronic = "WWW";
|
||||
|
||||
public DNADataAuditService(ICoreApiWrapperService coreApiWrapperService, IOptinService optinService)
|
||||
{
|
||||
_optinService = optinService;
|
||||
_coreApiWrapperService = coreApiWrapperService;
|
||||
}
|
||||
|
||||
public async Task HandleAccountAuditCheck(DnaFieldChangeRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var accountNumber = request.DnaFieldIdInformation;
|
||||
var account = await _coreApiWrapperService.GetAgreementAccountByAccountId(accountNumber);
|
||||
|
||||
if (account == null)
|
||||
{
|
||||
Log.Information($"During audit process account with ID: {accountNumber} could not be found, and will not be processed.");
|
||||
return;
|
||||
}
|
||||
|
||||
await UpdateAccountDeliveryMethodIfNotEqualToMemberPreference(account);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex,
|
||||
$"Failed to process DNA Audit for member preferences Account.");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task HandleAgreementAuditCheck(DnaFieldChangeRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var agreementNumber = request.DnaFieldIdInformation;
|
||||
var agreement = await _coreApiWrapperService.GetAgreementByAgreementId(agreementNumber);
|
||||
|
||||
if (agreement == null)
|
||||
{
|
||||
Log.Information($"During audit process agreement with ID: {agreementNumber} could not be found, and will not be processed.");
|
||||
return;
|
||||
}
|
||||
|
||||
IEnumerable<AgreementAccount> agreementAccounts;
|
||||
|
||||
if (agreement.ByOrgNbr != 0)
|
||||
{
|
||||
agreementAccounts = await _coreApiWrapperService.GetAgreementAccountsByOrganizationId(agreement.ByOrgNbr);
|
||||
}
|
||||
else
|
||||
{
|
||||
agreementAccounts = await _coreApiWrapperService.GetAgreementAccountsByUserId(agreement.UserId);
|
||||
agreementAccounts = agreementAccounts.Where(account => account.TaxReportForPersonNumber != null && account.AccountOwner.AgreementNumber == agreement.AgreementNumber);
|
||||
}
|
||||
|
||||
foreach (var agreementAccount in agreementAccounts)
|
||||
{
|
||||
await UpdateAccountDeliveryMethodIfNotEqualToMemberPreference(agreementAccount);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex,
|
||||
$"Failed to process DNA Audit for member preferences Agreement.");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task HandleOrganizationAuditCheck(DnaFieldChangeRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var organizationId = request.DnaFieldIdInformation;
|
||||
var organizationAccounts = await _coreApiWrapperService.GetAgreementAccountsByOrganizationId(organizationId);
|
||||
|
||||
if (organizationAccounts == null)
|
||||
{
|
||||
Log.Information($"During audit process organization with ID: {organizationId} could not be found, and will not be processed.");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var account in organizationAccounts)
|
||||
{
|
||||
await UpdateAccountDeliveryMethodIfNotEqualToMemberPreference(account);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex,
|
||||
$"Failed to process DNA Audit for member preferences Organization.");
|
||||
}
|
||||
}
|
||||
|
||||
private async Task UpdateAccountDeliveryMethodIfNotEqualToMemberPreference(AgreementAccount account)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (account.AccountOwner?.UserId == null)
|
||||
{
|
||||
await _coreApiWrapperService.UpdateAgreementAccountsDeliveryMethod(new List<long> { account.AccountNumber }, "PRNT", "None Found During Audit");
|
||||
return;
|
||||
}
|
||||
|
||||
var currentAccountDeliveryMethod = account.OvrDeliveryMethCD;
|
||||
|
||||
var memberOptinSettings = await _optinService.GetMemberOptInSettings(account.AccountOwner.UserId);
|
||||
var memberPreferenceDeliveryMethod = DetermineMemberPreference(memberOptinSettings);
|
||||
|
||||
if (!string.Equals(currentAccountDeliveryMethod, memberPreferenceDeliveryMethod, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
await _coreApiWrapperService.UpdateAgreementAccountsDeliveryMethod(new List<long> { account.AccountNumber }, memberPreferenceDeliveryMethod, account.AccountOwner.UserId);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failed to UpdateAccountDeliveryMethodIfNotEqualToMemberPreference for account number: {account.AccountNumber}");
|
||||
}
|
||||
}
|
||||
|
||||
private string DetermineMemberPreference(MemberOptInSettings optinSettings)
|
||||
{
|
||||
if (optinSettings == null)
|
||||
{
|
||||
return MemberPreferencePrint;
|
||||
}
|
||||
|
||||
if (optinSettings.IsUnifiedElectronicEnrolled())
|
||||
{
|
||||
return MemberPreferenceElectronic;
|
||||
}
|
||||
|
||||
if (optinSettings.IsUnifiedPaperEnrolled())
|
||||
{
|
||||
return MemberPreferencePrint;
|
||||
}
|
||||
|
||||
if (string.Equals(optinSettings.EStatements, "Paper", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
return MemberPreferencePrint;
|
||||
}
|
||||
|
||||
if (string.Equals(optinSettings.EStatements, "Electronic", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
return MemberPreferenceElectronic;
|
||||
}
|
||||
|
||||
return MemberPreferencePrint;
|
||||
}
|
||||
}
|
||||
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
using LCU.Library.Internal.LCUServiceFactory.Configurations;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Responses;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
|
||||
public class DNADataOrganizationAuditService : DNAAuditCheckService, IDNAAuditCheckService
|
||||
{
|
||||
private readonly IScanBiCoreApiWrapperService _scanBiCoreApiWrapperService;
|
||||
private readonly ICoreApiWrapperService _coreApiWrapperService;
|
||||
private readonly IServiceScopeFactory _serviceScopeFactory;
|
||||
private readonly IDNAAuditHelperService _auditHelperService;
|
||||
|
||||
public DNADataOrganizationAuditService(ServicesFactoryConfiguration servicesFactoryConfiguration,
|
||||
ICoreApiWrapperService coreApiWrapperService,
|
||||
IScanBiCoreApiWrapperService scanBiCoreApiWrapperService,
|
||||
IServiceScopeFactory serviceScopeFactory,
|
||||
IDNAAuditHelperService auditHelperService)
|
||||
: base(servicesFactoryConfiguration)
|
||||
{
|
||||
_serviceScopeFactory = serviceScopeFactory;
|
||||
_coreApiWrapperService = coreApiWrapperService;
|
||||
_scanBiCoreApiWrapperService = scanBiCoreApiWrapperService;
|
||||
_auditHelperService = auditHelperService;
|
||||
}
|
||||
|
||||
public async Task<RequestResponse> ProcessRequest(DnaAuditProcessRequest request, DnaAuditProcess dnaAuditProcess)
|
||||
{
|
||||
try
|
||||
{
|
||||
var organizationAuditRecords = await AuditDNAOrganizationForTimePeriod(dnaAuditProcess.LastUpdated.AddMinutes(request.LookBackMinutes));
|
||||
|
||||
await HandleOrganizationAuditCheck(organizationAuditRecords);
|
||||
|
||||
return new RequestResponse(request, true, new List<string>() { $"DNAOrganizationAudit ran successfully for {organizationAuditRecords.Count} records" });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = $"Failure During ProcessRequest in DNADataOrganizationAuditService. Exception Message: {ex.Message}";
|
||||
return new RequestResponse(request, false, new List<string>() { error });
|
||||
}
|
||||
}
|
||||
|
||||
public async Task HandleOrganizationAuditCheck(List<long> organizationAuditRecords)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var record in organizationAuditRecords)
|
||||
{
|
||||
var organizationAccounts = await _coreApiWrapperService.GetAgreementAccountsByOrganizationId(record);
|
||||
var organizationAccountsList = organizationAccounts.ToList();
|
||||
|
||||
if (organizationAccountsList == null)
|
||||
{
|
||||
Log.Information($"During audit process organization with ID: {record} could not be found, and will not be processed.");
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var account in organizationAccountsList)
|
||||
{
|
||||
await _auditHelperService.UpdateAccountDeliveryMethodIfNotEqualToMemberPreference(account);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failed to process DNA Audit for member preferences Organization.");
|
||||
throw new ServiceException($"Failure in DNADataOrganizationAuditService HandleOrganizationAuditCheck. ExceptionMessage: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<long>> AuditDNAOrganizationForTimePeriod(DateTime timeToSearchFrom)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dnaOrganizationAuditRecords = await _scanBiCoreApiWrapperService.GetAuditOrganizationFromDateLastMaintained(timeToSearchFrom);
|
||||
return dnaOrganizationAuditRecords.ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new ServiceException(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
using LCU.Library.Internal.LCUServiceFactory.Services;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Responses;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
|
||||
public interface IDNAAuditCheckService : ILcuService
|
||||
{
|
||||
Task<RequestResponse> ProcessRequest(DnaAuditProcessRequest request, DnaAuditProcess dnaAuditProcess);
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.Agreements;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
|
||||
public interface IDNAAuditHelperService
|
||||
{
|
||||
Task UpdateAccountDeliveryMethodIfNotEqualToMemberPreference(AgreementAccount account);
|
||||
}
|
||||
+1
-4
@@ -4,8 +4,5 @@ namespace LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
|
||||
public interface IDNADataAuditProcessService
|
||||
{
|
||||
Task RunDataAuditProcesses();
|
||||
Task AuditDNAOrganizationForTimePeriod(DateTime timeToSearchFrom, DnaAuditProcess dnaProcess);
|
||||
Task AuditDNAAgreementForTimePeriod(DateTime timeToSearchFrom, DnaAuditProcess dnaProcess);
|
||||
Task AuditDNAAccountsForTimePeriod(DateTime timeToSearchFrom, DnaAuditProcess dnaProcess);
|
||||
Task HandleDnaAuditProcessRequest(DnaAuditProcessRequest request);
|
||||
}
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
|
||||
public interface IDNADataAuditService
|
||||
{
|
||||
Task HandleAccountAuditCheck(DnaFieldChangeRequest dnaFieldChange);
|
||||
Task HandleAgreementAuditCheck(DnaFieldChangeRequest dnaFieldChange);
|
||||
Task HandleOrganizationAuditCheck(DnaFieldChangeRequest dnaFieldChange);
|
||||
}
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.DnaAuditServices;
|
||||
using NCrontab;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.HostedServices
|
||||
{
|
||||
public class HostedDnaDataAuditProcessService : BackgroundService
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
private CancellationToken _cancellationToken;
|
||||
private ApiConfiguration _memberPreferencesConfig;
|
||||
private readonly CrontabSchedule _cleanUpJobSchedule;
|
||||
private DateTime _nextScheduleRun;
|
||||
|
||||
public HostedDnaDataAuditProcessService(ApiConfiguration appConfig,
|
||||
IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
_memberPreferencesConfig = appConfig;
|
||||
_cleanUpJobSchedule = CrontabSchedule.Parse(_memberPreferencesConfig.DnaDataAuditProcessCronSchedule);
|
||||
_nextScheduleRun = _cleanUpJobSchedule.GetNextOccurrence(DateTime.Now);
|
||||
_cancellationToken = new CancellationToken();
|
||||
}
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
Log.Information("Hosted DNADataAuditProcessService is starting, for DNA Member Preferences Audit.");
|
||||
_cancellationToken = cancellationToken;
|
||||
try
|
||||
{
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
if (DateTime.Now > _nextScheduleRun)
|
||||
{
|
||||
using (var scope = _scopeFactory.CreateScope())
|
||||
{
|
||||
await scope.ServiceProvider.GetRequiredService<IDNADataAuditProcessService>().RunDataAuditProcesses();
|
||||
}
|
||||
}
|
||||
await Task.Delay(UntilNextExecution(), cancellationToken);
|
||||
}
|
||||
}
|
||||
catch (TaskCanceledException ex) when (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
Log.Information(ex, "Hosted DnaDataAuditProcessService was shut down normally.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Error in main thread for DnaDataAuditProcessService");
|
||||
}
|
||||
|
||||
Log.Information("Hosted DnaDataAuditProcessService is stopping.");
|
||||
}
|
||||
|
||||
private int UntilNextExecution() => Math.Max(0, (int)_nextScheduleRun.Subtract(DateTime.Now).TotalMilliseconds);
|
||||
}
|
||||
}
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.XdiServices;
|
||||
using NCrontab;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.HostedServices;
|
||||
|
||||
public class HostedXdiBatchProcessService : BackgroundService
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
private CancellationToken _cancellationToken;
|
||||
private ApiConfiguration _apiConfiguration;
|
||||
private XdiSftpApiConfiguration _xdiSftpApiConfiguration;
|
||||
private readonly CrontabSchedule _cleanUpJobSchedule;
|
||||
private DateTime _nextScheduleRun;
|
||||
|
||||
public HostedXdiBatchProcessService(ApiConfiguration apiConfiguration, XdiSftpApiConfiguration xdiSftpApiConfiguration, IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
_apiConfiguration = apiConfiguration;
|
||||
_xdiSftpApiConfiguration = xdiSftpApiConfiguration;
|
||||
_cleanUpJobSchedule = CrontabSchedule.Parse(_apiConfiguration.XdiBatchProcessCronSchedule);
|
||||
_nextScheduleRun = _cleanUpJobSchedule.GetNextOccurrence(DateTime.Now);
|
||||
_cancellationToken = new CancellationToken();
|
||||
}
|
||||
|
||||
protected override async Task ExecuteAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
Log.Information("Hosted XDI Batch Service is starting");
|
||||
_cancellationToken = cancellationToken;
|
||||
try
|
||||
{
|
||||
while (!cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
if (DateTime.Now > _nextScheduleRun)
|
||||
{
|
||||
using (var scope = _scopeFactory.CreateScope())
|
||||
{
|
||||
await scope.ServiceProvider.GetRequiredService<IXdiBatchProcessService>().RunXdiBatchProcess(_xdiSftpApiConfiguration.SftpRootBasePath);
|
||||
}
|
||||
_nextScheduleRun = _cleanUpJobSchedule.GetNextOccurrence(DateTime.Now);
|
||||
}
|
||||
await Task.Delay(UntilNextExecution(), cancellationToken);
|
||||
}
|
||||
}
|
||||
catch (TaskCanceledException ex) when (cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
Log.Information(ex, "Hosted XdiBatchService was shut down normally");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, "Error in main thread for XdiBatchService");
|
||||
}
|
||||
|
||||
Log.Information("Hosted XdiBatchService is stopping");
|
||||
}
|
||||
|
||||
private int UntilNextExecution() => Math.Max(0, (int)_nextScheduleRun.Subtract(DateTime.Now).TotalMilliseconds);
|
||||
}
|
||||
-14
@@ -127,20 +127,6 @@ namespace LCU.API.Internal.MemberPreferencesApi.MicroApiServices
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<long>> GetAuditOrganizationFromDateLastMaintained(DateTime dateTime)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _coreApiWrapperDao.GetAuditOrganizationFromDateLastMaintained(dateTime);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = $"Failed to GetAuditOrganizationFromDateLastMaintained. DateTime: {dateTime} Exception Message: {ex.Message}";
|
||||
Log.Error(error);
|
||||
throw new ServiceException(error);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdateAgreementAccountsDeliveryMethod(IEnumerable<long> accountIds, string deliveryMethod, string userId)
|
||||
{
|
||||
try
|
||||
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.DataAccess;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.MicroApiServices
|
||||
{
|
||||
public class FileOperationsApiService : IFileOperationsApiService
|
||||
{
|
||||
private readonly IFileOperationsApiDao _fileOperationsApiDao;
|
||||
|
||||
public FileOperationsApiService(IFileOperationsApiDao fileOperationsApiDao)
|
||||
{
|
||||
_fileOperationsApiDao = fileOperationsApiDao;
|
||||
}
|
||||
|
||||
public async Task<RequestResponse> AppendFile(AppendFileRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _fileOperationsApiDao.AppendFileAsync(request);
|
||||
|
||||
Log.Information($"XDI File Sent, Response: {result.ReturnResponse}");
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = $"Failed to create XDI Direct File. Exception Message: {ex.Message}";
|
||||
Log.Error(error);
|
||||
throw new ServiceException(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
using LCU.Api.Internal.FTPLib.Models;
|
||||
using LCU.API.Internal.MemberPreferencesApi.DataAccess;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.MicroApiServices
|
||||
{
|
||||
public class FtpApiService : IFtpApiService
|
||||
{
|
||||
private readonly IFtpApiDao _ftpApiDao;
|
||||
|
||||
public FtpApiService(IFtpApiDao ftpApiDao)
|
||||
{
|
||||
_ftpApiDao = ftpApiDao;
|
||||
}
|
||||
|
||||
public async Task SendXdiFtpRequest(SshFtpRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _ftpApiDao.SendFtpAsync(request);
|
||||
Log.Information($"XDI Ftp Sent: {request.RemoteFilePath}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = $"Failed to send FTP file. Exception Message: {ex.Message}";
|
||||
Log.Error(error);
|
||||
throw new ServiceException(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-1
@@ -12,6 +12,5 @@ public interface ICoreApiWrapperService
|
||||
public Task<IEnumerable<AgreementAccount>> GetAgreementAccountsByOrganizationId(long organizationId);
|
||||
public Task<IEnumerable<long>> GetAuditAccountsFromDateLastMaintained(DateTime dateTime);
|
||||
public Task<IEnumerable<long>> GetAuditAgreementFromDateLastMaintained(DateTime dateTime);
|
||||
public Task<IEnumerable<long>> GetAuditOrganizationFromDateLastMaintained(DateTime dateTime);
|
||||
public Task UpdateAgreementAccountsDeliveryMethod(IEnumerable<long> accountIds, string deliveryMethod, string userId);
|
||||
}
|
||||
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
using LCU.Library.Internal.FileOperationsModels.Models;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
|
||||
public interface IFileOperationsApiService
|
||||
{
|
||||
public Task<RequestResponse> AppendFile(AppendFileRequest request);
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
using LCU.Api.Internal.FTPLib.Models;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
|
||||
public interface IFtpApiService
|
||||
{
|
||||
public Task SendXdiFtpRequest(SshFtpRequest request);
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.MicroApiServices
|
||||
{
|
||||
public interface IScanBiCoreApiWrapperService
|
||||
{
|
||||
public Task<IEnumerable<long>> GetAuditOrganizationFromDateLastMaintained(DateTime dateTime);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -66,7 +66,7 @@ public class NotificationService : INotificationService
|
||||
var filteredRecipients = recipients.Distinct(StringComparer.InvariantCultureIgnoreCase).ToList();
|
||||
var subject = "Paper Statement Enrollment";
|
||||
var message =
|
||||
$"<div style=\"padding: 2em;\"><p style=\"color: #0054a4;\"><strong>You have enrolled to receive paper for your statements and notices.</strong></p><p>You have selected to receive paper statements and notices. You will no longer be able to view these documents online or on your mobile device.</p><p>With electronic statements through Landmark Credit Union Digital Banking, you’ll be able to:</p><ul><li>View your statements and tax documents online or on your mobile device</li><li>Maintain your own secure online archive</li><li>Help the environment by reducing paper and clutter</li></ul><p>Please note, some accounts may have promotional rates or offers that require paperless statements and electing to receive paper may impact offers on your account. Please refer to your account Truth in Savings disclosure for more information. If you need to make changes to any of your preferences, you can visit Manage Delivery Preferences under Statements & Notices.</p><div style=\"color: #959ba6;\"><center><p style=\"margin:0px;\">You are receiving this email because you requested to receive paper statements and notices. If you did not make this selection or believe this is in error, please contact us.</p><p style=\"margin:0px;\"><a href=\"http://www.landmarkcu.com/\">Landmark Credit Union</a> | <a href=\"https://landmarkcu.com/contact-us/\">Contact Us</a></p><p style=\"margin:0px;\">Landmark Credit Union</p><p style=\"margin:0px;\">© 2021 All rights reserved</p></center></div></div>";
|
||||
$"<div style=\"padding: 2em;\"><p style=\"color: #0054a4;\"><strong>You have enrolled to receive paper for your statements and notices.</strong></p><p>You have selected to receive paper statements and notices. You will no longer be able to view these documents online or on your mobile device.</p><p>With electronic documents through Landmark Credit Union Digital Banking, you’ll be able to:</p><ul><li>View your statements and tax documents online or on your mobile device</li><li>Maintain your own secure online archive</li><li>Help the environment by reducing paper and clutter</li></ul><p>Please note that this change in delivery method could impact fees, offers, and earnings tied to some account requirements. Please refer to your recent offers, account Truth in Savings disclosure, and current fee schedule for more information. If you need to make changes to any of your preferences, you can visit Manage Delivery Preferences under Statements & Notices.</p><div style=\"color: #959ba6;\"><center><p style=\"margin:0px;\">You are receiving this email because you requested to receive paper statements and notices. If you did not make this selection or believe this is in error, please contact us.</p><p style=\"margin:0px;\"><a href=\"http://www.landmarkcu.com/\">Landmark Credit Union</a> | <a href=\"https://landmarkcu.com/contact-us/\">Contact Us</a></p><p style=\"margin:0px;\">Landmark Credit Union</p><p style=\"margin:0px;\">© 2021 All rights reserved</p></center></div></div>";
|
||||
await SendMessageAsync(filteredRecipients, subject, message);
|
||||
}
|
||||
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.DataAccess;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
|
||||
public class ScanBiCoreApiWrapperService : IScanBiCoreApiWrapperService
|
||||
{
|
||||
private readonly IScanBiCoreApiWrapperDao _scanBiCoreApiWrapperDao;
|
||||
|
||||
public ScanBiCoreApiWrapperService(IScanBiCoreApiWrapperDao scanBiCoreApiWrapperDao)
|
||||
{
|
||||
_scanBiCoreApiWrapperDao = scanBiCoreApiWrapperDao;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<long>> GetAuditOrganizationFromDateLastMaintained(DateTime dateTime)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _scanBiCoreApiWrapperDao.GetAuditOrganizationFromDateLastMaintained(dateTime);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = $"Failed to GetAuditOrganizationFromDateLastMaintained. DateTime: {dateTime} Exception Message: {ex.Message}";
|
||||
Log.Error(error);
|
||||
throw new ServiceException(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
|
||||
public interface IQueueDnaAccountAuditService
|
||||
{
|
||||
Task QueueDataAuditForAccounts(List<long> accountNumbers, int consecutiveFailures = 0);
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
|
||||
public interface IQueueDnaAgreementAuditService
|
||||
{
|
||||
Task QueueDataAuditForAgreements(List<long> agreementAuditRecords, int consecutiveFailures = 0);
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
|
||||
public interface IQueueDnaAuditProcessService
|
||||
{
|
||||
Task QueueDnaAuditProcessRequest(DnaAuditProcessRequest request);
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
|
||||
public interface IQueueDnaOrganizationAuditService
|
||||
{
|
||||
Task QueueDataAuditForOrganizations(List<long> organizationNumbers, int consecutiveFailures = 0);
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
|
||||
public interface IQueueXdiBatchProcessService
|
||||
{
|
||||
Task QueueXdiBatchProcess(XdiBatchProcessRequest request);
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
|
||||
public interface IQueueXdiBatchService
|
||||
{
|
||||
Task QueueXdiBatchProcess(XdiBatchRequest request);
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
using LCU.Library.Internal.LcuMassTransitModels;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.QueueServices
|
||||
{
|
||||
public class QueueDnaAccountAuditService : IQueueDnaAccountAuditService
|
||||
{
|
||||
private readonly ISendEndpoint _sendEndpoint;
|
||||
private readonly ReceiveEndpointConfiguration _dnaAccountAuditReceiveEndpoint;
|
||||
|
||||
public QueueDnaAccountAuditService(IBusControl busControl, ReceiveEndpointConfigurations receiveEndpointConfigurations)
|
||||
{
|
||||
_dnaAccountAuditReceiveEndpoint = receiveEndpointConfigurations.DnaAccountAuditEndpoint;
|
||||
_sendEndpoint = busControl.GetSendEndpoint(_dnaAccountAuditReceiveEndpoint.ReceiveEndpointUri).Result;
|
||||
}
|
||||
|
||||
public async Task QueueDataAuditForAccounts(List<long> accountAuditRecords, int consecutiveFailures = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var account in accountAuditRecords)
|
||||
{
|
||||
var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
|
||||
var request = new DnaFieldChangeRequest()
|
||||
{
|
||||
DnaFieldIdInformation = account,
|
||||
ConsecutiveFailures = consecutiveFailures,
|
||||
DnaProcessType = DnaAuditProcessType.DNAAccounts,
|
||||
LastUpdated = DateTime.UtcNow,
|
||||
ProcessId = 2
|
||||
};
|
||||
await _sendEndpoint.Send(request, cancellationTokenSource.Token);
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group), Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(ex, "Failed to Queue MemberPreference DNA Account Audit records.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
using LCU.Library.Internal.LcuMassTransitModels;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
|
||||
public class QueueDnaAgreementAuditService : IQueueDnaAgreementAuditService
|
||||
{
|
||||
private readonly ISendEndpoint _sendEndpoint;
|
||||
private readonly ReceiveEndpointConfiguration _dnaAuditAgreementReceiveEndpoint;
|
||||
|
||||
public QueueDnaAgreementAuditService(IBusControl busControl, ReceiveEndpointConfigurations receiveEndpointConfigurations)
|
||||
{
|
||||
_dnaAuditAgreementReceiveEndpoint = receiveEndpointConfigurations.DnaAgreementAuditEndpoint;
|
||||
_sendEndpoint = busControl.GetSendEndpoint(_dnaAuditAgreementReceiveEndpoint.ReceiveEndpointUri).Result;
|
||||
}
|
||||
|
||||
public async Task QueueDataAuditForAgreements(List<long> agreementAuditRecords, int consecutiveFailures = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var agreement in agreementAuditRecords)
|
||||
{
|
||||
var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
|
||||
var request = new DnaFieldChangeRequest()
|
||||
{
|
||||
DnaFieldIdInformation = agreement,
|
||||
ConsecutiveFailures = consecutiveFailures,
|
||||
DnaProcessType = DnaAuditProcessType.DNAAgreement,
|
||||
LastUpdated = DateTime.UtcNow,
|
||||
ProcessId = 1
|
||||
};
|
||||
await _sendEndpoint.Send(request, cancellationTokenSource.Token);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group), Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(ex, "Failed to Queue MemberPreference DNA Account Audit records.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
|
||||
using LCU.Library.Internal.LcuMassTransitModels;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
|
||||
public class QueueDnaAuditProcessService : IQueueDnaAuditProcessService
|
||||
{
|
||||
private readonly ISendEndpoint _sendEndpoint;
|
||||
|
||||
public QueueDnaAuditProcessService(IBusControl busControl, ReceiveEndpointConfigurations receiveEndpointConfigurations)
|
||||
{
|
||||
_sendEndpoint = busControl.GetSendEndpoint(receiveEndpointConfigurations.DnaAuditProcessEndpoint.ReceiveEndpointUri).Result;
|
||||
}
|
||||
|
||||
public async Task QueueDnaAuditProcessRequest(DnaAuditProcessRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
|
||||
await _sendEndpoint.Send(request, cancellationTokenSource.Token);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(ex, "Failed to Queue DnaAuditProcess Request.");
|
||||
throw new ServiceException("Failed to Queue DnaAuditProcess Request.");
|
||||
}
|
||||
}
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
using LCU.Library.Internal.LcuMassTransitModels;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
|
||||
public class QueueDnaOrganizationService : IQueueDnaOrganizationAuditService
|
||||
{
|
||||
private readonly ISendEndpoint _sendEndpoint;
|
||||
private readonly ReceiveEndpointConfiguration _dnaAuditOrganizationReceiveEndpoint;
|
||||
|
||||
public QueueDnaOrganizationService(IBusControl busControl, ReceiveEndpointConfigurations receiveEndpointConfigurations)
|
||||
{
|
||||
_dnaAuditOrganizationReceiveEndpoint = receiveEndpointConfigurations.DnaOrganizationAuditEndpoint;
|
||||
_sendEndpoint = busControl.GetSendEndpoint(_dnaAuditOrganizationReceiveEndpoint.ReceiveEndpointUri).Result;
|
||||
}
|
||||
|
||||
public async Task QueueDataAuditForOrganizations(List<long> organizationAuditRecords, int consecutiveFailures = 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var organization in organizationAuditRecords)
|
||||
{
|
||||
var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
|
||||
var request = new DnaFieldChangeRequest()
|
||||
{
|
||||
DnaFieldIdInformation = organization,
|
||||
ConsecutiveFailures = consecutiveFailures,
|
||||
DnaProcessType = DnaAuditProcessType.DNAOrganization,
|
||||
LastUpdated = DateTime.UtcNow,
|
||||
ProcessId = 3
|
||||
|
||||
};
|
||||
await _sendEndpoint.Send(request, cancellationTokenSource.Token);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group), Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(ex, "Failed to Queue MemberPreference DNA Account Audit records.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -3,18 +3,17 @@ using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.QueueServices
|
||||
{
|
||||
public class QueueXdiBatchService : IQueueXdiBatchService
|
||||
public class QueueXdiBatchProcessService : IQueueXdiBatchProcessService
|
||||
{
|
||||
private readonly ISendEndpoint _sendEndpoint;
|
||||
private readonly ReceiveEndpointConfiguration _xdiServiceEndpoint;
|
||||
|
||||
public QueueXdiBatchService(IBusControl busControl, ReceiveEndpointConfigurations receiveEndpointConfigurations)
|
||||
public QueueXdiBatchProcessService(IBusControl busControl, ReceiveEndpointConfigurations receiveEndpointConfigurations)
|
||||
{
|
||||
_xdiServiceEndpoint = receiveEndpointConfigurations.XdiBatchProcessEndpoint;
|
||||
_sendEndpoint = busControl.GetSendEndpoint(_xdiServiceEndpoint.ReceiveEndpointUri).Result;
|
||||
}
|
||||
|
||||
public async Task QueueXdiBatchProcess(XdiBatchRequest request)
|
||||
public async Task QueueXdiBatchProcess(XdiBatchProcessRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
+1
-1
@@ -2,5 +2,5 @@ namespace LCU.API.Internal.MemberPreferencesApi.Services.XdiServices;
|
||||
|
||||
public interface IXdiBatchProcessService
|
||||
{
|
||||
Task RunXdiBatchProcess(string sftpRootBasePath);
|
||||
Task HandleXdiBatchProcess(XdiBatchProcessRequest xdiBatchProcessRequest);
|
||||
}
|
||||
|
||||
+3
-5
@@ -1,17 +1,15 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.Models;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using ApiResponse = LCU.Library.Internal.ApiResponse.Models;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.XdiServices;
|
||||
|
||||
public interface IXdiBatchService
|
||||
{
|
||||
Task AddXdiBatchItem(XdiBatchItem newItem);
|
||||
Task SaveRangeAsync(List<XdiBatchItem> xdiBatchItemList);
|
||||
Task CreateXdiBatchFiles(XdiBatchRequest request);
|
||||
Task<XdiBatchRequest> BuildXdiBatchRequest(XdiBatchRequest request);
|
||||
Task HandleFtpProcess(XdiBatchRequest request);
|
||||
Task<bool> RequestFtpTransport(IReadOnlyCollection<XdiBatchFile> files);
|
||||
Task<bool> MarkPendingSuccessful(ApiResponse.Response response);
|
||||
Task<List<FtpQueuePayloadItem>> CreateFtpPayload(XdiBatchFile xdiBatchFile);
|
||||
Task<List<XdiBatchFileExport>> BuildXdiFiles(XdiBatchFile batchFile, string filePath, XdiBatchProcessInfo xdiBatchProcessInfo);
|
||||
Task<bool> MarkPendingSuccessful(List<XdiBatchFileExport> batchFileExportList);
|
||||
Task<bool> DoesMemberHavePendingXdiChange(string memberId);
|
||||
}
|
||||
|
||||
+12
-10
@@ -1,6 +1,6 @@
|
||||
using LCU.API.Internal.MemberPreferencesApi.Models;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Services.QueueServices;
|
||||
using LCU.API.Internal.MemberPreferencesApiLib.Repositories;
|
||||
using LCU.Library.Internal.ApiResponse.Services;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.XdiServices;
|
||||
@@ -8,15 +8,15 @@ namespace LCU.API.Internal.MemberPreferencesApi.Services.XdiServices;
|
||||
public class XdiBatchProcessService : IXdiBatchProcessService
|
||||
{
|
||||
private readonly IXdiBatchItemsRepository _xdiBatchItemsRepository;
|
||||
private readonly IQueueXdiBatchService _queueXdiBatchService;
|
||||
private readonly IXdiBatchService _xdiBatchService;
|
||||
|
||||
public XdiBatchProcessService(IQueueXdiBatchService queueXdiBatchService, IXdiBatchItemsRepository xdiBatchItemsRepository)
|
||||
public XdiBatchProcessService(IXdiBatchService xdiBatchService, IXdiBatchItemsRepository xdiBatchItemsRepository)
|
||||
{
|
||||
_xdiBatchItemsRepository = xdiBatchItemsRepository;
|
||||
_queueXdiBatchService = queueXdiBatchService;
|
||||
_xdiBatchService = xdiBatchService;
|
||||
}
|
||||
|
||||
public async Task RunXdiBatchProcess(string sftpRootBasePath)
|
||||
public async Task HandleXdiBatchProcess(XdiBatchProcessRequest xdiBatchProcessRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -33,17 +33,19 @@ public class XdiBatchProcessService : IXdiBatchProcessService
|
||||
{
|
||||
XdiBatch = xdiBatch,
|
||||
XdiBatchItems = xdiBatchItems.ToList(),
|
||||
SftpRootBasePath = sftpRootBasePath
|
||||
XdiAppendFileRootBasePath = xdiBatchProcessRequest.XdiAppendFileRootBasePath
|
||||
};
|
||||
|
||||
await _queueXdiBatchService.QueueXdiBatchProcess(request);
|
||||
await _xdiBatchService.CreateXdiBatchFiles(request);
|
||||
await QueueReturnResponse.QueueResponse(xdiBatchProcessRequest, true, new List<string> { $"Requested {xdiBatchItems.Count()} Xdi Batch Items to Process."});
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var error = $"Failed to Run XdiBatchProcess. Exception Message: {ex.Message}";
|
||||
Log.Error(error);
|
||||
throw new ServiceException(error);
|
||||
var errorMessage = $"Failed to HandleXdiBatchProcess. Exception Message: {ex.Message}";
|
||||
Log.Error(errorMessage);
|
||||
await QueueReturnResponse.QueueResponse(xdiBatchProcessRequest, false, new List<string>() {errorMessage});
|
||||
throw new ServiceException(errorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+121
-94
@@ -1,58 +1,58 @@
|
||||
using ApiResponse = LCU.Library.Internal.ApiResponse.Models;
|
||||
using LCU.API.Internal.MemberPreferencesApi.MicroApiServices;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Models;
|
||||
using LCU.API.Internal.MemberPreferencesApiLib.Repositories;
|
||||
using LCU.Api.Internal.FTPLib.Models;
|
||||
using LCU.Library.Internal.ApiResponse.Models;
|
||||
using LCU.Library.Internal.LcuMassTransitModels;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models;
|
||||
using LCU.Library.Internal.LcuClassPatterns.Crud.Services;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
using LCU.API.Internal.MemberPreferencesApi.Models;
|
||||
using Newtonsoft.Json;
|
||||
using System.Data.SqlClient;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApi.Services.XdiServices
|
||||
{
|
||||
public class XdiBatchService : IXdiBatchService
|
||||
public class XdiBatchService : CrudService<XdiBatchProcessInfo>, IXdiBatchService
|
||||
{
|
||||
private readonly IXdiBatchProcessInfoRepository _xdiBatchProcessInfoRepository;
|
||||
private readonly IXdiBatchItemsRepository _xdiBatchItemsRepository;
|
||||
private readonly IUnifiedOptInRepository _unifiedOptInRepository;
|
||||
private readonly IMemberPreferenceRepository _memberPreferenceRepository;
|
||||
private readonly ConnectionConfiguration _connectionConfiguration;
|
||||
private readonly ReceiveEndpointConfiguration _completionReceiveEndpoint;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
private readonly XdiSftpApiConfiguration _xdiSftpApiConfiguration;
|
||||
private readonly IFtpApiService _ftpApiService;
|
||||
private readonly IFileOperationsApiService _fileOperationsApiService;
|
||||
private const string XdiBatchProcessOperatorName = "XdiBatchProcess";
|
||||
|
||||
public XdiBatchService(IXdiBatchItemsRepository xdiBatchItemsRepository, IUnitOfWork unitOfWork,
|
||||
XdiSftpApiConfiguration xdiSftpApiConfiguration, IUnifiedOptInRepository unifiedOptInRepository,
|
||||
IMemberPreferenceRepository memberPreferenceRepository, ConnectionConfiguration connectionConfiguration,
|
||||
ReceiveEndpointConfigurations receiveEndpointsConfigurations, IFtpApiService ftpApiService)
|
||||
public XdiBatchService(IXdiBatchItemsRepository xdiBatchItemsRepository,
|
||||
IUnitOfWork unitOfWork, IUnifiedOptInRepository unifiedOptInRepository,
|
||||
IMemberPreferenceRepository memberPreferencesRepository, IFileOperationsApiService fileOperationsApiService,
|
||||
IXdiBatchProcessInfoRepository xdiBatchProcessInfoRepository) : base(xdiBatchProcessInfoRepository)
|
||||
{
|
||||
_xdiBatchItemsRepository = xdiBatchItemsRepository;
|
||||
_unitOfWork = unitOfWork;
|
||||
_xdiSftpApiConfiguration = xdiSftpApiConfiguration;
|
||||
_memberPreferenceRepository = memberPreferencesRepository;
|
||||
_unifiedOptInRepository = unifiedOptInRepository;
|
||||
_memberPreferenceRepository = memberPreferenceRepository;
|
||||
_connectionConfiguration = connectionConfiguration;
|
||||
_ftpApiService = ftpApiService;
|
||||
_completionReceiveEndpoint = receiveEndpointsConfigurations.XdiBatchConfirmEndpoint;
|
||||
_fileOperationsApiService = fileOperationsApiService;
|
||||
_xdiBatchProcessInfoRepository = xdiBatchProcessInfoRepository;
|
||||
}
|
||||
|
||||
public async Task CreateXdiBatchFiles(XdiBatchRequest request)
|
||||
{
|
||||
var batchProcessInfo = new XdiBatchProcessInfo();
|
||||
var batchUserIds = string.Join(",", request.XdiBatchItems.Select(c => c.UserId).ToList());
|
||||
try
|
||||
{
|
||||
if (!request.XdiBatchItems.Any())
|
||||
var batchProcessInProgress = _xdiBatchProcessInfoRepository.FindBatchProcessInfoByStatus(XdiBatchProcessStatus.InProgress).Result;
|
||||
if (batchProcessInProgress.Count() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
request = await BuildXdiBatchRequest(request);
|
||||
await HandleFtpProcess(request);
|
||||
batchProcessInfo = await CreateNewBatchProcessInfo(request.XdiBatchItems.Count());
|
||||
await CreateXdiExportFileRequest(request, batchProcessInfo);
|
||||
|
||||
await UpdateBatchAsync(batchProcessInfo, XdiBatchProcessStatus.Completed, $"Completed XDI Batch Process for UserIds: {batchUserIds}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failed to Create XDI Batch Files.");
|
||||
await UpdateBatchAsync(batchProcessInfo, XdiBatchProcessStatus.Failed, $"Failed XDI Batch Process for UserIds: {batchUserIds}");
|
||||
throw new ServiceException($"Failed to Create XDI Batch Files. Exception Message: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,11 +74,11 @@ namespace LCU.API.Internal.MemberPreferencesApi.Services.XdiServices
|
||||
BatchState = BatchState.TransferPending,
|
||||
LastUpdated = DateTime.UtcNow
|
||||
});
|
||||
Log.Information($"Hosted XDI Sync processed batch item with UserId: {item.UserId}");
|
||||
Log.Information($"XdiBatchService processed batch item with UserId: {item.UserId}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Error($"Row not processed in XDI Audit for member with UserId: {item.UserId}, marking complete.");
|
||||
Log.Error($"No XdiBatchRow or XDI File was processed based on current member UserId: {item.UserId} Opt In Settings, marking complete.");
|
||||
_xdiBatchItemsRepository.Delete(item);
|
||||
}
|
||||
};
|
||||
@@ -89,71 +89,49 @@ namespace LCU.API.Internal.MemberPreferencesApi.Services.XdiServices
|
||||
return request;
|
||||
}
|
||||
|
||||
public async Task HandleFtpProcess(XdiBatchRequest request)
|
||||
public async Task CreateXdiExportFileRequest(XdiBatchRequest request, XdiBatchProcessInfo xdiBatchProcessInfo)
|
||||
{
|
||||
try
|
||||
{
|
||||
IReadOnlyCollection<XdiBatchFile> batchFiles = request.XdiBatch.GetNonEmptyFiles(request.SftpRootBasePath);
|
||||
Log.Information($"Hosted XDI Sync produced {batchFiles.Count} files");
|
||||
IReadOnlyCollection<XdiBatchFile> batchFiles = request.XdiBatch.GetNonEmptyFiles();
|
||||
Log.Information($"XdiBatchService produced {batchFiles.Count} files");
|
||||
|
||||
bool results = await RequestFtpTransport(batchFiles);
|
||||
string resultDescription = results ? "Success" : "Failure";
|
||||
Log.Information($"Hosted XDI Sync Ftp Results...{resultDescription}");
|
||||
foreach (var xdiBatchFile in batchFiles)
|
||||
{
|
||||
var xdiBatchFileExport = await BuildXdiFiles(xdiBatchFile, request.XdiAppendFileRootBasePath, xdiBatchProcessInfo);
|
||||
await MarkPendingSuccessful(xdiBatchFileExport);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failed to Handle FTP Process.");
|
||||
Log.Error(ex, $"Failed to Create the XDI File to export.");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> RequestFtpTransport(IReadOnlyCollection<XdiBatchFile> files)
|
||||
public async Task<List<XdiBatchFileExport>> BuildXdiFiles(XdiBatchFile batchFile, string filePath, XdiBatchProcessInfo xdiBatchProcessInfo)
|
||||
{
|
||||
SshFtpRequest request = BuildFtpRequest();
|
||||
AppendFileRequest request = BuildFileOperationsRequest(batchFile, filePath);
|
||||
var xdiBatchFileExport = await CreateDirectoryXdiFiles(batchFile);
|
||||
var result = await _fileOperationsApiService.AppendFile(request);
|
||||
|
||||
foreach (var xdiBatchFile in files)
|
||||
{
|
||||
request.LocalFileData = xdiBatchFile.ConvertToDataFile();
|
||||
request.RemoteFilePath = xdiBatchFile.GetFileName();
|
||||
|
||||
var payload = await CreateFtpPayload(xdiBatchFile);
|
||||
request.ResponseItems.First().ResponsePayload = JsonConvert.SerializeObject(payload).ToString();
|
||||
await _ftpApiService.SendXdiFtpRequest(request);
|
||||
}
|
||||
return true;
|
||||
return xdiBatchFileExport;
|
||||
}
|
||||
|
||||
private SshFtpRequest BuildFtpRequest()
|
||||
private AppendFileRequest BuildFileOperationsRequest(XdiBatchFile xdiBatchFile, string filePath)
|
||||
{
|
||||
var request = new SshFtpRequest()
|
||||
var request = new AppendFileRequest()
|
||||
{
|
||||
ResponseItems = new List<ResponseItem>()
|
||||
{
|
||||
new ResponseItem()
|
||||
{
|
||||
ResponsePayload = "",
|
||||
ReturnQueueConnectionConfig = new QueueConnectionConfig()
|
||||
{
|
||||
Url = _connectionConfiguration.HostUrl,
|
||||
Username = _connectionConfiguration.UserName,
|
||||
Password = _connectionConfiguration.Password
|
||||
},
|
||||
ReturnQueueConsumerConfig = new QueueConsumerConfig()
|
||||
{
|
||||
ExchangeName = _completionReceiveEndpoint.ReceiveEndpoint
|
||||
}
|
||||
}
|
||||
},
|
||||
HostName = _xdiSftpApiConfiguration.HostName,
|
||||
Password = _xdiSftpApiConfiguration.Password,
|
||||
PortNumber = _xdiSftpApiConfiguration.PortNumber,
|
||||
UserName = _xdiSftpApiConfiguration.UserName
|
||||
DestinationPath = filePath,
|
||||
Extension = ".txt",
|
||||
FileData = xdiBatchFile.ConvertToDataFile(),
|
||||
FileName = xdiBatchFile.GetFileName()
|
||||
};
|
||||
return request;
|
||||
}
|
||||
|
||||
public async Task<List<FtpQueuePayloadItem>> CreateFtpPayload(XdiBatchFile xdiBatchFile)
|
||||
public async Task<List<XdiBatchFileExport>> CreateDirectoryXdiFiles(XdiBatchFile xdiBatchFile)
|
||||
{
|
||||
List<FtpQueuePayloadItem> payload = new List<FtpQueuePayloadItem>();
|
||||
List<XdiBatchFileExport> batchFileExportList = new List<XdiBatchFileExport>();
|
||||
var userIds = xdiBatchFile.Data.Select(x => x.UserId).ToList();
|
||||
|
||||
foreach (var userId in userIds)
|
||||
@@ -161,7 +139,7 @@ namespace LCU.API.Internal.MemberPreferencesApi.Services.XdiServices
|
||||
var settings = await _unifiedOptInRepository.GetMemberOptInSettingsNoTracking(userId);
|
||||
if (settings != null)
|
||||
{
|
||||
payload.Add(new FtpQueuePayloadItem
|
||||
batchFileExportList.Add(new XdiBatchFileExport
|
||||
{
|
||||
UserId = userId,
|
||||
Value = settings.UniversalOptIn == DeliveryPreference.Electronic
|
||||
@@ -170,10 +148,12 @@ namespace LCU.API.Internal.MemberPreferencesApi.Services.XdiServices
|
||||
});
|
||||
}
|
||||
}
|
||||
return payload;
|
||||
return batchFileExportList;
|
||||
}
|
||||
|
||||
public async Task AddXdiBatchItem(XdiBatchItem newItem)
|
||||
{
|
||||
try
|
||||
{
|
||||
var existing = await _xdiBatchItemsRepository.FindExistingItem(newItem.UserId, BatchState.New);
|
||||
if (existing != null)
|
||||
@@ -185,41 +165,48 @@ namespace LCU.API.Internal.MemberPreferencesApi.Services.XdiServices
|
||||
{
|
||||
await _xdiBatchItemsRepository.SaveAsync(newItem);
|
||||
}
|
||||
|
||||
await _unitOfWork.CompleteAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"AddXdiBatchItem userId {newItem.UserId} error: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task SaveRangeAsync(List<XdiBatchItem> xdiBatchItemList)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _xdiBatchItemsRepository.SaveRangeAsync(xdiBatchItemList);
|
||||
await _unitOfWork.CompleteAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error($"SaveRangeAsync method error: " + ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> DoesMemberHavePendingXdiChange(string userId)
|
||||
{
|
||||
return await _xdiBatchItemsRepository.FindExistingItem(userId, BatchState.TransferPending) != null;
|
||||
}
|
||||
|
||||
public async Task<bool> MarkPendingSuccessful(ApiResponse.Response response)
|
||||
public async Task<bool> MarkPendingSuccessful(List<XdiBatchFileExport> batchFileExportList)
|
||||
{
|
||||
try
|
||||
{
|
||||
var payloadString = response.ResponsePayload;
|
||||
var payload = JsonConvert.DeserializeObject<List<FtpQueuePayloadItem>>(payloadString);
|
||||
if (!response.Successful)
|
||||
{
|
||||
var errorMessage = string.Join("; ", response.ResponseStack.ToArray());
|
||||
throw new ServiceException($"XdiBatchItemService Failure occured. Payload response was unsuccessful. Error Message: {errorMessage}");
|
||||
}
|
||||
Log.Information($"Marking {batchFileExportList.Count} Batch Items Successful.");
|
||||
var memberIds = batchFileExportList.Select(x => x.UserId);
|
||||
var pendingComplete = await _xdiBatchItemsRepository.MarkPendingSuccessful(memberIds.ToList());
|
||||
|
||||
Log.Information($"Marking {payload.Count} Payloads Successful.");
|
||||
var memberIds = payload.Select(x => x.UserId);
|
||||
var result = await _xdiBatchItemsRepository.MarkPendingSuccessful(memberIds.ToList());
|
||||
if (result)
|
||||
if (pendingComplete)
|
||||
{
|
||||
await UpdateMemberPreferenceEntries(payload);
|
||||
await UpdateMemberPreferenceEntries(batchFileExportList);
|
||||
}
|
||||
|
||||
await _unitOfWork.CompleteAsync(XdiBatchProcessOperatorName, DateTime.UtcNow, UserType.System);
|
||||
return result;
|
||||
}
|
||||
catch (ServiceException serviceEx)
|
||||
{
|
||||
Log.Error($"{serviceEx}");
|
||||
throw serviceEx;
|
||||
return pendingComplete;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -228,9 +215,9 @@ namespace LCU.API.Internal.MemberPreferencesApi.Services.XdiServices
|
||||
}
|
||||
}
|
||||
|
||||
private async Task UpdateMemberPreferenceEntries(List<FtpQueuePayloadItem> payload)
|
||||
private async Task UpdateMemberPreferenceEntries(List<XdiBatchFileExport> batchFileExport)
|
||||
{
|
||||
foreach (var item in payload)
|
||||
foreach (var item in batchFileExport)
|
||||
{
|
||||
var settings = await _unifiedOptInRepository.GetOrCreateMemberOptinSettings(item.UserId);
|
||||
|
||||
@@ -269,5 +256,45 @@ namespace LCU.API.Internal.MemberPreferencesApi.Services.XdiServices
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<XdiBatchProcessInfo> CreateNewBatchProcessInfo(int batchTotal)
|
||||
{
|
||||
var xdiBatchProcessInfo = new XdiBatchProcessInfo();
|
||||
xdiBatchProcessInfo.StartTimeStamp = DateTime.Now;
|
||||
xdiBatchProcessInfo.XdiBatchProcessStatus = XdiBatchProcessStatus.InProgress;
|
||||
xdiBatchProcessInfo.BatchTotal = batchTotal;
|
||||
return await _xdiBatchProcessInfoRepository.AddAsync(xdiBatchProcessInfo);
|
||||
}
|
||||
|
||||
public async Task<XdiBatchProcessInfo> UpdateBatchAsync(XdiBatchProcessInfo xdiBatchProcessInfo, XdiBatchProcessStatus xdiBatchStatus, string apiResponse)
|
||||
{
|
||||
try
|
||||
{
|
||||
var existing = await _xdiBatchProcessInfoRepository.FindByIdAsync(xdiBatchProcessInfo.XdiBatchProcessInfoId);
|
||||
if (existing == null)
|
||||
{
|
||||
throw new ServiceException($"XdiBatchProcessInfo with XdiBatchProcessInfoId {xdiBatchProcessInfo.XdiBatchProcessInfoId} not found");
|
||||
}
|
||||
existing.XdiBatchProcessStatus = xdiBatchStatus;
|
||||
existing.ApiResponse = apiResponse;
|
||||
existing.EndTimeStamp = DateTime.Now;
|
||||
|
||||
await _xdiBatchProcessInfoRepository.UpdateAsync(existing);
|
||||
await _unitOfWork.CompleteAsync();
|
||||
return existing;
|
||||
}
|
||||
catch (SqlException sqlEx)
|
||||
{
|
||||
var message = $"Failure updating XdiBatchProcessInfo with XdiBatchProcessInfoId {xdiBatchProcessInfo.XdiBatchProcessInfoId}";
|
||||
Log.Error(sqlEx, message);
|
||||
throw new ServiceException(message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var message = $"Failure updating XdiBatchProcessInfo with XdiBatchProcessInfoId {xdiBatchProcessInfo.XdiBatchProcessInfoId}";
|
||||
Log.Error(ex, message);
|
||||
throw new ServiceException(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+33
-41
@@ -3,15 +3,9 @@
|
||||
"AppName": "Member Preferences Api",
|
||||
"SeqUrl": "http://localhost:5080",
|
||||
"SeqKey": "9MQu0vLDwQ1LCFzGixZM",
|
||||
"XdiBatchProcessCronSchedule": "1 5-18 * * *",
|
||||
"DnaDataAuditProcessCronSchedule": "*/5 3-19 * * *",
|
||||
"FeatureFlags": {
|
||||
"RunHostedServices": true,
|
||||
"RunXdiBatchProcessConsumer": true,
|
||||
"RunXdiSshResponseConsumer": true,
|
||||
"RunAccountDnaFieldChangeConsumer": true,
|
||||
"RunAgreementDnaFieldChangeConsumer": true,
|
||||
"RunOrganizationDnaFieldChangeConsumer": true
|
||||
"RunDnaAuditProcessConsumer": true
|
||||
},
|
||||
"FeatureGates": {
|
||||
"EnableControllers": true,
|
||||
@@ -43,20 +37,12 @@
|
||||
"TestEmailList": [ "[email protected]" ],
|
||||
"ShouldSendRealEmails": false
|
||||
},
|
||||
"FtpApiConfiguration": {
|
||||
"Url": "https://localhost:56641/",
|
||||
"QueueSshFtpRequestEndpoint": "SshFtp/QueueSshFtpRequest"
|
||||
},
|
||||
"XdiSftpApiConfiguration": {
|
||||
"SftpRootBasePath": "/home/devops/",
|
||||
"HostName": "10.147.44.23",
|
||||
"UserName": "devops",
|
||||
"PortNumber": 22,
|
||||
"Password": "vault-value",
|
||||
"Fingerprint": "ssh-ed25519 255 Yj16sxy1rlbKuNxGnYTNqnDUkPjiV8qFiEAjb6h9Xdk="
|
||||
"FileOperationsApiConfiguration": {
|
||||
"Url": "https://localhost:63532/api/",
|
||||
"AppendFile": "DirectFileOperations/AppendFile"
|
||||
},
|
||||
"CoreApiWrapperConfiguration": {
|
||||
"CoreApiBaseUrl": "https://localhost:44355/api/core/",
|
||||
"CoreApiBaseUrl": "https://qa-core-api-wrapper-api.apps.azure.lcu-internal.com/api/core/",
|
||||
"CoreApiGetAgreementByUserId": "Agree/AgreementByUserId/{userId}",
|
||||
"CoreApiGetAgreementByAgreementId": "Agree/AgreementByAgreementId/{agreementId}",
|
||||
"CoreApiGetAgreementsByAccountId": "Agree/AgreementsByAccountId/{accountId}",
|
||||
@@ -65,31 +51,20 @@
|
||||
"CoreApiGetAgreementAccountsByOrganizationId": "Agree/AgreementAccountsByOrganizationId/{organizationId}",
|
||||
"CoreApiGetAuditAccountsFromDateLastMaintained": "Agree/AgreementAccountsAuditFromDateLastMaintained",
|
||||
"CoreApiGetAuditAgreementFromDateLastMaintained": "Agree/AgreementAuditFromDateLastMaintained",
|
||||
"CoreApiGetAuditOrganizationFromDateLastMaintained": "Agree/OrganizationAuditFromDateLastMaintained",
|
||||
"CoreApiUpdateAccountsMaintenanceRequest": "Account/AccountMaintenanceRequest"
|
||||
},
|
||||
"ScanBiCoreApiWrapperConfiguration": {
|
||||
"ScanBiCoreApiWrapperUrl": "https://qa-scanbi-core-api-wrapper-api.apps.azure.lcu-internal.com/api/core/",
|
||||
"GetAuditOrganizationFromDateLastMaintainedEndpoint": "Agree/OrganizationAuditFromDateLastMaintained"
|
||||
},
|
||||
"XdiBatchProcessEndpoint": {
|
||||
"ReceiveEndpoint": "LCU.MemberPreferencesApi.XdiBatchProcess",
|
||||
"ReceiveEndpointType": "exchange",
|
||||
"PrefetchLimit": 1
|
||||
},
|
||||
"XdiBatchConfirmEndpoint": {
|
||||
"ReceiveEndpoint": "LCU.MemberPreferencesApi.XdiBatchConfirm",
|
||||
"ReceiveEndpointType": "exchange",
|
||||
"PrefetchLimit": 1
|
||||
},
|
||||
"DnaAccountAuditEndpoint": {
|
||||
"ReceiveEndpoint": "LCU.MemberPreferencesApi.DnaAccountAudit",
|
||||
"ReceiveEndpointType": "exchange",
|
||||
"PrefetchLimit": 1
|
||||
},
|
||||
"DnaOrganizationAuditEndpoint": {
|
||||
"ReceiveEndpoint": "LCU.MemberPreferencesApi.DnaOrganizationAudit",
|
||||
"ReceiveEndpointType": "exchange",
|
||||
"PrefetchLimit": 1
|
||||
},
|
||||
"DnaAgreementAuditEndpoint": {
|
||||
"ReceiveEndpoint": "LCU.MemberPreferencesApi.DnaAgreementAudit",
|
||||
|
||||
"DnaAuditProcessEndpoint": {
|
||||
"ReceiveEndpoint": "LCU.MemberPreferencesApi.DnaAuditProcess",
|
||||
"ReceiveEndpointType": "exchange",
|
||||
"PrefetchLimit": 1
|
||||
},
|
||||
@@ -98,15 +73,32 @@
|
||||
"UserName": "guest",
|
||||
"Password": "guest"
|
||||
},
|
||||
"DnaAuditProcessConfiguration": {
|
||||
"LookBackMinutes": -5,
|
||||
"NumberOfAllowedConsecutiveFailures": 12
|
||||
},
|
||||
"ApiSecurityConfiguration": {
|
||||
"ApiKeyAuthenticationFailureBehavior": "Error",
|
||||
"ExternalApiKeySet": {},
|
||||
"InternalApiKeySet": {
|
||||
"MembershipPreferences": "85c3f03b-f412-4f8d-bc1e-438a7a69cbbe"
|
||||
}
|
||||
},
|
||||
"ServicesFactoryConfiguration": {
|
||||
"ServiceFactoryRegistrations": [
|
||||
{
|
||||
"ServiceInterfaceName": "IDNAAuditCheckService",
|
||||
"ServiceRegistrations": [
|
||||
{
|
||||
"ServiceName": "DNADataAgreementAuditCheckService",
|
||||
"ServiceId": "0"
|
||||
},
|
||||
{
|
||||
"ServiceName": "DNADataAccountAuditCheckService",
|
||||
"ServiceId": "1"
|
||||
},
|
||||
{
|
||||
"ServiceName": "DNADataOrganizationAuditService",
|
||||
"ServiceId": "2"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -6,6 +6,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LCU.Library.Internal.LcuClassPatterns.Crud" Version="1.0.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
|
||||
+4
@@ -18,6 +18,7 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext
|
||||
public DbSet<MemberOptInSettings> MemberOptInSettings { get; set; }
|
||||
public DbSet<DnaAuditProcess> DnaAuditProcesses { get; set; }
|
||||
public DbSet<XdiBatchItem> XdiBatchItems { get; set; }
|
||||
public DbSet<XdiBatchProcessInfo> XdiBatchProcessInfos { get; set; }
|
||||
|
||||
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken())
|
||||
{
|
||||
@@ -103,5 +104,8 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext
|
||||
|
||||
builder.Entity<DnaAuditProcess>().ToTable("DnaAuditProcess");
|
||||
builder.Entity<DnaAuditProcess>().HasKey(p => p.ProcessId);
|
||||
|
||||
builder.Entity<XdiBatchProcessInfo>().ToTable("XdiBatchProcessInfo");
|
||||
builder.Entity<XdiBatchProcessInfo>().HasKey(p => p.XdiBatchProcessInfoId);
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -11,6 +11,7 @@ public interface IApplicationDbContext : IAuditableChanges
|
||||
DbSet<MemberOptInSettings> MemberOptInSettings { get; set; }
|
||||
public DbSet<XdiBatchItem> XdiBatchItems { get; set; }
|
||||
public DbSet<DnaAuditProcess> DnaAuditProcesses { get; set; }
|
||||
public DbSet<XdiBatchProcessInfo> XdiBatchProcessInfos { get; set; }
|
||||
Task<int> SaveChangesAsync(CancellationToken cancellationToken = new CancellationToken());
|
||||
Task<int> SaveChangesWithOperatorAsync(string operatorId, DateTime dateAdded, UserType userType, CancellationToken cancellationToken);
|
||||
}
|
||||
|
||||
+6
@@ -1,5 +1,6 @@
|
||||
using LCU.API.Internal.MemberPreferencesApiLib.Persistence;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApiLib.Repositories;
|
||||
@@ -15,6 +16,11 @@ public class DnaAuditProcessRepository : BaseRepository, IDnaAuditProcessReposit
|
||||
return await _context.DnaAuditProcesses.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<DnaAuditProcess> GetDnaAuditProcessByDnaProcessType(DnaAuditProcessType type)
|
||||
{
|
||||
return await _context.DnaAuditProcesses.Where(d => d.DnaProcessType == type).FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task Update(DnaAuditProcess existing)
|
||||
{
|
||||
_context.DnaAuditProcesses.Update(existing);
|
||||
|
||||
+2
@@ -1,9 +1,11 @@
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApiLib.Repositories;
|
||||
|
||||
public interface IDnaAuditProcessRepository
|
||||
{
|
||||
Task<IReadOnlyCollection<DnaAuditProcess>> GetAllDnaAuditProcesses();
|
||||
Task<DnaAuditProcess> GetDnaAuditProcessByDnaProcessType(DnaAuditProcessType type);
|
||||
Task Update(DnaAuditProcess existing);
|
||||
}
|
||||
|
||||
+1
@@ -8,6 +8,7 @@ public interface IXdiBatchItemsRepository
|
||||
Task<IReadOnlyCollection<XdiBatchItem>> GetXdiBatchItems();
|
||||
Task<IReadOnlyCollection<XdiBatchItem>> GetNewXdiBatchItems();
|
||||
Task<XdiBatchItem> SaveAsync(XdiBatchItem batchItem);
|
||||
Task<List<XdiBatchItem>> SaveRangeAsync(List<XdiBatchItem> batchItemList);
|
||||
Task<XdiBatchItem> FindExistingItem(string memberId, BatchState batchState);
|
||||
void Update(XdiBatchItem existing);
|
||||
void Delete(XdiBatchItem item);
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
using LCU.Library.Internal.LcuClassPatterns.Crud.Repositories;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApiLib.Repositories;
|
||||
|
||||
public interface IXdiBatchProcessInfoRepository: ICrudRepository<XdiBatchProcessInfo>
|
||||
{
|
||||
Task<IEnumerable<XdiBatchProcessInfo>> FindBatchProcessInfoByStatus(XdiBatchProcessStatus xdiProcessStatus);
|
||||
}
|
||||
+6
@@ -27,6 +27,12 @@ public class XdiBatchItemsRepository : BaseRepository, IXdiBatchItemsRepository
|
||||
return batchItem;
|
||||
}
|
||||
|
||||
public async Task<List<XdiBatchItem>> SaveRangeAsync(List<XdiBatchItem> batchItemList)
|
||||
{
|
||||
await _context.XdiBatchItems.AddRangeAsync(batchItemList);
|
||||
return batchItemList;
|
||||
}
|
||||
|
||||
public async Task<XdiBatchItem> FindExistingItem(string userId, BatchState batchState)
|
||||
{
|
||||
return await _context.XdiBatchItems.Where(p => p.UserId == userId && p.BatchState == batchState)
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
using LCU.API.Internal.MemberPreferencesApiLib.Persistence;
|
||||
using LCU.Library.Internal.LcuClassPatterns.Crud.Repositories;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace LCU.API.Internal.MemberPreferencesApiLib.Repositories;
|
||||
|
||||
public class XdiBatchProcessInfoRepository : CrudRepository<XdiBatchProcessInfo>, IXdiBatchProcessInfoRepository
|
||||
{
|
||||
private readonly IApplicationDbContext _context;
|
||||
public XdiBatchProcessInfoRepository(ApplicationDbContext context) : base(context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<XdiBatchProcessInfo>> FindBatchProcessInfoByStatus(XdiBatchProcessStatus xdiProcessStatus)
|
||||
{
|
||||
return await _context.XdiBatchProcessInfos.Where(p => p.XdiBatchProcessStatus == xdiProcessStatus).ToListAsync();
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Operations Version="1.0" xmlns="http://schemas.microsoft.com/sqlserver/dac/Serialization/2012/02">
|
||||
<Operation Name="Rename Refactor" Key="5c3556a6-05fd-442f-a0af-06c6e69d6a9d" ChangeDateTime="03/24/2026 00:12:28">
|
||||
<Property Name="ElementName" Value="[dbo].[XdiBatchProcessInfo].[Id]" />
|
||||
<Property Name="ElementType" Value="SqlSimpleColumn" />
|
||||
<Property Name="ParentElementName" Value="[dbo].[XdiBatchProcessInfo]" />
|
||||
<Property Name="ParentElementType" Value="SqlTable" />
|
||||
<Property Name="NewName" Value="XdiBatchProcessInfoId" />
|
||||
</Operation>
|
||||
</Operations>
|
||||
+4
@@ -63,5 +63,9 @@
|
||||
<Build Include="MemberOptInSettings.sql" />
|
||||
<Build Include="MemberPreference.sql" />
|
||||
<Build Include="XdiBatchItems.sql" />
|
||||
<Build Include="XdiBatchProcessInfo.sql" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<RefactorLog Include="LCU.API.Internal.MemberPreferencesApiSql.refactorlog" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
+1
@@ -4,4 +4,5 @@ CREATE TABLE [dbo].[XdiBatchItems]
|
||||
[BatchState] [int] NOT NULL,
|
||||
[Created] [datetime2](7) NOT NULL,
|
||||
[LastUpdated] [datetime2](7) NOT NULL,
|
||||
CONSTRAINT [UQ_XdiBatchItems_UserId] UNIQUE (UserId)
|
||||
)
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE [dbo].[XdiBatchProcessInfo]
|
||||
(
|
||||
[XdiBatchProcessInfoId] [int] NOT NULL PRIMARY KEY IDENTITY,
|
||||
[StartTimeStamp] DATETIME2 NOT NULL,
|
||||
[EndTimeStamp] DATETIME2 NULL,
|
||||
[BatchTotal] INT NOT NULL DEFAULT 0,
|
||||
[ApiResponse] NVARCHAR(MAX) NULL,
|
||||
[XdiBatchProcessStatus] INT NOT NULL
|
||||
)
|
||||
+4
-3
@@ -1,9 +1,9 @@
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.DataTransfer;
|
||||
|
||||
public class MemberOptInInformation
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.DataTransfer
|
||||
{
|
||||
public class MemberOptInInformation
|
||||
{
|
||||
public MemberOptInInformation(MemberOptInSettings settings, bool hasPendingUpdates)
|
||||
{
|
||||
MemberOptinSettings = settings;
|
||||
@@ -12,4 +12,5 @@ public class MemberOptInInformation
|
||||
|
||||
public MemberOptInSettings MemberOptinSettings { get; set; }
|
||||
public bool HasPendingUpdates { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -1,9 +1,10 @@
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
|
||||
public class ApplicationUser
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities
|
||||
{
|
||||
public class ApplicationUser
|
||||
{
|
||||
public string UserName { get; set; }
|
||||
public UserType UserType { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -1,7 +1,7 @@
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
|
||||
public static class DeliveryPreference
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities
|
||||
{
|
||||
public static class DeliveryPreference
|
||||
{
|
||||
public const string Paper = "Paper";
|
||||
public const string Electronic = "Electronic";
|
||||
public const string Hold = "Hold";
|
||||
@@ -23,4 +23,5 @@ public static class DeliveryPreference
|
||||
return DeliveryPreference.Paper;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -2,13 +2,14 @@ using System;
|
||||
using System.Text.Json.Serialization;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
|
||||
public class DnaAuditProcess
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities
|
||||
{
|
||||
public class DnaAuditProcess
|
||||
{
|
||||
public int ProcessId { get; set; }
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public DnaAuditProcessType DnaProcessType { get; set; }
|
||||
public DateTime LastUpdated { get; set; }
|
||||
public int ConsecutiveFailures { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -1,8 +1,9 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
|
||||
public interface IMemberPreferences
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities
|
||||
{
|
||||
public interface IMemberPreferences
|
||||
{
|
||||
Task Add(MemberPreference preferenceChange);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -2,10 +2,10 @@ using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Models;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
|
||||
public class MemberPreference : Auditable
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities
|
||||
{
|
||||
public class MemberPreference : Auditable
|
||||
{
|
||||
public MemberPreference()
|
||||
{
|
||||
}
|
||||
@@ -16,4 +16,5 @@ public class MemberPreference : Auditable
|
||||
public PreferenceType Preference { get; set; }
|
||||
public string Value { get; set; }
|
||||
public string LegalReference { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -2,13 +2,14 @@ using System;
|
||||
using System.Text.Json.Serialization;
|
||||
using LCU.Library.Internal.MemberPreferencesApiModels.Enums;
|
||||
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities;
|
||||
|
||||
public class XdiBatchItem
|
||||
namespace LCU.Library.Internal.MemberPreferencesApiModels.Entities
|
||||
{
|
||||
public class XdiBatchItem
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
[JsonConverter(typeof(JsonStringEnumConverter))]
|
||||
public BatchState BatchState { get; set; }
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime LastUpdated { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user