Updating
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
**/*.bat
|
||||
**/*.log
|
||||
**/*.md
|
||||
**/*.yml
|
||||
**/.dockerignore
|
||||
**/.editorconfig
|
||||
**/.git
|
||||
**/.gitattributes
|
||||
**/.gitignore
|
||||
**/.vs
|
||||
**/.vscode
|
||||
**/bin
|
||||
**/dist
|
||||
**/dockerfile
|
||||
**/node_modules
|
||||
**/obj
|
||||
**/package-lock.json
|
||||
@@ -0,0 +1,362 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
@@ -0,0 +1,41 @@
|
||||
# .NET Core SDK
|
||||
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS aspnetcore-build
|
||||
|
||||
# Copy Projects
|
||||
COPY LCU.Api.Internal.ArchiverApi/LCU.Api.Internal.ArchiverApi.csproj ./source/LCU.Api.Internal.ArchiverApi/
|
||||
COPY LCU.Library.Internal.ArchiverApiLib/LCU.Library.Internal.ArchiverApiLib.csproj ./source/LCU.Library.Internal.ArchiverApiLib/
|
||||
COPY LCU.Library.Internal.ArchiverApiModel/LCU.Library.Internal.ArchiverApiModel.csproj ./source/LCU.Library.Internal.ArchiverApiModel/
|
||||
|
||||
# Install Credential Provider and set env variables to enable Nuget restore with auth
|
||||
ARG PAT=bh2lq3jibktw67b2wdbqyfln7cd3je6lk52kijntpj43v6kimpgq
|
||||
RUN curl -L https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh | sh
|
||||
#RUN wget -qO- https://raw.githubusercontent.com/Microsoft/artifacts-credprovider/master/helpers/installcredprovider.sh | bash
|
||||
ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED true
|
||||
ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS "{\"endpointCredentials\": [{\"endpoint\":\"https://landmarkcu.pkgs.visualstudio.com/_packaging/LCU-Internal/nuget/v3/index.json\", \"password\":\"${PAT}\"}]}"
|
||||
|
||||
# .NET Core Restore, use auth'd feed
|
||||
RUN dotnet restore -s "https://landmarkcu.pkgs.visualstudio.com/_packaging/LCU-Internal/nuget/v3/index.json" -s "https://api.nuget.org/v3/index.json" ./source/LCU.Api.Internal.ArchiverApi/LCU.Api.Internal.ArchiverApi.csproj
|
||||
|
||||
# Copy All Files
|
||||
COPY . ./source/
|
||||
|
||||
FROM aspnetcore-build AS test
|
||||
LABEL test=true
|
||||
COPY LCU.Api.Internal.ArchiverApiTest/LCU.Api.Internal.ArchiverApiTest.csproj ./source/LCU.Api.Internal.ArchiverApiTest/
|
||||
RUN dotnet restore ./source/LCU.Api.Internal.ArchiverApiTest/LCU.Api.Internal.ArchiverApiTest.csproj
|
||||
RUN dotnet test -c Release --results-directory /testresults --logger "trx;LogFileName=test_results.trx" ./source/LCU.Api.Internal.ArchiverApiTest/LCU.Api.Internal.ArchiverApiTest.csproj
|
||||
|
||||
# .NET Core Publish
|
||||
FROM aspnetcore-build as publish
|
||||
RUN dotnet publish ./source/LCU.Api.Internal.ArchiverApi/LCU.Api.Internal.ArchiverApi.csproj -c Release -o /dist
|
||||
|
||||
# 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
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=publish /dist .
|
||||
ENTRYPOINT ["dotnet", "LCU.Api.Internal.ArchiverApi.dll"]
|
||||
@@ -0,0 +1,51 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31903.59
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LCU.Api.Internal.ArchiverApi", "LCU.Api.Internal.ArchiverApi\LCU.Api.Internal.ArchiverApi.csproj", "{249893A9-F03C-4857-82E8-D91A81FED23B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LCU.Library.Internal.ArchiverApiModel", "LCU.Library.Internal.ArchiverApiModel\LCU.Library.Internal.ArchiverApiModel.csproj", "{9C5489B7-356A-4E28-AF4F-AEE195967576}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LCU.Api.Internal.ArchiverApiTest", "LCU.Api.Internal.ArchiverApiTest\LCU.Api.Internal.ArchiverApiTest.csproj", "{E2608CCB-9042-4BE6-B2B9-DDA76E617FE7}"
|
||||
EndProject
|
||||
Project("{00D1A9C2-B5F0-4AF3-8072-F6C62B433612}") = "LCU.Api.Internal.ArchiverApiSql", "LCU.Api.Internal.ArchiverApiSql\LCU.Api.Internal.ArchiverApiSql.sqlproj", "{DEEFABEC-E066-4A9B-93AD-A32482D8F03A}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LCU.Library.Internal.ArchiverApiLib", "LCU.Library.Internal.ArchiverApiLib\LCU.Library.Internal.ArchiverApiLib.csproj", "{4BE28089-38A6-406B-AA18-057D43E129E1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{249893A9-F03C-4857-82E8-D91A81FED23B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{249893A9-F03C-4857-82E8-D91A81FED23B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{249893A9-F03C-4857-82E8-D91A81FED23B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{249893A9-F03C-4857-82E8-D91A81FED23B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9C5489B7-356A-4E28-AF4F-AEE195967576}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9C5489B7-356A-4E28-AF4F-AEE195967576}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9C5489B7-356A-4E28-AF4F-AEE195967576}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9C5489B7-356A-4E28-AF4F-AEE195967576}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E2608CCB-9042-4BE6-B2B9-DDA76E617FE7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E2608CCB-9042-4BE6-B2B9-DDA76E617FE7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E2608CCB-9042-4BE6-B2B9-DDA76E617FE7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E2608CCB-9042-4BE6-B2B9-DDA76E617FE7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DEEFABEC-E066-4A9B-93AD-A32482D8F03A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DEEFABEC-E066-4A9B-93AD-A32482D8F03A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DEEFABEC-E066-4A9B-93AD-A32482D8F03A}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
|
||||
{DEEFABEC-E066-4A9B-93AD-A32482D8F03A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DEEFABEC-E066-4A9B-93AD-A32482D8F03A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DEEFABEC-E066-4A9B-93AD-A32482D8F03A}.Release|Any CPU.Deploy.0 = Release|Any CPU
|
||||
{4BE28089-38A6-406B-AA18-057D43E129E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4BE28089-38A6-406B-AA18-057D43E129E1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4BE28089-38A6-406B-AA18-057D43E129E1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4BE28089-38A6-406B-AA18-057D43E129E1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {E3722568-CF81-4BDA-BBBF-BC18C69B4A45}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Configuration;
|
||||
|
||||
public class ArchiverApiConfig
|
||||
{
|
||||
public string SeqUrl { get; set; }
|
||||
public string SeqApiKey { get; set; }
|
||||
public string ApplicationName { get; set; }
|
||||
public string NotificationApiEmail { get; set; }
|
||||
public string FileOperationApiBulkMoveFile { get; set; }
|
||||
public string FileOperationApiBuildDynamicFileList { get; set; }
|
||||
public string FileOperationApiValidateFileExists { get; set; }
|
||||
public string CoreApiWrapperGetApplicationHistory { get; set; }
|
||||
public string DnaBasePath { get; set; }
|
||||
public string ReportPathDateFormat { get; set; }
|
||||
public string ErrorMonitoringTemplate { get; set; }
|
||||
public string ErrorRowTemplate { get; set; }
|
||||
public string ErrorMonitoringSubject { get; set; }
|
||||
public List<string> ErrorRecipients { get; set; }
|
||||
public string TimeZone { get; set; }
|
||||
public FeatureFlags FeatureFlags { get; set; }
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
using LCU.Library.Internal.LcuMassTransitModels;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Configuration;
|
||||
|
||||
public class ReceiveEndpointConfigurations
|
||||
{
|
||||
public ReceiveEndpointConfiguration ArchiverReceiveEndpoint { get; set; }
|
||||
public ReceiveEndpointConfiguration ResponseReceiveEndpoint { get; set; }
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
namespace LCU.Api.Internal.ArchiverApi.Configuration;
|
||||
|
||||
public class FeatureFlags
|
||||
{
|
||||
public bool RunArchiverConsumer { get; set; }
|
||||
public bool RunResponseConsumer { get; set; }
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Serilog;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using MassTransit;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
using LCU.Api.Internal.ArchiverApi.Services;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Consumers;
|
||||
|
||||
public class ArchiverConsumer : IConsumer<ArchiveRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public ArchiverConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<ArchiveRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(() => scope.ServiceProvider.GetRequiredService<IArchiverService>().ExecuteRequest(context.Message));
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Fatal(exception, $"Unexpected Failure");
|
||||
}
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Serilog;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using MassTransit;
|
||||
using LCU.Api.Internal.ArchiverApi.Services;
|
||||
using ApiResponse = LCU.Library.Internal.ApiResponse.Models;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Consumers;
|
||||
|
||||
public class ResponseConsumer : IConsumer<ApiResponse.Response>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public ResponseConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<ApiResponse.Response> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(() => scope.ServiceProvider.GetRequiredService<IArchiveCompletionService>().HandleReportArchiveCompletedRequest(context.Message));
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Fatal(exception, $"Unexpected Failure");
|
||||
}
|
||||
}
|
||||
}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using Serilog;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using LCU.Api.Internal.ArchiverApi.Services;
|
||||
using LCU.Api.Internal.ArchiverApi.Extensions;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class ApplicationMappingController : ControllerBase
|
||||
{
|
||||
private readonly IApplicationMappingService _applicationMappingService;
|
||||
|
||||
public ApplicationMappingController(IApplicationMappingService applicationMappingService)
|
||||
{
|
||||
_applicationMappingService = applicationMappingService;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetAllJobs")]
|
||||
[ProducesResponseType(typeof(IEnumerable<ApplicationMapping>), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Get()
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _applicationMappingService.GetAsync();
|
||||
return Ok(result);
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("{id:int}", Name = "GetById")]
|
||||
[ProducesResponseType(201)]
|
||||
[ProducesResponseType(typeof(ApplicationMapping), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetById(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _applicationMappingService.GetByIdAsync(id);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ProducesResponseType(201)]
|
||||
[ProducesResponseType(typeof(ApplicationMapping), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Post([FromBody] ApplicationMapping applicationMapping)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.GetErrorMessages());
|
||||
}
|
||||
|
||||
var result = await _applicationMappingService.SaveAsync(applicationMapping);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut("Update", Name = "Update")]
|
||||
[ProducesResponseType(typeof(ApplicationMapping), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public IActionResult Update([FromBody] ApplicationMapping applicationMapping)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _applicationMappingService.Update(applicationMapping);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete()]
|
||||
[ProducesResponseType(typeof(ApplicationMapping), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public IActionResult Delete(int jobId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (jobId <= 0)
|
||||
{
|
||||
return BadRequest("Invalid Id");
|
||||
}
|
||||
|
||||
_applicationMappingService.DeleteAsync(jobId);
|
||||
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 System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Serilog;
|
||||
using LCU.Api.Internal.ArchiverApi.Services;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class QueueArchiverController : ControllerBase
|
||||
{
|
||||
private readonly IQueueArchiverService _queueArchiverService;
|
||||
|
||||
public QueueArchiverController(IQueueArchiverService queueArchiverService)
|
||||
{
|
||||
_queueArchiverService = queueArchiverService;
|
||||
}
|
||||
|
||||
[HttpPost("QueueArchiver")]
|
||||
public IActionResult QueueArchiver(ArchiveRequest archiveRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState.Values);
|
||||
}
|
||||
|
||||
_queueArchiverService.QueueArchiver(archiveRequest);
|
||||
return Ok();
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using Serilog;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using LCU.Api.Internal.ArchiverApi.Services;
|
||||
using LCU.Api.Internal.ArchiverApi.Extensions;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class RegexMappingController : ControllerBase
|
||||
{
|
||||
IRegexMappingService _regexMappingService;
|
||||
public RegexMappingController(IRegexMappingService regexMappingService)
|
||||
{
|
||||
_regexMappingService = regexMappingService;
|
||||
}
|
||||
|
||||
[HttpGet(Name = "GetAllRegex")]
|
||||
[ProducesResponseType(typeof(IEnumerable<RegexMapping>), 200)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Get()
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _regexMappingService.GetAsync();
|
||||
return Ok(result);
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("GetByRegexId/{regexMappingId:int}", Name = "GetByRegexId")]
|
||||
[ProducesResponseType(201)]
|
||||
[ProducesResponseType(204)]
|
||||
[ProducesResponseType(typeof(RegexMapping), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetByRegexMappingId(int regexMappingId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (regexMappingId <= 0)
|
||||
{
|
||||
return BadRequest("Invalid Id");
|
||||
}
|
||||
var result = await _regexMappingService.GetByRegexMappingIdAsync(regexMappingId);
|
||||
if (result == null)
|
||||
{
|
||||
return NoContent();
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("GetByApplicationMappingId/{applicationMappingid:int}", Name = "GetByApplicationMappingId")]
|
||||
[ProducesResponseType(201)]
|
||||
[ProducesResponseType(204)]
|
||||
[ProducesResponseType(typeof(RegexMapping), 400)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> GetByApplicationMappingId(int applicationMappingId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (applicationMappingId <= 0)
|
||||
{
|
||||
return BadRequest("Invalid Id");
|
||||
}
|
||||
var result = await _regexMappingService.GetByApplicationMappingIdAsync(applicationMappingId);
|
||||
if (result == null)
|
||||
{
|
||||
return NoContent();
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ProducesResponseType(201)]
|
||||
[ProducesResponseType(typeof(RegexMapping), 400)]
|
||||
[ProducesResponseType(406)]
|
||||
[ProducesResponseType(500)]
|
||||
public async Task<IActionResult> Post([FromBody] RegexMapping regexMapping)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _regexMappingService.SaveAsync(regexMapping);
|
||||
if (result == null)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status406NotAcceptable);
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut("UpdateRegex", Name = "UpdateRegex")]
|
||||
[ProducesResponseType(typeof(RegexMapping), 200)]
|
||||
[ProducesResponseType(406)]
|
||||
[ProducesResponseType(500)]
|
||||
public IActionResult Update([FromBody] RegexMapping regexMapping)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _regexMappingService.Update(regexMapping);
|
||||
if (result == null)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status406NotAcceptable);
|
||||
}
|
||||
return Ok(result);
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete()]
|
||||
[ProducesResponseType(typeof(RegexMapping), 200)]
|
||||
[ProducesResponseType(400)]
|
||||
[ProducesResponseType(500)]
|
||||
public IActionResult Delete(int regexId)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (regexId <= 0)
|
||||
{
|
||||
return BadRequest("Invalid Id");
|
||||
}
|
||||
|
||||
_regexMappingService.DeleteAsync(regexId);
|
||||
return Ok();
|
||||
}
|
||||
catch (ServiceException)
|
||||
{
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Unexpected Exception");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Serilog;
|
||||
using LCU.Api.Internal.ArchiverApi.Models;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class StatusController : ControllerBase
|
||||
{
|
||||
private readonly IEnvironmentView _environmentView;
|
||||
|
||||
public StatusController(IEnvironmentView environmentView)
|
||||
{
|
||||
_environmentView = environmentView;
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
[ProducesResponseType(200)]
|
||||
[ProducesResponseType(500)]
|
||||
public IActionResult Get()
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Verbose($"{_environmentView.Application}'s status endpoint was hit in {_environmentView.Environment}");
|
||||
return Ok(_environmentView);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error("Failure return status, message: {0} {1}", e.Message, e.StackTrace);
|
||||
return StatusCode((int)System.Net.HttpStatusCode.InternalServerError);
|
||||
}
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
using System;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Exceptions;
|
||||
|
||||
public class FailedToParseException : Exception
|
||||
{
|
||||
public FailedToParseException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Exceptions;
|
||||
|
||||
/**
|
||||
* If an entity cannot be found, that specific error can allow for a 404 or 400 with more detail to be
|
||||
* returned. So specify that to the API layer.
|
||||
*/
|
||||
public class NotFoundException : ApplicationException
|
||||
{
|
||||
public NotFoundException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Exceptions;
|
||||
|
||||
/**
|
||||
* Do not want to expose database and related exceptions to the controllers / web layer.
|
||||
* The lower layers log what happened for developers, then return a general error; unless
|
||||
* a more specific error can be returned in a way to allow the client to act (such as NotFound).
|
||||
*/
|
||||
public class ServerErrorException : Exception
|
||||
{
|
||||
public ServerErrorException() : base("A server error occured, and a response could not be produced.") { }
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace LCU.Api.Internal.ArchiverApi.Extensions
|
||||
{
|
||||
public static class ModelStateMessages
|
||||
{
|
||||
public static List<string> GetErrorMessages(this ModelStateDictionary dictionary)
|
||||
{
|
||||
return dictionary.SelectMany(m => m.Value.Errors)
|
||||
.Select(m => m.ErrorMessage)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Description>
|
||||
1.0.0 - Initial Versioning
|
||||
1.1.0 - Notice, Statments, and Reports
|
||||
1.1.1 - Fix regex to only look for extensions at end. Fix path for error templates.\
|
||||
1.2.0 - Added ReturnResponse to ArchiveRequest and updated nugets.
|
||||
1.3.0 - Change QueueArchiveRequest to use DaysFromDate.
|
||||
1.4.0 - Update to use MassTransit and ApiResponse upgrade.
|
||||
1.5.0 - Upgraded FileOperations package version
|
||||
</Description>
|
||||
<Version>1.4.0</Version>
|
||||
<PackageReleaseNotes>
|
||||
1.0.0 - Initial Versioning
|
||||
1.1.0 - Notice, Statments, and Reports
|
||||
1.1.1 - Fix regex to only look for extensions at end. Fix path for error templates.
|
||||
1.2.0 - Added ReturnResponse to ArchiveRequest and updated nugets.
|
||||
1.3.0 - Change QueueArchiveRequest to use DaysFromDate.
|
||||
1.4.0 - Update to use MassTransit and ApiResponse upgrade.
|
||||
1.5.0 - Upgraded FileOperations package version
|
||||
</PackageReleaseNotes>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LCU.Api.Internal.MaidBotLib" Version="1.0.0" />
|
||||
<PackageReference Include="LCU.API.Internal.NotificationsApiLib" Version="2.1.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.ApiResponse" Version="3.3.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.ApiResponse.Models" Version="3.3.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.CoreApiWrapperModel" Version="2.2.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.Exceptions" Version="1.0.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.FileOperationsModels" Version="4.1.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="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="5.0.1">
|
||||
<NoWarn>NU1605</NoWarn>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.9" />
|
||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Async" Version="1.5.0" />
|
||||
<PackageReference Include="Serilog.Sinks.Seq" Version="5.0.1" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
|
||||
<PackageReference Include="TimeZoneConverter" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LCU.Library.Internal.ArchiverApiLib\LCU.Library.Internal.ArchiverApiLib.csproj" />
|
||||
<ProjectReference Include="..\LCU.Library.Internal.ArchiverApiModel\LCU.Library.Internal.ArchiverApiModel.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Templates\ErrorMonitoringTemplate.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Templates\ErrorRowTemplate.html">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Models;
|
||||
|
||||
public class EnvironmentView : IEnvironmentView
|
||||
{
|
||||
public string Application => _env.ApplicationName;
|
||||
public DateTime CurrentDate => DateTime.Now;
|
||||
public string BuildVersion => Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
public DateTime BuildDate => AssemblyBuildDate();
|
||||
public string Environment => _env.EnvironmentName;
|
||||
private readonly IWebHostEnvironment _env;
|
||||
|
||||
public EnvironmentView(IWebHostEnvironment env)
|
||||
{
|
||||
_env = env;
|
||||
}
|
||||
|
||||
public static DateTime AssemblyBuildDate()
|
||||
{
|
||||
//https://stackoverflow.com/a/804310/266594
|
||||
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
|
||||
System.IO.FileInfo fileInfo = new System.IO.FileInfo(assembly.Location);
|
||||
DateTime lastModified = fileInfo.LastWriteTime;
|
||||
|
||||
return lastModified;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Models;
|
||||
|
||||
public interface IEnvironmentView
|
||||
{
|
||||
string Application { get; }
|
||||
DateTime CurrentDate { get; }
|
||||
string BuildVersion { get; }
|
||||
DateTime BuildDate { get; }
|
||||
string Environment { get; }
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Serilog;
|
||||
using System;
|
||||
|
||||
namespace LCU.Api.Internal.ArchiverApi;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CreateHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); })
|
||||
.ConfigureAppConfiguration((context,builder) =>
|
||||
{
|
||||
builder.AddJsonFile("/app/config/mapped-appsettings/primary.json", optional: true, reloadOnChange: true);
|
||||
builder.AddJsonFile("/vault/secrets/archiver-api-database-connection.json", optional: true, reloadOnChange: true);
|
||||
builder.AddJsonFile("/vault/secrets/archiver-api-seq-api-key.json", optional: true, reloadOnChange: true);
|
||||
builder.AddJsonFile("/vault/secrets/archiver-api-queue-username.json", optional: true, reloadOnChange: true);
|
||||
builder.AddJsonFile("/vault/secrets/archiver-api-queue-password.json", optional: true, reloadOnChange: true);
|
||||
builder.AddJsonFile("/vault/secrets/archiverapi_configuration.json", optional: true, reloadOnChange: true);
|
||||
|
||||
var config = builder.Build();
|
||||
})
|
||||
.UseSerilog();
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:56414",
|
||||
"sslPort": 44353
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"LCU.Api.Internal.AutomicApiWrapper": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": "true",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "swagger",
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Threading.Tasks;
|
||||
using Serilog;
|
||||
using LCU.Library.Internal.ArchiverApiLib.Repositories;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public class ApplicationMappingService : IApplicationMappingService
|
||||
{
|
||||
private readonly IApplicationMappingRepository _applicationMappingRepository;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public ApplicationMappingService(IUnitOfWork unitOfWork,
|
||||
IApplicationMappingRepository applicationMappingRepository)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
_applicationMappingRepository = applicationMappingRepository;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ApplicationMapping>> GetAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _applicationMappingRepository.ListAsync();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Failure retrieving application mappings.");
|
||||
throw new ServiceException("Failure retrieving application mappings.");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ApplicationMapping> GetByIdAsync(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var applicationMapping = await _applicationMappingRepository.FindByIdAsync(id);
|
||||
ArgumentNullException.ThrowIfNull(applicationMapping);
|
||||
return applicationMapping;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, $"Failure retrieving application mapping with id {id}.");
|
||||
throw new ServiceException($"Failure retrieving application mapping with id {id}.");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ApplicationMapping>> GetByIdentifierAsync(string identifier)
|
||||
{
|
||||
try
|
||||
{
|
||||
var applicationMapping = await _applicationMappingRepository.FindByIdentifierAsync(identifier);
|
||||
ArgumentNullException.ThrowIfNull(applicationMapping);
|
||||
return applicationMapping;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, $"Failure retrieving application mapping with id {identifier}.");
|
||||
throw new ServiceException($"Failure retrieving application mapping with id {identifier}.");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ApplicationMapping> SaveAsync(ApplicationMapping applicationMapping)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = await _applicationMappingRepository.AddAsync(applicationMapping);
|
||||
await _unitOfWork.CompleteAsync();
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Failure saving application mapping");
|
||||
throw new ServiceException("Failure saving application mapping");
|
||||
}
|
||||
}
|
||||
|
||||
public ApplicationMapping Update(ApplicationMapping applicationMapping)
|
||||
{
|
||||
try
|
||||
{
|
||||
var existing = GetByIdAsync(applicationMapping.ApplicationMappingId).Result;
|
||||
ArgumentNullException.ThrowIfNull(existing);
|
||||
|
||||
existing.Identifier = applicationMapping.Identifier;
|
||||
existing.DesignatedName = applicationMapping.DesignatedName;
|
||||
existing.ApplicationOverrideName = applicationMapping.ApplicationOverrideName;
|
||||
existing.ParameterMappings = applicationMapping.ParameterMappings;
|
||||
|
||||
_applicationMappingRepository.Update(existing);
|
||||
_unitOfWork.Complete();
|
||||
|
||||
return existing;
|
||||
}
|
||||
catch (SqlException sqlException)
|
||||
{
|
||||
Log.Error(sqlException, "SQL Failure updating application mapping");
|
||||
throw new ServiceException("SQL Failure updating application mapping");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Failure updating application mapping");
|
||||
throw new ServiceException("Failure updating application mapping");
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteAsync(int applicationMappingId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var applicationMapping = _applicationMappingRepository.FindByIdAsync(applicationMappingId).Result;
|
||||
ArgumentNullException.ThrowIfNull(applicationMapping);
|
||||
_applicationMappingRepository.Remove(applicationMapping);
|
||||
_unitOfWork.Complete();
|
||||
}
|
||||
catch (SqlException sqlException)
|
||||
{
|
||||
Log.Error(sqlException, $"SQL failure removing application mapping. ApplicationMappingId: {applicationMappingId}");
|
||||
throw new ServiceException($"SQL failure removing application mapping. ApplicationMappingId: {applicationMappingId}");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, $"Failure removing application mapping. ApplicationMappingId: {applicationMappingId}");
|
||||
throw new ServiceException($"Failure removing application mapping. ApplicationMappingId: {applicationMappingId}");
|
||||
}
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Serilog;
|
||||
using Newtonsoft.Json;
|
||||
using LCU.Api.Internal.MaidBotLib.Models;
|
||||
using LCU.Library.Internal.ApiResponse.Models;
|
||||
using LCU.Library.Internal.ApiResponse.Services;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public class ArchiveCompletionService : IArchiveCompletionService
|
||||
{
|
||||
private readonly IFileOperationsService _fileOperationsService;
|
||||
private readonly INotificationService _notificationService;
|
||||
|
||||
public ArchiveCompletionService(IFileOperationsService fileOperationsService,
|
||||
INotificationService notificationService)
|
||||
{
|
||||
_fileOperationsService = fileOperationsService;
|
||||
_notificationService = notificationService;
|
||||
}
|
||||
|
||||
public void HandleReportArchiveCompletedRequest(Response response)
|
||||
{
|
||||
try
|
||||
{
|
||||
var payLoadString = response.ResponsePayload;
|
||||
var archiveResponsePayload = JsonConvert.DeserializeObject<ArchiveResponsePayload>(payLoadString);
|
||||
var archiveRequestResponse = archiveResponsePayload.ArchiveRequestResponse;
|
||||
archiveRequestResponse.IsSuccessful = response.Successful;
|
||||
archiveRequestResponse.MessageStack.AddRange(response.ResponseStack);
|
||||
|
||||
var requestResult = PopulateErrorDetailsAndRequestResponse(archiveResponsePayload, archiveRequestResponse);
|
||||
|
||||
QueueReturnResponse.QueueResponse(archiveResponsePayload.ArchiveRequest,
|
||||
requestResult.archiveRequestResponse.IsSuccessful,
|
||||
requestResult.archiveRequestResponse.MessageStack);
|
||||
|
||||
var errorsSent = _notificationService.SendErrorEmailAsync(requestResult.errorDetails).Result;
|
||||
if (!errorsSent)
|
||||
{
|
||||
Log.ForContext(nameof(PropertyEnum.Group),
|
||||
nameof(GroupEnum.ITDevelopment))
|
||||
.Error($"Failure to send error details for {requestResult.errorDetails.Count} errors.");
|
||||
throw new Exception($"Failure to send error details for {requestResult.errorDetails.Count} errors.");
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, $"Error while archiving reports. " +
|
||||
$"Message:{exception.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public (List<ErrorDetail> errorDetails, ArchiveRequestResponse archiveRequestResponse) PopulateErrorDetailsAndRequestResponse(ArchiveResponsePayload archiveResponsePayload,
|
||||
ArchiveRequestResponse archiveRequestResponse)
|
||||
{
|
||||
var errorDetails = new List<ErrorDetail>();
|
||||
foreach (var request in archiveResponsePayload.BulkOperationRequest.OperationRequests)
|
||||
{
|
||||
var errorMessage = "";
|
||||
try
|
||||
{
|
||||
//If file still exist move did not occur.
|
||||
var fileExists = _fileOperationsService.ValidateFileExists(request.Source).Result;
|
||||
if (fileExists)
|
||||
{
|
||||
errorMessage = $"File {request.SourceFile} was not archived to the path of {request.Destination} ";
|
||||
archiveRequestResponse.IsSuccessful = false;
|
||||
archiveRequestResponse.MessageStack.Add(errorMessage);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
var loggingMessage = $"Exception thrown while looking for the file at path {request.Source}.";
|
||||
errorMessage = $"{loggingMessage}. Message: {exception.Message}";
|
||||
Log.Error(exception, loggingMessage);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(errorMessage))
|
||||
{
|
||||
var newErrorDetail = new ErrorDetail()
|
||||
{
|
||||
FileLocation = request.SourcePath,
|
||||
Filename = request.FinalSourceFile,
|
||||
Destination = request.Destination,
|
||||
Description = errorMessage
|
||||
};
|
||||
errorDetails.Add(newErrorDetail);
|
||||
}
|
||||
}
|
||||
|
||||
return (errorDetails, archiveRequestResponse);
|
||||
}
|
||||
}
|
||||
+284
@@ -0,0 +1,284 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Serilog;
|
||||
using Newtonsoft.Json;
|
||||
using LCU.Library.Internal.ApiResponse.Models;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models.NameSettings;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models;
|
||||
using LCU.Api.Internal.ArchiverApi.Configuration;
|
||||
using LCU.Api.Internal.MaidBotLib.Models;
|
||||
using LCU.Library.Internal.ApiResponse.Services;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
using LCU.Library.Internal.LcuMassTransitModels;
|
||||
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public class ArchiverService : IArchiverService
|
||||
{
|
||||
private readonly ArchiverApiConfig _ArchiverApiConfig;
|
||||
private readonly IReportService _reportService;
|
||||
private readonly IFileOperationsService _fileOperationsService;
|
||||
private readonly ConnectionConfiguration _connectionConfiguration;
|
||||
private readonly ReceiveEndpointConfiguration _receiveEndpointsConfiguration;
|
||||
|
||||
private const string NameRegexStartTag = "{Regex0}";
|
||||
private const string NameRegexStart = "^(" + RegexStartCaseInsenstive;
|
||||
private const string NameRegexEndTag = "{Regex1}";
|
||||
private const string NameRegexEnd = RegexStopCaseInsenstive + ")";
|
||||
private const string AnyWordAndPeriodRegexTag = "{Regex2}";
|
||||
private const string AnyWordAndPeriodRegex = "\\w*\\.";
|
||||
private const string ExtensionRegexTag = "{Regex3}";
|
||||
private const string ExtensionRegexStart = "(";
|
||||
private const string ExtensionRegexEnd = ")$";
|
||||
private const string RegexPipe = "|";
|
||||
private const string RegexStartCaseInsenstive = "(?i)";
|
||||
private const string RegexStopCaseInsenstive = "(?-i)";
|
||||
|
||||
public ArchiverService(ArchiverApiConfig ArchiverApiConfig,
|
||||
IReportService reportService,
|
||||
IFileOperationsService fileOperationsService,
|
||||
ConnectionConfiguration connectionConfiguration,
|
||||
ReceiveEndpointConfigurations receiveEndpointsConfiguration)
|
||||
{
|
||||
_ArchiverApiConfig = ArchiverApiConfig;
|
||||
_reportService = reportService;
|
||||
_fileOperationsService = fileOperationsService;
|
||||
_connectionConfiguration = connectionConfiguration;
|
||||
_receiveEndpointsConfiguration = receiveEndpointsConfiguration.ResponseReceiveEndpoint;
|
||||
}
|
||||
|
||||
public void ExecuteRequest(ArchiveRequest archiveRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var archiveResult = HandleArchiveRequest(archiveRequest);
|
||||
if (!archiveResult.archiveRequestResponse.IsSuccessful)
|
||||
{
|
||||
var errorMessage = String.Join("; ", archiveResult.archiveRequestResponse.MessageStack.ToArray());
|
||||
Log.Error($"Archive Request was not successful. MessaggeStack:{errorMessage}");
|
||||
}
|
||||
|
||||
//Happy path we queue return response later in ArchivecompletionService after the BulkOperations has been preformed.
|
||||
if (archiveResult.queueReturnResponse)
|
||||
{
|
||||
QueueReturnResponse.QueueResponse(archiveRequest,
|
||||
archiveResult.archiveRequestResponse.IsSuccessful,
|
||||
archiveResult.archiveRequestResponse.MessageStack);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(nameof(PropertyEnum.Group),
|
||||
nameof(GroupEnum.ITDevelopment))
|
||||
.Error(exception, $"Error while archiving reports. Look into failed ArchiveRequest. " +
|
||||
$"ArchiveRequest: {JsonConvert.SerializeObject(archiveRequest)}");
|
||||
}
|
||||
}
|
||||
|
||||
public (ArchiveRequestResponse archiveRequestResponse, bool queueReturnResponse) HandleArchiveRequest(ArchiveRequest archiveRequest)
|
||||
{
|
||||
var archiveRequestResponse = new ArchiveRequestResponse();
|
||||
try
|
||||
{
|
||||
var reports = _reportService.GetReportsToArchiveAsync(archiveRequest).Result;
|
||||
if (!reports.Any())
|
||||
{
|
||||
Log.Information("No reports to bulk move.");
|
||||
archiveRequestResponse.MessageStack.Add("No application histories retrieved from DNA database to move.");
|
||||
archiveRequestResponse.IsSuccessful = archiveRequest.SucceedIfEmpty;
|
||||
return (archiveRequestResponse, true);
|
||||
}
|
||||
|
||||
var bulkOperationRequest = BuildBulkOperationRequest(reports, archiveRequest);
|
||||
if (!bulkOperationRequest.OperationRequests.Any())
|
||||
{
|
||||
Log.Information("There are no files to bulk move.");
|
||||
archiveRequestResponse.MessageStack.Add("There are no files to bulk move.");
|
||||
archiveRequestResponse.IsSuccessful = archiveRequest.SucceedIfEmpty;
|
||||
return (archiveRequestResponse, true);
|
||||
}
|
||||
|
||||
bulkOperationRequest = SetUpResponse(bulkOperationRequest, archiveRequest, archiveRequestResponse);
|
||||
_fileOperationsService.SendBulkOperationsAsync(bulkOperationRequest);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
archiveRequestResponse.IsSuccessful = false;
|
||||
var anyIdentifiers = archiveRequest.ArchiveIdentifiers != null && archiveRequest.ArchiveIdentifiers.Any();
|
||||
var identifiers = anyIdentifiers ? String.Join(", ", archiveRequest.ArchiveIdentifiers.ToArray()) : "";
|
||||
archiveRequestResponse.MessageStack.Add($"Failure to execute archive request. " +
|
||||
$"EffectiveDate: [{archiveRequest.EffectiveDate}], " +
|
||||
$"DaysFromDate: [{archiveRequest.DaysFromDate}], " +
|
||||
$"ArchiveDestinationBase: [{archiveRequest.ArchiveDestinationBase}], " +
|
||||
$"Identifiers: [{identifiers}], " +
|
||||
$"Exception: {exception} ");
|
||||
}
|
||||
|
||||
return (archiveRequestResponse, !archiveRequestResponse.IsSuccessful);
|
||||
}
|
||||
|
||||
public BulkOperationRequest<MoveFileRequest> BuildBulkOperationRequest(IEnumerable<Report> reports, ArchiveRequest archiveRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var bulkOperationRequest = new BulkOperationRequest<MoveFileRequest>();
|
||||
bulkOperationRequest.OperationRequests = new List<MoveFileRequest>();
|
||||
var extensionRegex = new RegexSetting()
|
||||
{
|
||||
Tag = ExtensionRegexTag,
|
||||
Regex = BuildExtensionRegexString(archiveRequest)
|
||||
};
|
||||
var anyWordAndPeriodRegex = new RegexSetting()
|
||||
{
|
||||
Tag = AnyWordAndPeriodRegexTag,
|
||||
Regex = AnyWordAndPeriodRegex
|
||||
};
|
||||
|
||||
foreach (var report in reports)
|
||||
{
|
||||
var nameSettings = SetUpNameSettings(report);
|
||||
|
||||
nameSettings.RegexSettings.Add(anyWordAndPeriodRegex);
|
||||
nameSettings.RegexSettings.Add(extensionRegex);
|
||||
var dynamicallyNamedRequests = CreateOperationRequests(report, nameSettings, archiveRequest);
|
||||
bulkOperationRequest.OperationRequests.AddRange(dynamicallyNamedRequests);
|
||||
}
|
||||
|
||||
return bulkOperationRequest;
|
||||
}
|
||||
catch (AggregateException exception)
|
||||
{
|
||||
throw new AggregateException($"Error while attempting to build bulk operation request. " +
|
||||
$"Exception Message: {exception.Message}");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw new Exception($"Error while attempting to build bulk operation request. " +
|
||||
$"Exception Message: {exception.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public string BuildExtensionRegexString(ArchiveRequest archiveRequest)
|
||||
{
|
||||
var regexStringBuilder = new StringBuilder();
|
||||
regexStringBuilder.Append(ExtensionRegexStart);
|
||||
|
||||
for (int index = 0; index < archiveRequest.AllowedExensions.Count; ++index)
|
||||
{
|
||||
var pipe = index == archiveRequest.AllowedExensions.Count ? "" : RegexPipe;
|
||||
regexStringBuilder.Append(RegexStartCaseInsenstive +
|
||||
archiveRequest.AllowedExensions[index] +
|
||||
RegexStopCaseInsenstive +
|
||||
pipe);
|
||||
}
|
||||
|
||||
regexStringBuilder.Append(ExtensionRegexEnd);
|
||||
return regexStringBuilder.ToString();
|
||||
}
|
||||
|
||||
public List<MoveFileRequest> CreateOperationRequests(Report report, DynamicNameSetting nameSettings, ArchiveRequest archiveRequest)
|
||||
{
|
||||
var fileName = report.HasRegexMapping ? report.DisplayReportName : report.FinalReportName;
|
||||
|
||||
DateTime effectiveDate = archiveRequest.EffectiveDate == null ? DateTime.MinValue : (DateTime)archiveRequest.EffectiveDate;
|
||||
var reportPath = $"{_ArchiverApiConfig.DnaBasePath}\\" +
|
||||
$"{effectiveDate.ToString(_ArchiverApiConfig.ReportPathDateFormat)}\\" +
|
||||
$"{report.QueueNumber}";
|
||||
var sourceFile = $"{NameRegexStartTag}{fileName}{NameRegexEndTag}{AnyWordAndPeriodRegexTag}{ExtensionRegexTag}";
|
||||
var files = _fileOperationsService.BuildDynamicFileListAsync(reportPath, sourceFile, nameSettings).Result;
|
||||
var dynamicallyNamedRequests = new List<MoveFileRequest>();
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
var request = new MoveFileRequest()
|
||||
{
|
||||
SourcePath = reportPath,
|
||||
SourceFile = file,
|
||||
DestinationPath = archiveRequest.ArchiveDestinationBase,
|
||||
FileNameSetting = nameSettings
|
||||
};
|
||||
SetDestinationName(report, request, archiveRequest);
|
||||
dynamicallyNamedRequests.Add(request);
|
||||
}
|
||||
|
||||
return dynamicallyNamedRequests;
|
||||
}
|
||||
|
||||
public void SetDestinationName(Report report, MoveFileRequest request, ArchiveRequest archiveRequest)
|
||||
{
|
||||
var extention = archiveRequest.AllowedExensions
|
||||
.FirstOrDefault(fe => request.SourceFile.Contains($".{fe}", StringComparison.OrdinalIgnoreCase));
|
||||
if (extention != null)
|
||||
{
|
||||
request.DestinationName = report.BuildDestinationName(request.FinalSourceFile, extention);
|
||||
}
|
||||
}
|
||||
|
||||
public DynamicNameSetting SetUpNameSettings(Report report) {
|
||||
var nameSettings = new DynamicNameSetting();
|
||||
nameSettings.RegexSettings = new List<RegexSetting>()
|
||||
{
|
||||
new RegexSetting()
|
||||
{
|
||||
Tag = NameRegexStartTag,
|
||||
Regex = NameRegexStart
|
||||
},
|
||||
new RegexSetting()
|
||||
{
|
||||
Tag = NameRegexEndTag,
|
||||
Regex = NameRegexEnd
|
||||
}
|
||||
};
|
||||
|
||||
if (report.ApplicationMapping == null)
|
||||
{
|
||||
return nameSettings;
|
||||
};
|
||||
|
||||
foreach (var regex in report.ApplicationMapping.RegexMappings)
|
||||
{
|
||||
nameSettings.RegexSettings.Add(new RegexSetting()
|
||||
{
|
||||
Tag = regex.Tag,
|
||||
Regex = regex.Regex,
|
||||
});
|
||||
}
|
||||
return nameSettings;
|
||||
}
|
||||
|
||||
public BulkOperationRequest<MoveFileRequest> SetUpResponse(BulkOperationRequest<MoveFileRequest> bulkOperationRequest,
|
||||
ArchiveRequest archiveRequest,
|
||||
ArchiveRequestResponse archiveRequestResponse)
|
||||
{
|
||||
var archiveResponsePayload = new ArchiveResponsePayload()
|
||||
{
|
||||
ArchiveRequest = archiveRequest,
|
||||
BulkOperationRequest = bulkOperationRequest,
|
||||
ArchiveRequestResponse = archiveRequestResponse
|
||||
};
|
||||
|
||||
var responseItem = new ResponseItem
|
||||
{
|
||||
ReturnQueueConsumerConfig = new QueueConsumerConfig()
|
||||
{
|
||||
ExchangeName = _receiveEndpointsConfiguration.ReceiveEndpoint
|
||||
},
|
||||
ReturnQueueConnectionConfig = new QueueConnectionConfig()
|
||||
{
|
||||
Url = _connectionConfiguration.HostUrl,
|
||||
Username = _connectionConfiguration.UserName,
|
||||
Password = _connectionConfiguration.Password
|
||||
},
|
||||
ResponsePayload = JsonConvert.SerializeObject(archiveResponsePayload)
|
||||
};
|
||||
|
||||
bulkOperationRequest.ResponseItems = new List<ResponseItem>()
|
||||
{
|
||||
responseItem
|
||||
};
|
||||
|
||||
return bulkOperationRequest;
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using LCU.Api.Internal.ArchiverApi.Configuration;
|
||||
using LCU.Library.Internal.ArchiverApi.Utilities;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.ApplicationHistories;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public class CoreApiWrapperService : ICoreApiWrapperService
|
||||
{
|
||||
private readonly ArchiverApiConfig _ArchiverApiConfig;
|
||||
|
||||
public CoreApiWrapperService(ArchiverApiConfig ArchiverApiConfig)
|
||||
{
|
||||
_ArchiverApiConfig = ArchiverApiConfig;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ApplicationHistory>> GetApplicationHistories(ArchiveRequest archiveRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var applicationHistoryRequest = new ApplicationHistoryRequest()
|
||||
{
|
||||
ApplicationNumbers = archiveRequest.ArchiveIdentifiers,
|
||||
EffectiveDate = archiveRequest.EffectiveDate.ToString()
|
||||
};
|
||||
|
||||
var url = SetUpUrl(applicationHistoryRequest);
|
||||
var client = HttpUtilities.GetClient(url);
|
||||
var response = await client.GetAsync(url);
|
||||
response.EnsureSuccessStatusCode();
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception($"Issue retrieving Application History from Core Api Wrapper. " +
|
||||
$"Request: {JsonConvert.SerializeObject(applicationHistoryRequest)}");
|
||||
}
|
||||
|
||||
var stringResponse = await response.Content.ReadAsStringAsync();
|
||||
var applicationHistories = JsonConvert.DeserializeObject<List<ApplicationHistory>>(stringResponse);
|
||||
return applicationHistories;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw new Exception($"Failure to get application histories. Exception Message: {exception.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public string SetUpUrl(ApplicationHistoryRequest applicationHistoryRequest)
|
||||
{
|
||||
var endpointBuilder = new StringBuilder();
|
||||
endpointBuilder.Append(_ArchiverApiConfig.CoreApiWrapperGetApplicationHistory);
|
||||
|
||||
var propertyCounter = 0;
|
||||
var propertyName = nameof(applicationHistoryRequest.ApplicationNumbers);
|
||||
HttpUtilities.AppendListOfValuesToEndpoint(endpointBuilder, propertyCounter, applicationHistoryRequest.ApplicationNumbers, propertyName);
|
||||
endpointBuilder.Append($"&{nameof(applicationHistoryRequest.EffectiveDate)}={applicationHistoryRequest.EffectiveDate}");
|
||||
return endpointBuilder.ToString();
|
||||
}
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models.NameSettings;
|
||||
using LCU.Library.Internal.ArchiverApi.Utilities;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models;
|
||||
using LCU.Api.Internal.ArchiverApi.Configuration;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public class FileOperationsService : IFileOperationsService
|
||||
{
|
||||
private readonly ArchiverApiConfig _ArchiverApiConfig;
|
||||
|
||||
public FileOperationsService(ArchiverApiConfig ArchiverApiConfig)
|
||||
{
|
||||
_ArchiverApiConfig = ArchiverApiConfig;
|
||||
}
|
||||
|
||||
public void SendBulkOperationsAsync(BulkOperationRequest<MoveFileRequest> bulkOperationRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var encoded = JsonConvert.SerializeObject(bulkOperationRequest);
|
||||
var client = HttpUtilities.GetClient(_ArchiverApiConfig.FileOperationApiBulkMoveFile);
|
||||
var content = new StringContent(encoded, Encoding.UTF8, "application/json");
|
||||
|
||||
HttpResponseMessage response = client.PostAsync(_ArchiverApiConfig.FileOperationApiBulkMoveFile, content).Result;
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception($"IsSuccessStatusCode: {response.IsSuccessStatusCode}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception($"Failure to use the Bulk Operations. Message{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<string>> BuildDynamicFileListAsync(string path, string file, DynamicNameSetting dynamicNameSetting)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dynamicFileListRequest = new DynamicFileListRequest()
|
||||
{
|
||||
Path = path,
|
||||
Filename = file,
|
||||
DynamicFileSettings = dynamicNameSetting
|
||||
};
|
||||
|
||||
var encoded = JsonConvert.SerializeObject(dynamicFileListRequest);
|
||||
var client = HttpUtilities.GetClient(_ArchiverApiConfig.FileOperationApiBuildDynamicFileList);
|
||||
var content = new StringContent(encoded, Encoding.UTF8, "application/json");
|
||||
HttpResponseMessage response = await client.PostAsync(_ArchiverApiConfig.FileOperationApiBuildDynamicFileList, content);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception($"IsSuccessStatusCode: {response.IsSuccessStatusCode}");
|
||||
}
|
||||
|
||||
var stringResponse = await response.Content.ReadAsStringAsync();
|
||||
var fileList = JsonConvert.DeserializeObject<List<string>>(stringResponse);
|
||||
return fileList;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw new Exception($"Unable to build dynamic list of files. Exception Message: {exception}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> ValidateFileExists(string sourceFilePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
var encoded = JsonConvert.SerializeObject(sourceFilePath);
|
||||
var client = HttpUtilities.GetClient(_ArchiverApiConfig.FileOperationApiValidateFileExists);
|
||||
var content = new StringContent(encoded, Encoding.UTF8, "application/json");
|
||||
HttpResponseMessage response = await client.PostAsync(_ArchiverApiConfig.FileOperationApiValidateFileExists, content);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception($"IsSuccessStatusCode: {response.IsSuccessStatusCode}");
|
||||
}
|
||||
|
||||
var stringResponse = await response.Content.ReadAsStringAsync();
|
||||
var result = JsonConvert.DeserializeObject<bool>(stringResponse);
|
||||
return result;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw new Exception($"Failure to validate files exist. " +
|
||||
$"Exception Message:{exception.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public interface IApplicationMappingService
|
||||
{
|
||||
Task<IEnumerable<ApplicationMapping>> GetAsync();
|
||||
Task<ApplicationMapping> GetByIdAsync(int id);
|
||||
Task<IEnumerable<ApplicationMapping>> GetByIdentifierAsync(string identifier);
|
||||
Task<ApplicationMapping> SaveAsync(ApplicationMapping applicationMapping);
|
||||
ApplicationMapping Update(ApplicationMapping applicationMapping);
|
||||
void DeleteAsync(int applicationMappingId);
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
using LCU.Library.Internal.ApiResponse.Models;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public interface IArchiveCompletionService
|
||||
{
|
||||
void HandleReportArchiveCompletedRequest(Response response);
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models.NameSettings;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public interface IArchiverService
|
||||
{
|
||||
void ExecuteRequest(ArchiveRequest archiveRequest);
|
||||
(ArchiveRequestResponse archiveRequestResponse, bool queueReturnResponse) HandleArchiveRequest(ArchiveRequest archiveRequest);
|
||||
BulkOperationRequest<MoveFileRequest> BuildBulkOperationRequest(IEnumerable<Report> reports, ArchiveRequest archiveRequest);
|
||||
string BuildExtensionRegexString(ArchiveRequest archiveRequest);
|
||||
List<MoveFileRequest> CreateOperationRequests(Report report, DynamicNameSetting nameSettings, ArchiveRequest archiveRequest);
|
||||
void SetDestinationName(Report report, MoveFileRequest request, ArchiveRequest archiveRequest);
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.ApplicationHistories;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public interface ICoreApiWrapperService
|
||||
{
|
||||
Task<IEnumerable<ApplicationHistory>> GetApplicationHistories(ArchiveRequest archiveRequest);
|
||||
string SetUpUrl(ApplicationHistoryRequest applicationHistoryRequest);
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models.NameSettings;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public interface IFileOperationsService
|
||||
{
|
||||
void SendBulkOperationsAsync(BulkOperationRequest<MoveFileRequest> bulkOperationRequest);
|
||||
Task<List<string>> BuildDynamicFileListAsync(string path, string file, DynamicNameSetting dynamicNameSetting);
|
||||
Task<bool> ValidateFileExists(string sourceFilePath);
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public interface INotificationService
|
||||
{
|
||||
Task<bool> SendEmailAsync(List<string> recipients, string subject, string emailTemplate);
|
||||
Task<bool> SendErrorEmailAsync(List<ErrorDetail> errorDetails);
|
||||
string CreateErrorRow(ErrorDetail errorDetail, string basePath);
|
||||
string CreateErrorMonitoringEmail(string errorRows, string basePath);
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public interface IQueueArchiverService
|
||||
{
|
||||
void QueueArchiver(ArchiveRequest archiveRequest);
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public interface IRegexMappingService
|
||||
{
|
||||
Task<IEnumerable<RegexMapping>> GetAsync();
|
||||
Task<RegexMapping> GetByApplicationMappingIdAsync(int id);
|
||||
Task<RegexMapping> SaveAsync(RegexMapping regexMapping);
|
||||
RegexMapping Update(RegexMapping regexMapping);
|
||||
void DeleteAsync(int regexMappingId);
|
||||
public Task<RegexMapping> GetByRegexMappingIdAsync(int id);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public interface IReportService
|
||||
{
|
||||
Task<IEnumerable<Report>> GetReportsToArchiveAsync(ArchiveRequest archiveRequest);
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using Serilog;
|
||||
using LCU.Api.Internal.ArchiverApi.Configuration;
|
||||
using LCU.API.Internal.NotificationsApiLib.Models;
|
||||
using LCU.Library.Internal.ArchiverApi.Utilities;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public class NotificationService : INotificationService
|
||||
{
|
||||
private readonly ArchiverApiConfig _ArchiverApiConfig;
|
||||
private const string TableRowsTag = "{TableRows}";
|
||||
|
||||
public NotificationService(ArchiverApiConfig ArchiverApiConfig)
|
||||
{
|
||||
_ArchiverApiConfig = ArchiverApiConfig;
|
||||
}
|
||||
|
||||
public async Task<bool> SendEmailAsync(List<string> recipients, string subject, string emailTemplate)
|
||||
{
|
||||
try
|
||||
{
|
||||
var emailRequest = new EmailRequest
|
||||
{
|
||||
Recipient = recipients,
|
||||
Subject = subject,
|
||||
Body = emailTemplate
|
||||
};
|
||||
|
||||
var encoded = JsonConvert.SerializeObject(emailRequest);
|
||||
var client = HttpUtilities.GetClient(_ArchiverApiConfig.NotificationApiEmail);
|
||||
var content = new StringContent(encoded, Encoding.UTF8, "application/json");
|
||||
HttpResponseMessage response = await client.PostAsync(_ArchiverApiConfig.NotificationApiEmail, content);
|
||||
response.EnsureSuccessStatusCode();
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failure to send email from Archiver Api");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> SendErrorEmailAsync(List<ErrorDetail> errorDetails)
|
||||
{
|
||||
if (!errorDetails.Any())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
var basePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
|
||||
string rowsOfErrors = "";
|
||||
foreach (var errorDetail in errorDetails)
|
||||
{
|
||||
rowsOfErrors += CreateErrorRow(errorDetail, basePath);
|
||||
}
|
||||
|
||||
var emailTemplate = CreateErrorMonitoringEmail(rowsOfErrors, basePath);
|
||||
var successfullySent = await SendEmailAsync(_ArchiverApiConfig.ErrorRecipients,
|
||||
_ArchiverApiConfig.ErrorMonitoringSubject,
|
||||
emailTemplate);
|
||||
return successfullySent;
|
||||
}
|
||||
|
||||
public string CreateErrorRow(ErrorDetail errorDetail, string basePath)
|
||||
{
|
||||
var errorRowReader = new StreamReader($"{basePath}{_ArchiverApiConfig.ErrorRowTemplate}");
|
||||
string errorRowOutput = errorRowReader.ReadToEnd();
|
||||
|
||||
foreach (var property in errorDetail.GetType().GetProperties())
|
||||
{
|
||||
string value = property.GetValue(errorDetail) == null ?
|
||||
string.Empty :
|
||||
property.GetValue(errorDetail).ToString();
|
||||
errorRowOutput = errorRowOutput.Replace($"{{{property.Name}}}", value);
|
||||
}
|
||||
|
||||
return errorRowOutput;
|
||||
}
|
||||
|
||||
public string CreateErrorMonitoringEmail(string errorRows, string basePath)
|
||||
{
|
||||
var errorMonitoringReader = new StreamReader($"{basePath}{_ArchiverApiConfig.ErrorMonitoringTemplate}");
|
||||
string errorMonitoringOutput = errorMonitoringReader.ReadToEnd();
|
||||
return errorMonitoringOutput.Replace(TableRowsTag, errorRows);
|
||||
}
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using Serilog;
|
||||
using MassTransit;
|
||||
using TimeZoneConverter;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
using LCU.Api.Internal.ArchiverApi.Configuration;
|
||||
using LCU.Library.Internal.LcuMassTransitModels;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public class QueueArchiverService : IQueueArchiverService
|
||||
{
|
||||
private readonly ISendEndpoint _sendEndpoint;
|
||||
private readonly ReceiveEndpointConfiguration _receiveEndpointsConfiguration;
|
||||
private readonly ArchiverApiConfig _archiverApiConfig;
|
||||
|
||||
public QueueArchiverService(IBusControl busControl,
|
||||
ReceiveEndpointConfigurations receiveEndpointsConfiguration,
|
||||
ArchiverApiConfig archiverApiConfig)
|
||||
{
|
||||
_receiveEndpointsConfiguration = receiveEndpointsConfiguration.ArchiverReceiveEndpoint;
|
||||
_archiverApiConfig = archiverApiConfig;
|
||||
_sendEndpoint = busControl.GetSendEndpoint(_receiveEndpointsConfiguration.ReceiveEndpointUri).Result;
|
||||
}
|
||||
|
||||
public void QueueArchiver(ArchiveRequest archiveRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dateToConvert = archiveRequest.EffectiveDate == null ?
|
||||
DateTime.Now.AddDays(archiveRequest.DaysFromDate) :
|
||||
Convert.ToDateTime(archiveRequest.EffectiveDate).AddDays(archiveRequest.DaysFromDate);
|
||||
|
||||
var assumedTimezone = TZConvert.GetTimeZoneInfo(_archiverApiConfig.TimeZone);
|
||||
archiveRequest.EffectiveDate = TimeZoneInfo.ConvertTime(dateToConvert, assumedTimezone).Date;
|
||||
_sendEndpoint.Send(archiveRequest);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex, $"Failed to queue archive request with effective date. Effective Date: {archiveRequest.EffectiveDate}");
|
||||
throw new ServiceException($"Failed to queue archive request with effective date. Effective Date: {archiveRequest.EffectiveDate}");
|
||||
}
|
||||
}
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
using LCU.Library.Internal.ArchiverApiLib.Repositories;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
using System.Data.SqlClient;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public class RegexMappingService : IRegexMappingService
|
||||
{
|
||||
private readonly IRegexMappingRepository _regexMappingRepository;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
public RegexMappingService(IUnitOfWork unitOfWork,
|
||||
IRegexMappingRepository regexMappingRepository)
|
||||
{
|
||||
_unitOfWork = unitOfWork;
|
||||
_regexMappingRepository = regexMappingRepository;
|
||||
}
|
||||
public void DeleteAsync(int regexMappingId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var regexMapping = _regexMappingRepository.FindByRegexMappingIdAsync(regexMappingId).Result;
|
||||
ArgumentNullException.ThrowIfNull(regexMapping);
|
||||
_regexMappingRepository.Remove(regexMapping);
|
||||
_unitOfWork.Complete();
|
||||
}
|
||||
catch (SqlException sqlException)
|
||||
{
|
||||
Log.Error(sqlException, $"SQL failure removing regex mapping. RegexMappingId: {regexMappingId}");
|
||||
throw new ServiceException($"SQL failure removing regex mapping. RegexMappingId: {regexMappingId}");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, $"Failure removing regex mapping. RegexMappingId: {regexMappingId}");
|
||||
throw new ServiceException($"Failure removing regex mapping. RegexMappingId: {regexMappingId}");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RegexMapping>> GetAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _regexMappingRepository.ListAsync();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Failure retrieving regex mappings.");
|
||||
throw new ServiceException("Failure retrieving regex mappings.");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<RegexMapping> GetByApplicationMappingIdAsync(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var regexMapping = await _regexMappingRepository.FindByApplicationMappingIdAsync(id);
|
||||
ArgumentNullException.ThrowIfNull(regexMapping);
|
||||
return regexMapping;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, $"Failure retrieving regex mapping with id {id}.");
|
||||
throw new ServiceException($"Failure retrieving regex mapping with id {id}.");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<RegexMapping> GetByRegexMappingIdAsync(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var regexMapping = await _regexMappingRepository.FindByRegexMappingIdAsync(id);
|
||||
ArgumentNullException.ThrowIfNull(regexMapping);
|
||||
return regexMapping;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, $"Failure retrieving regex mapping with id {id}.");
|
||||
throw new ServiceException($"Failure retrieving regex mapping with id {id}.");
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<RegexMapping> SaveAsync(RegexMapping regexMapping)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (CheckTagInvalid(regexMapping.Tag))
|
||||
{
|
||||
throw new Exception("Invalid Tag: "+regexMapping.Tag);
|
||||
}
|
||||
var result = await _regexMappingRepository.AddAsync(regexMapping);
|
||||
await _unitOfWork.CompleteAsync();
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Failure saving regex mapping");
|
||||
throw new ServiceException("Failure saving regex mapping");
|
||||
}
|
||||
}
|
||||
|
||||
public RegexMapping Update(RegexMapping regexMapping)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (CheckTagInvalid(regexMapping.Tag))
|
||||
{
|
||||
throw new Exception("Invalid Tag: "+regexMapping.Tag);
|
||||
}
|
||||
var existing = GetByRegexMappingIdAsync(regexMapping.RegexMappingId).Result;
|
||||
ArgumentNullException.ThrowIfNull(existing);
|
||||
|
||||
existing.ApplicationMappingId = regexMapping.ApplicationMappingId;
|
||||
existing.Regex = regexMapping.Regex;
|
||||
existing.Tag = regexMapping.Tag;
|
||||
|
||||
_regexMappingRepository.Update(existing);
|
||||
_unitOfWork.Complete();
|
||||
|
||||
return existing;
|
||||
}
|
||||
catch (SqlException sqlException)
|
||||
{
|
||||
Log.Error(sqlException, "SQL Failure updating regex mapping");
|
||||
throw new ServiceException("SQL Failure updating regex mapping");
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.Error(exception, "Failure updating regex mapping");
|
||||
throw new ServiceException("Failure updating regex mapping");
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckTagInvalid(string tag)
|
||||
{
|
||||
var endIndex = tag.IndexOf('}');
|
||||
var sub = tag.Substring(0, 6);
|
||||
if (tag.Substring(0,6) == "{Regex" && endIndex >= 7)
|
||||
{
|
||||
var tagNumber = Int32.Parse(tag.Substring(6, endIndex - 6));
|
||||
return tagNumber >= 0 && tagNumber <= 3;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.ApplicationHistories;
|
||||
|
||||
namespace LCU.Api.Internal.ArchiverApi.Services;
|
||||
|
||||
public class ReportService : IReportService
|
||||
{
|
||||
private readonly ICoreApiWrapperService _coreApiWrapperService;
|
||||
private readonly IApplicationMappingService _applicationMappingService;
|
||||
private readonly IRegexMappingService _regexMappingService;
|
||||
|
||||
public ReportService(ICoreApiWrapperService coreApiWrapperService,
|
||||
IApplicationMappingService applicationMappingService,
|
||||
IRegexMappingService regexMappingService)
|
||||
{
|
||||
_coreApiWrapperService = coreApiWrapperService;
|
||||
_applicationMappingService = applicationMappingService;
|
||||
_regexMappingService = regexMappingService;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<Report>> GetReportsToArchiveAsync(ArchiveRequest archiveRequest)
|
||||
{
|
||||
try
|
||||
{
|
||||
var applicationHistories = await _coreApiWrapperService.GetApplicationHistories(archiveRequest);
|
||||
var reports = new List<Report>();
|
||||
foreach (var applicationHistory in applicationHistories)
|
||||
{
|
||||
var applicationMappings = await _applicationMappingService.GetByIdentifierAsync(applicationHistory.ApplicationNumber.ToString());
|
||||
var report = new Report()
|
||||
{
|
||||
ReportName = applicationHistory.ApplicationName,
|
||||
QueueNumber = applicationHistory.QueueNumber.ToString(),
|
||||
StopDateTime = applicationHistory.StopDateTime,
|
||||
ApplicationMapping = DeteriminApplicationMapping(applicationMappings.ToList(), applicationHistory),
|
||||
};
|
||||
|
||||
reports.Add(report);
|
||||
}
|
||||
|
||||
return reports;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
throw new Exception($"Error while trying to get reports ready for archiving. " +
|
||||
$"Message: {exception.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
public ApplicationMapping DeteriminApplicationMapping(List<ApplicationMapping> applicationMappings, ApplicationHistory applicationHistory)
|
||||
{
|
||||
var applicationMapping = DeteriminApplicationMappingWithoutParameters(applicationMappings);
|
||||
if(applicationMapping != null)
|
||||
{
|
||||
return applicationMapping;
|
||||
}
|
||||
|
||||
applicationMapping = DeteriminApplicationMappingByParameters(applicationMappings, applicationHistory);
|
||||
return applicationMapping;
|
||||
}
|
||||
|
||||
public ApplicationMapping DeteriminApplicationMappingWithoutParameters(List<ApplicationMapping> possibleApplicationMappings)
|
||||
{
|
||||
var onlyASingleApplicationMapping = possibleApplicationMappings.Count == 1;
|
||||
if (onlyASingleApplicationMapping)
|
||||
{
|
||||
var singleApplicationMapping = possibleApplicationMappings.First();
|
||||
if (singleApplicationMapping.ParameterMappings == null ||
|
||||
!singleApplicationMapping.ParameterMappings.Any())
|
||||
{
|
||||
return singleApplicationMapping;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ApplicationMapping DeteriminApplicationMappingByParameters(List<ApplicationMapping> possibleApplicationMappings, ApplicationHistory applicationHistory)
|
||||
{
|
||||
foreach (var applicationMapping in possibleApplicationMappings)
|
||||
{
|
||||
bool containsAllParameter = false;
|
||||
foreach (var parameterMapping in applicationMapping.ParameterMappings)
|
||||
{
|
||||
containsAllParameter = applicationHistory.QueueApplicationParameters.Any(qap => qap.ParameterCode == parameterMapping.ParameterCode &&
|
||||
qap.ParameterValue == parameterMapping.ParameterValue);
|
||||
|
||||
if (!containsAllParameter)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (containsAllParameter)
|
||||
{
|
||||
return applicationMapping;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Serilog;
|
||||
using MassTransit;
|
||||
using LCU.Library.Internal.Logging.Models;
|
||||
using LCU.Library.Internal.Logging;
|
||||
using LCU.Library.Internal.Logging.Middleware;
|
||||
using LCU.Api.Internal.ArchiverApi.Configuration;
|
||||
using LCU.Api.Internal.ArchiverApi.Models;
|
||||
using LCU.Api.Internal.ArchiverApi.Services;
|
||||
using LCU.Library.Internal.ArchiverApiLib.Repositories;
|
||||
using LCU.Library.Internal.ArchiverApiLib.Persistence;
|
||||
using LCU.Library.Internal.LcuMassTransit;
|
||||
using LCU.Library.Internal.LcuMassTransitModels;
|
||||
using LCU.Api.Internal.ArchiverApi.Consumers;
|
||||
namespace LCU.Api.Internal.ArchiverApi;
|
||||
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddControllers();
|
||||
services.AddHttpClient();
|
||||
services.AddDbContext<AppDbContext>(options =>
|
||||
{
|
||||
options.UseSqlServer(
|
||||
Configuration.GetSection("Primary").GetSection("Connections").GetSection("SQL").GetSection("ArchiverApiDb").Value
|
||||
);
|
||||
});
|
||||
|
||||
var archiverApiConfig = new ArchiverApiConfig();
|
||||
Configuration.GetSection("Primary").Bind(archiverApiConfig);
|
||||
services.AddSingleton(archiverApiConfig);
|
||||
|
||||
var loggerConfiguration = new LoggingConfiguration(archiverApiConfig.ApplicationName,
|
||||
archiverApiConfig.SeqApiKey,
|
||||
archiverApiConfig.SeqUrl);
|
||||
var lcuLogging = new LcuLogging(loggerConfiguration);
|
||||
lcuLogging.UseLcuLogging();
|
||||
|
||||
var connectionConfiguration = MassTransitConfigurationSetUp.AddConnectionConfiguration(ref services, Configuration);
|
||||
var receiveEndpointConfigurations = new ReceiveEndpointConfigurations()
|
||||
{
|
||||
ArchiverReceiveEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(Configuration,
|
||||
"ArchiverReceiveEndpoint"),
|
||||
ResponseReceiveEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(Configuration,
|
||||
"ResponseReceiveEndpoint")
|
||||
};
|
||||
services.AddSingleton(receiveEndpointConfigurations);
|
||||
AddMassTransitServices(ref services, connectionConfiguration, receiveEndpointConfigurations, archiverApiConfig);
|
||||
|
||||
services.AddScoped<IEnvironmentView, EnvironmentView>();
|
||||
|
||||
//Services
|
||||
services.AddScoped<IReportService, ReportService>();
|
||||
services.AddScoped<IApplicationMappingService, ApplicationMappingService>();
|
||||
services.AddScoped<IRegexMappingService, RegexMappingService>();
|
||||
services.AddScoped<IArchiverService, ArchiverService>();
|
||||
services.AddScoped<IQueueArchiverService, QueueArchiverService>();
|
||||
services.AddScoped<IArchiveCompletionService, ArchiveCompletionService>();
|
||||
services.AddScoped<IFileOperationsService, FileOperationsService>();
|
||||
services.AddScoped<INotificationService, NotificationService>();
|
||||
services.AddScoped<ICoreApiWrapperService, CoreApiWrapperService>();
|
||||
|
||||
//Repositories
|
||||
services.AddScoped<IApplicationMappingRepository, ApplicationMappingRepository>();
|
||||
services.AddScoped<IRegexMappingRepository, RegexMappingRepository>();
|
||||
services.AddScoped<IUnitOfWork, UnitOfWork>();
|
||||
|
||||
services.AddControllers().AddJsonOptions(options => options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()));
|
||||
services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = $"{archiverApiConfig.ApplicationName}", Version = "v1" }); });
|
||||
|
||||
}
|
||||
|
||||
public void AddMassTransitServices(ref IServiceCollection services,
|
||||
ConnectionConfiguration connectionConfiguration,
|
||||
ReceiveEndpointConfigurations receiveEndpointConfigurations,
|
||||
ArchiverApiConfig archiverApiConfig)
|
||||
{
|
||||
services.AddMassTransit(x =>
|
||||
{
|
||||
x.AddConsumer<ArchiverConsumer>();
|
||||
x.AddConsumer<ResponseConsumer>();
|
||||
|
||||
x.UsingRabbitMq((context, cfg) =>
|
||||
{
|
||||
cfg.Host(connectionConfiguration.HostUrl, "/", host =>
|
||||
{
|
||||
host.Username(connectionConfiguration.UserName);
|
||||
host.Password(connectionConfiguration.Password);
|
||||
});
|
||||
|
||||
if (archiverApiConfig.FeatureFlags.RunArchiverConsumer)
|
||||
{
|
||||
cfg.ReceiveEndpoint(receiveEndpointConfigurations.ArchiverReceiveEndpoint.ReceiveEndpoint, e =>
|
||||
{
|
||||
e.ConfigureConsumer<ArchiverConsumer>(context);
|
||||
e.PrefetchCount = receiveEndpointConfigurations.ArchiverReceiveEndpoint.PrefetchLimit;
|
||||
e.SetQuorumQueue();
|
||||
});
|
||||
}
|
||||
|
||||
if (archiverApiConfig.FeatureFlags.RunResponseConsumer)
|
||||
{
|
||||
cfg.ReceiveEndpoint(receiveEndpointConfigurations.ResponseReceiveEndpoint.ReceiveEndpoint, e =>
|
||||
{
|
||||
e.ConfigureConsumer<ResponseConsumer>(context);
|
||||
e.PrefetchCount = receiveEndpointConfigurations.ResponseReceiveEndpoint.PrefetchLimit;
|
||||
e.SetQuorumQueue();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
services.AddMassTransitHostedService();
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("v1/swagger.json", "LCU.Api.Internal.ArchiverApi v1"));
|
||||
app.UseMiddleware<RequestResponseLoggingMiddleware>();
|
||||
app.UseSerilogRequestLogging(options => { options.EnrichDiagnosticContext = RequestResponseLoggingMiddleware.RequestDataParser.EnrichFromRequest; });
|
||||
app.UseHttpsRedirection();
|
||||
app.UseRouting();
|
||||
app.UseAuthorization();
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
}
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
#errors {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#errors td, #errors th {
|
||||
border: 1px solid #ddd;
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
#errors tr:nth-child(even) {
|
||||
background-color: #f2f2f2;
|
||||
}
|
||||
|
||||
#errors th {
|
||||
padding-top: 12px;
|
||||
padding-bottom: 12px;
|
||||
text-align: left;
|
||||
background-color: #4CAF50;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#emailHeader {
|
||||
color: #0054a2;
|
||||
}
|
||||
|
||||
#errorTableHeader {
|
||||
background-color: #0054a2;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<title>Archiver Api: Error Monitoring</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1><span id="emailHeader">Archiver Api: Error Monitoring</span></h1>
|
||||
<table id="errors">
|
||||
<thead id="errorTableHeader">
|
||||
<tr style="height: 17px;">
|
||||
<td style="max-width: 250px;font-weight: bolder;">Filename</td>
|
||||
<td style="max-width: 200px;font-weight: bolder;">File Location</td>
|
||||
<td style="max-width: 79px;font-weight: bolder;">Destination</td>
|
||||
<td style="max-width: 150px;font-weight: bolder;">Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="errorRows">
|
||||
{TableRows}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
<tr id="errorRow" style="height: 22px;">
|
||||
<td style="max-width: 250px;">{Filename}</td>
|
||||
<td style="max-width: 200px;">{FileLocation}</td>
|
||||
<td style="max-width: 79px;">{Destination}</td>
|
||||
<td style="max-width: 150px;">{Description}</td>
|
||||
</tr>
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
namespace LCU.Library.Internal.ArchiverApi.Utilities;
|
||||
|
||||
public static class HttpUtilities
|
||||
{
|
||||
private const int ParamCounterDefault = 1;
|
||||
|
||||
public static HttpClient GetClient(string url)
|
||||
{
|
||||
var handler = new HttpClientHandler
|
||||
{
|
||||
SslProtocols = System.Security.Authentication.SslProtocols.Tls12 |
|
||||
System.Security.Authentication.SslProtocols.Tls11 |
|
||||
System.Security.Authentication.SslProtocols.Tls,
|
||||
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
|
||||
};
|
||||
|
||||
var httpClient = new HttpClient(handler)
|
||||
{
|
||||
Timeout = TimeSpan.FromSeconds(60),
|
||||
BaseAddress = new Uri(url)
|
||||
};
|
||||
|
||||
return httpClient;
|
||||
}
|
||||
|
||||
public static void AppendListOfValuesToEndpoint<T>(StringBuilder endpointBuilder, int currentIndex, List<T> listOfValues, string propertyName)
|
||||
{
|
||||
foreach (var value in listOfValues)
|
||||
{
|
||||
var splitter = currentIndex == 0 ? "?" : "&";
|
||||
endpointBuilder.Append($"{splitter}{propertyName}={value}");
|
||||
currentIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"Primary": {
|
||||
"SeqUrl": "https://qa-seq.lcu-internal.com",
|
||||
"SeqApiKey": "STORED_IN_VAULT",
|
||||
"ApplicationName": "ArchiverApi",
|
||||
"NotificationApiEmail": "https://qa-notifications-api.apps.azure.lcu-internal.com/api/Email",
|
||||
"FileOperationApiBulkMoveFile": "https://localhost:44323/api/FileOperations/BulkMoveFile",
|
||||
"FileOperationApiBuildDynamicFileList": "https://qa-fileoperationsapi.lcu-internal.com/DynamicFile/BuildDynamicFileList",
|
||||
"FileOperationApiValidateFileExists": "https://qa-fileoperationsapi.lcu-internal.com/FileValidation/ValidateFileExists",
|
||||
"CoreApiWrapperGetApplicationHistory": "https://qa-core-api-wrapper-api.apps.azure.lcu-internal.com/api/core/ApplicationHistory/GetApplicationHistory",
|
||||
"DnaBasePath": "\\\\zeus\\DataIntegrationsQA\\AutomicArchive\\TEST_DNA",
|
||||
"ReportPathDateFormat": "yyyyMMdd",
|
||||
"ErrorMonitoringTemplate": "/Templates/ErrorMonitoringTemplate.html",
|
||||
"ErrorRowTemplate": "/Templates/ErrorRowTemplate.html",
|
||||
"ErrorMonitoringSubject": "Archiver Api: Error Monitoring",
|
||||
"ErrorRecipients": [ "[email protected]", "[email protected]" ],
|
||||
"TimeZone": "America/Chicago",
|
||||
"Connections": {
|
||||
"SQL": {
|
||||
"ArchiverApiDb": "data source=localhost;initial catalog=ArchiverApi;Integrated Security=SSPI;MultipleActiveResultSets=True;App=EntityFramework"
|
||||
}
|
||||
},
|
||||
"FeatureFlags": {
|
||||
"RunArchiverConsumer": true,
|
||||
"RunResponseConsumer": true
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionConfiguration": {
|
||||
"HostUrl": "localhost",
|
||||
"UserName": "guest",
|
||||
"Password": "guest"
|
||||
},
|
||||
"ArchiverReceiveEndpoint": {
|
||||
"ReceiveEndpoint": "LCU.Archiver",
|
||||
"ReceiveEndpointType": "exchange",
|
||||
"PrefetchLimit": 1
|
||||
},
|
||||
"ResponseReceiveEndpoint": {
|
||||
"ReceiveEndpoint": "LCU.Archiver.Response",
|
||||
"ReceiveEndpointType": "exchange",
|
||||
"PrefetchLimit": 1
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE [dbo].[ApplicationMapping]
|
||||
(
|
||||
[ApplicationMappingId] INT NOT NULL PRIMARY KEY IDENTITY,
|
||||
[Identifier] VARCHAR(200) NOT NULL,
|
||||
[DesignatedName] VARCHAR(200) NOT NULL,
|
||||
[ApplicationOverrideName] VARCHAR(200) NULL
|
||||
)
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
<?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="b8f0295f-1c1c-4f6c-a682-33a2ee776f0b" ChangeDateTime="08/19/2021 15:44:56">
|
||||
<Property Name="ElementName" Value="[dbo].[ParameterMapping].[Id]" />
|
||||
<Property Name="ElementType" Value="SqlSimpleColumn" />
|
||||
<Property Name="ParentElementName" Value="[dbo].[ParameterMapping]" />
|
||||
<Property Name="ParentElementType" Value="SqlTable" />
|
||||
<Property Name="NewName" Value="ParameterMappingId" />
|
||||
</Operation>
|
||||
<Operation Name="Rename Refactor" Key="418c1041-3994-4a03-b55b-f47f699ba635" ChangeDateTime="08/19/2021 17:34:45">
|
||||
<Property Name="ElementName" Value="[dbo].[ApplicationMapping].[Id]" />
|
||||
<Property Name="ElementType" Value="SqlSimpleColumn" />
|
||||
<Property Name="ParentElementName" Value="[dbo].[ApplicationMapping]" />
|
||||
<Property Name="ParentElementType" Value="SqlTable" />
|
||||
<Property Name="NewName" Value="ApplicationMappingId" />
|
||||
</Operation>
|
||||
<Operation Name="Rename Refactor" Key="dd7d86c0-4601-49a7-be99-6f6c6d94d354" ChangeDateTime="08/23/2021 14:27:16">
|
||||
<Property Name="ElementName" Value="[dbo].[ParameterMapping].[int]" />
|
||||
<Property Name="ElementType" Value="SqlSimpleColumn" />
|
||||
<Property Name="ParentElementName" Value="[dbo].[ParameterMapping]" />
|
||||
<Property Name="ParentElementType" Value="SqlTable" />
|
||||
<Property Name="NewName" Value="ParameterCode" />
|
||||
</Operation>
|
||||
<Operation Name="Rename Refactor" Key="46269fa0-779c-4ebf-9a7d-bb0581621b8d" ChangeDateTime="08/23/2021 14:27:24">
|
||||
<Property Name="ElementName" Value="[dbo].[ParameterMapping].[ApplicationMappingId]" />
|
||||
<Property Name="ElementType" Value="SqlSimpleColumn" />
|
||||
<Property Name="ParentElementName" Value="[dbo].[ParameterMapping]" />
|
||||
<Property Name="ParentElementType" Value="SqlTable" />
|
||||
<Property Name="NewName" Value="ParameterValue" />
|
||||
</Operation>
|
||||
<Operation Name="Rename Refactor" Key="b1a9f68e-8baa-4646-badd-a41829a9a37a" ChangeDateTime="08/23/2021 14:29:29">
|
||||
<Property Name="ElementName" Value="[dbo].[ParameterMapping].[varchar(2000)]" />
|
||||
<Property Name="ElementType" Value="SqlSimpleColumn" />
|
||||
<Property Name="ParentElementName" Value="[dbo].[ParameterMapping]" />
|
||||
<Property Name="ParentElementType" Value="SqlTable" />
|
||||
<Property Name="NewName" Value="ApplicationMappingId" />
|
||||
</Operation>
|
||||
</Operations>
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<Name>LCU.Api.Internal.ArchiverApiSql</Name>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectVersion>4.1</ProjectVersion>
|
||||
<ProjectGuid>{deefabec-e066-4a9b-93ad-a32482d8f03a}</ProjectGuid>
|
||||
<DSP>Microsoft.Data.Tools.Schema.Sql.Sql130DatabaseSchemaProvider</DSP>
|
||||
<OutputType>Database</OutputType>
|
||||
<RootPath>
|
||||
</RootPath>
|
||||
<RootNamespace>LCU.Api.Internal.ArchiverApiSql</RootNamespace>
|
||||
<AssemblyName>LCU.Api.Internal.ArchiverApiSql</AssemblyName>
|
||||
<ModelCollation>1033, CI</ModelCollation>
|
||||
<DefaultFileStructure>BySchemaAndSchemaType</DefaultFileStructure>
|
||||
<DeployToDatabase>True</DeployToDatabase>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<TargetLanguage>CS</TargetLanguage>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<SqlServerVerification>False</SqlServerVerification>
|
||||
<IncludeCompositeObjects>True</IncludeCompositeObjects>
|
||||
<TargetDatabaseSet>True</TargetDatabaseSet>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
|
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<DefineDebug>false</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<BuildScriptName>$(MSBuildProjectName).sql</BuildScriptName>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">11.0</VisualStudioVersion>
|
||||
<!-- Default to the v11.0 targets path if the targets file for the current VS version is not found -->
|
||||
<SSDTExists Condition="Exists('$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets')">True</SSDTExists>
|
||||
<VisualStudioVersion Condition="'$(SSDTExists)' == ''">11.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Condition="'$(SQLDBExtensionsRefPath)' != ''" Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
|
||||
<Import Condition="'$(SQLDBExtensionsRefPath)' == ''" Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets" />
|
||||
<ItemGroup>
|
||||
<Folder Include="Properties" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Build Include="ParameterMapping.sql" />
|
||||
<Build Include="ApplicationMapping.sql" />
|
||||
<Build Include="RegexMapping.sql" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<RefactorLog Include="LCU.Api.Internal.ArchiverApiSql.refactorlog" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="LCU.Api.Internal.ArchiverApiSql.publish.xml" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,8 @@
|
||||
CREATE TABLE [dbo].[ParameterMapping]
|
||||
(
|
||||
[ParameterMappingId] INT NOT NULL PRIMARY KEY IDENTITY,
|
||||
[ApplicationMappingId] INT NOT NULL,
|
||||
[ParameterCode] VARCHAR(100) NOT NULL,
|
||||
[ParameterValue] VARCHAR(2000) NULL,
|
||||
CONSTRAINT [FK_ParameterMapping_ApplicationMapping] FOREIGN KEY ([ApplicationMappingId]) REFERENCES [ApplicationMapping]([ApplicationMappingId])
|
||||
)
|
||||
@@ -0,0 +1,8 @@
|
||||
CREATE TABLE [dbo].[RegexMapping]
|
||||
(
|
||||
[RegexMappingId] INT NOT NULL PRIMARY KEY IDENTITY,
|
||||
[ApplicationMappingId] INT NOT NULL,
|
||||
[Tag] VARCHAR(100) NULL,
|
||||
[Regex] VARCHAR(2000) NULL,
|
||||
CONSTRAINT [FK_RegexMapping_ApplicationMapping] FOREIGN KEY ([ApplicationMappingId]) REFERENCES [ApplicationMapping]([ApplicationMappingId])
|
||||
)
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using LCU.Api.Internal.ArchiverApi.Controllers;
|
||||
using LCU.Api.Internal.ArchiverApi.Services;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
namespace LCU.Api.Internal.ArchiverApiTest;
|
||||
|
||||
public class QueueArchiverControllerTest
|
||||
{
|
||||
private QueueArchiverController _queueArchiverController;
|
||||
private Mock<IQueueArchiverService> _mockQueueArchiverService;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_mockQueueArchiverService = new Mock<IQueueArchiverService>();
|
||||
_queueArchiverController = new QueueArchiverController(_mockQueueArchiverService.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void QueueArchiver_OK()
|
||||
{
|
||||
var archiveRequest = new ArchiveRequest();
|
||||
_mockQueueArchiverService.Setup(x => x.QueueArchiver(archiveRequest));
|
||||
var result = _queueArchiverController.QueueArchiver(archiveRequest);
|
||||
|
||||
Assert.NotNull(result);
|
||||
var okResult = result as OkResult;
|
||||
Assert.NotNull(okResult);
|
||||
Assert.AreEqual(200, okResult.StatusCode);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void QueueArchiver_Exception()
|
||||
{
|
||||
_mockQueueArchiverService.Setup(x => x.QueueArchiver(It.IsAny<ArchiveRequest>()))
|
||||
.Throws(new Exception("Oh nooo."));
|
||||
|
||||
var archiveRequest = new ArchiveRequest();
|
||||
var results = _queueArchiverController.QueueArchiver(archiveRequest);
|
||||
|
||||
Assert.NotNull(results);
|
||||
var badRes = results as StatusCodeResult;
|
||||
Assert.NotNull(badRes);
|
||||
Assert.AreEqual(500, badRes.StatusCode);
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LCU.Library.Internal.LcuMassTransitModels" Version="1.1.0" />
|
||||
<PackageReference Include="Moq" Version="4.16.1" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LCU.Api.Internal.ArchiverApi\LCU.Api.Internal.ArchiverApi.csproj" />
|
||||
<ProjectReference Include="..\LCU.Library.Internal.ArchiverApiModel\LCU.Library.Internal.ArchiverApiModel.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using LCU.Api.Internal.ArchiverApi.Services;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models.NameSettings;
|
||||
using LCU.Library.Internal.FileOperationsModels.Models;
|
||||
using LCU.Api.Internal.ArchiverApi.Configuration;
|
||||
using LCU.Library.Internal.LcuMassTransitModels;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
namespace LCU.Api.Internal.ArchiverApiTest;
|
||||
|
||||
public class ArchiverServiceTest
|
||||
{
|
||||
private ArchiverService _archiverService;
|
||||
private Mock<IReportService> _mockReportService;
|
||||
private Mock<IFileOperationsService> _mockFileOperationsService;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var config = new ArchiverApiConfig()
|
||||
{
|
||||
ReportPathDateFormat = "yyyyMMdd"
|
||||
};
|
||||
var connectionConfig = new ConnectionConfiguration();
|
||||
var receiveEndpointConfigurations = new ReceiveEndpointConfigurations();
|
||||
|
||||
_mockReportService = new Mock<IReportService>();
|
||||
_mockFileOperationsService = new Mock<IFileOperationsService>();
|
||||
_archiverService = new ArchiverService(config,
|
||||
_mockReportService.Object,
|
||||
_mockFileOperationsService.Object,
|
||||
connectionConfig,
|
||||
receiveEndpointConfigurations);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BuildRegexString_WithLisAndCsv()
|
||||
{
|
||||
var archiveRequest = new ArchiveRequest()
|
||||
{
|
||||
AllowedExensions = new List<string>() { "lis", "csv" }
|
||||
};
|
||||
|
||||
var result = _archiverService.BuildExtensionRegexString(archiveRequest);
|
||||
Assert.AreEqual("((?i)lis(?-i)|(?i)csv(?-i)|)$", result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateOperationRequests_CreateTwoRequests()
|
||||
{
|
||||
|
||||
var report = new Report()
|
||||
{
|
||||
ReportName = "test",
|
||||
ApplicationMapping = new ApplicationMapping()
|
||||
{
|
||||
DesignatedName = null
|
||||
}
|
||||
};
|
||||
var dynamicNameSetting = new DynamicNameSetting();
|
||||
var archiveRequest = new ArchiveRequest()
|
||||
{
|
||||
AllowedExensions = new List<string>() { "lis", "csv" }
|
||||
};
|
||||
var files = new List<string>() { "test1", "test2" };
|
||||
_mockFileOperationsService.Setup(x => x.BuildDynamicFileListAsync(It.IsAny<string>(), It.IsAny<string>(), dynamicNameSetting)).ReturnsAsync(files);
|
||||
|
||||
var results = _archiverService.CreateOperationRequests(report, dynamicNameSetting, archiveRequest);
|
||||
Assert.NotNull(results);
|
||||
Assert.AreEqual(2, results.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetDestinationName_SetCorrectDestination()
|
||||
{
|
||||
var testReport = new Report()
|
||||
{
|
||||
ReportName = "Test",
|
||||
QueueNumber = "1234",
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021"),
|
||||
ApplicationMapping = new ApplicationMapping()
|
||||
};
|
||||
|
||||
var testRequest = new MoveFileRequest()
|
||||
{
|
||||
SourceFile = "Test.lis"
|
||||
};
|
||||
|
||||
var archiveRequest = new ArchiveRequest()
|
||||
{
|
||||
AllowedExensions = new List<string>() { "lis", "csv" }
|
||||
};
|
||||
|
||||
_archiverService.SetDestinationName(testReport, testRequest, archiveRequest);
|
||||
|
||||
Assert.NotNull(testRequest);
|
||||
Assert.NotNull(testRequest.DestinationName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetDestinationName_ExtentionNotSupported_DestinationNameNull()
|
||||
{
|
||||
var testReport = new Report()
|
||||
{
|
||||
ReportName = "Test",
|
||||
QueueNumber = "1234",
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021")
|
||||
};
|
||||
|
||||
var testRequest = new MoveFileRequest()
|
||||
{
|
||||
SourceFile = "Test.txt"
|
||||
};
|
||||
|
||||
var archiveRequest = new ArchiveRequest()
|
||||
{
|
||||
AllowedExensions = new List<string>() { "lis", "csv" }
|
||||
};
|
||||
|
||||
_archiverService.SetDestinationName(testReport, testRequest, archiveRequest);
|
||||
|
||||
Assert.NotNull(testRequest);
|
||||
Assert.Null(testRequest.DestinationName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetUpNameSettings_NoApplicationMapping()
|
||||
{
|
||||
var testReport = new Report()
|
||||
{
|
||||
ReportName = "Test",
|
||||
QueueNumber = "1234",
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021"),
|
||||
};
|
||||
|
||||
var nameSettings = _archiverService.SetUpNameSettings(testReport);
|
||||
|
||||
Assert.NotNull(nameSettings);
|
||||
Assert.AreEqual(nameSettings.RegexSettings.Count, 2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetUpNameSettings_HasApplicationMapping()
|
||||
{
|
||||
var testReport = new Report()
|
||||
{
|
||||
ReportName = "Test",
|
||||
QueueNumber = "1234",
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021"),
|
||||
ApplicationMapping = new ApplicationMapping()
|
||||
{
|
||||
RegexMappings = new List<RegexMapping>
|
||||
{
|
||||
new RegexMapping()
|
||||
{
|
||||
Tag = "{Regex10}",
|
||||
Regex = "[0-9]"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var nameSettings = _archiverService.SetUpNameSettings(testReport);
|
||||
|
||||
Assert.NotNull(nameSettings);
|
||||
Assert.AreEqual(nameSettings.RegexSettings.Count, 3);
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using LCU.Api.Internal.ArchiverApi.Services;
|
||||
using LCU.Api.Internal.ArchiverApi.Configuration;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.CoreRequests;
|
||||
namespace LCU.Api.Internal.ArchiverApiTest;
|
||||
|
||||
public class CoreApiWrapperServiceTest
|
||||
{
|
||||
private CoreApiWrapperService _coreApiWrapperService;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var archiveApiConfig = new ArchiverApiConfig()
|
||||
{
|
||||
CoreApiWrapperGetApplicationHistory = "https://TEST/GetApplicationHistory"
|
||||
};
|
||||
_coreApiWrapperService = new CoreApiWrapperService(archiveApiConfig);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void SetUpEndpoint_SetCorrect()
|
||||
{
|
||||
var applicationHistoryRequest = new ApplicationHistoryRequest()
|
||||
{
|
||||
ApplicationNumbers = new List<string> { "1", "2" },
|
||||
EffectiveDate = Convert.ToDateTime("1/1/2021").ToString()
|
||||
};
|
||||
|
||||
var request = _coreApiWrapperService.SetUpUrl(applicationHistoryRequest);
|
||||
|
||||
Assert.NotNull(request);
|
||||
var testUrl = $"https://TEST/GetApplicationHistory?ApplicationNumbers=1&ApplicationNumbers=2&" +
|
||||
"EffectiveDate=" + Convert.ToDateTime("1/1/2021").ToString();
|
||||
Assert.AreEqual(testUrl, request);
|
||||
}
|
||||
}
|
||||
+280
@@ -0,0 +1,280 @@
|
||||
using LCU.Api.Internal.ArchiverApi.Services;
|
||||
using LCU.Library.Internal.ArchiverApiLib.Repositories;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Api.Internal.ArchiverApiTest.Services
|
||||
{
|
||||
public class RegexMappingServiceTest
|
||||
{
|
||||
private Mock<IUnitOfWork> mockUnitOfWork;
|
||||
private Mock<IRegexMappingRepository> mockRegexMappingRepository;
|
||||
|
||||
private RegexMappingService service;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
mockUnitOfWork = new Mock<IUnitOfWork>();
|
||||
mockRegexMappingRepository = new Mock<IRegexMappingRepository>();
|
||||
|
||||
service = new RegexMappingService(
|
||||
mockUnitOfWork.Object, mockRegexMappingRepository.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Post_Success()
|
||||
{
|
||||
mockRegexMappingRepository.Setup(repository => repository.AddAsync(It.IsAny<RegexMapping>()))
|
||||
.ReturnsAsync(new RegexMapping()
|
||||
{
|
||||
RegexMappingId = 1,
|
||||
ApplicationMappingId = 1,
|
||||
Tag = "{Regex5}",
|
||||
Regex = "[0-9]"
|
||||
})
|
||||
.Verifiable();
|
||||
|
||||
var regexMappingResponse = await service.SaveAsync(new RegexMapping()
|
||||
{
|
||||
ApplicationMappingId = 1,
|
||||
Tag = "{Regex5}",
|
||||
Regex = "[0-9]"
|
||||
});
|
||||
|
||||
Assert.NotNull(regexMappingResponse);
|
||||
|
||||
Assert.NotZero(regexMappingResponse.RegexMappingId);
|
||||
Assert.AreEqual(1, regexMappingResponse.ApplicationMappingId);
|
||||
Assert.AreEqual("{Regex5}", regexMappingResponse.Tag);
|
||||
Assert.AreEqual("[0-9]", regexMappingResponse.Regex);
|
||||
|
||||
mockUnitOfWork.Verify(x => x.CompleteAsync(), Times.Once);
|
||||
mockRegexMappingRepository.Verify(x => x.AddAsync(It.IsAny<RegexMapping>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Post_InvalidTag()
|
||||
{
|
||||
Assert.ThrowsAsync<ServiceException>(async () =>
|
||||
await service.SaveAsync(new RegexMapping()
|
||||
{
|
||||
ApplicationMappingId = 1,
|
||||
Tag = "{Regex1}",
|
||||
Regex = "[0-9]"
|
||||
}));
|
||||
|
||||
mockUnitOfWork.Verify(x => x.CompleteAsync(), Times.Never);
|
||||
mockRegexMappingRepository.Verify(x => x.AddAsync(It.IsAny<RegexMapping>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Post_Exception()
|
||||
{
|
||||
mockRegexMappingRepository.Setup(repository => repository.AddAsync(It.IsAny<RegexMapping>()))
|
||||
.ThrowsAsync(new Exception("Test")).Verifiable();
|
||||
|
||||
Assert.ThrowsAsync<ServiceException>(async () =>
|
||||
await service.SaveAsync(new RegexMapping()
|
||||
{
|
||||
ApplicationMappingId = 1,
|
||||
Tag = "{Regex5}",
|
||||
Regex = "[0-9]"
|
||||
}));
|
||||
|
||||
mockUnitOfWork.Verify(x => x.CompleteAsync(), Times.Never);
|
||||
mockRegexMappingRepository.Verify(x => x.AddAsync(It.IsAny<RegexMapping>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetByApplicationMappingId_Success()
|
||||
{
|
||||
mockRegexMappingRepository.Setup(repository => repository.FindByApplicationMappingIdAsync(It.IsAny<int>()))
|
||||
.ReturnsAsync(new RegexMapping()
|
||||
{
|
||||
RegexMappingId = 1,
|
||||
ApplicationMappingId = 1,
|
||||
Tag = "{Regex5}",
|
||||
Regex = "[0-9]"
|
||||
});
|
||||
|
||||
var regexMappingResponse = await service.GetByApplicationMappingIdAsync(1);
|
||||
|
||||
Assert.NotNull(regexMappingResponse);
|
||||
|
||||
Assert.NotZero(regexMappingResponse.RegexMappingId);
|
||||
Assert.AreEqual(1, regexMappingResponse.ApplicationMappingId);
|
||||
Assert.AreEqual("{Regex5}", regexMappingResponse.Tag);
|
||||
Assert.AreEqual("[0-9]", regexMappingResponse.Regex);
|
||||
|
||||
mockRegexMappingRepository.Verify(x => x.FindByApplicationMappingIdAsync(It.IsAny<int>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetByApplicationMappingId_Exception()
|
||||
{
|
||||
mockRegexMappingRepository.Setup(repository => repository.FindByRegexMappingIdAsync(It.IsAny<int>()))
|
||||
.ThrowsAsync(new Exception("Test")).Verifiable();
|
||||
|
||||
Assert.ThrowsAsync<ServiceException>(async () =>
|
||||
await service.GetByApplicationMappingIdAsync(1));
|
||||
|
||||
mockRegexMappingRepository.Verify(x => x.FindByApplicationMappingIdAsync(It.IsAny<int>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task GetByregexMappingId_Success()
|
||||
{
|
||||
mockRegexMappingRepository.Setup(repository => repository.FindByRegexMappingIdAsync(It.IsAny<int>()))
|
||||
.ReturnsAsync(new RegexMapping()
|
||||
{
|
||||
RegexMappingId = 1,
|
||||
ApplicationMappingId = 1,
|
||||
Tag = "{Regex5}",
|
||||
Regex = "[0-9]"
|
||||
});
|
||||
|
||||
var regexMappingResponse = await service.GetByRegexMappingIdAsync(1);
|
||||
|
||||
Assert.NotNull(regexMappingResponse);
|
||||
|
||||
Assert.NotZero(regexMappingResponse.RegexMappingId);
|
||||
Assert.AreEqual(1, regexMappingResponse.ApplicationMappingId);
|
||||
Assert.AreEqual("{Regex5}", regexMappingResponse.Tag);
|
||||
Assert.AreEqual("[0-9]", regexMappingResponse.Regex);
|
||||
|
||||
mockRegexMappingRepository.Verify(x => x.FindByRegexMappingIdAsync(It.IsAny<int>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetByRegexMappingId_Exception()
|
||||
{
|
||||
mockRegexMappingRepository.Setup(repository => repository.FindByRegexMappingIdAsync(It.IsAny<int>()))
|
||||
.ThrowsAsync(new Exception("Test")).Verifiable();
|
||||
|
||||
Assert.ThrowsAsync<ServiceException>(async () =>
|
||||
await service.GetByRegexMappingIdAsync(1));
|
||||
|
||||
mockUnitOfWork.Verify(x => x.CompleteAsync(), Times.Never);
|
||||
mockRegexMappingRepository.Verify(x => x.FindByRegexMappingIdAsync(It.IsAny<int>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Update_Success()
|
||||
{
|
||||
var originalRegex = new RegexMapping()
|
||||
{
|
||||
RegexMappingId = 1,
|
||||
ApplicationMappingId = 1,
|
||||
Tag = "{Regex5}",
|
||||
Regex = "[0-9]"
|
||||
};
|
||||
|
||||
var updatedRegex = new RegexMapping()
|
||||
{
|
||||
RegexMappingId = 1,
|
||||
ApplicationMappingId = 2,
|
||||
Tag = "{Regex50}",
|
||||
Regex = "[0-9]*"
|
||||
};
|
||||
|
||||
mockRegexMappingRepository.Setup(repository => repository.FindByRegexMappingIdAsync(It.IsAny<int>()))
|
||||
.ReturnsAsync((RegexMapping)originalRegex).Verifiable();
|
||||
|
||||
var regexMappingResponse = service.Update(updatedRegex);
|
||||
|
||||
Assert.NotNull(regexMappingResponse);
|
||||
|
||||
Assert.AreEqual(regexMappingResponse.RegexMappingId, originalRegex.RegexMappingId);
|
||||
Assert.AreEqual(regexMappingResponse.ApplicationMappingId, updatedRegex.ApplicationMappingId);
|
||||
Assert.AreEqual(regexMappingResponse.Tag, updatedRegex.Tag);
|
||||
Assert.AreEqual(regexMappingResponse.Regex, updatedRegex.Regex);
|
||||
|
||||
mockRegexMappingRepository.Verify(x => x.FindByRegexMappingIdAsync(It.IsAny<int>()), Times.Once());
|
||||
mockUnitOfWork.Verify(x => x.Complete(), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Update_InvalidTag()
|
||||
{
|
||||
Assert.ThrowsAsync<ServiceException>(async () =>
|
||||
await service.SaveAsync(new RegexMapping()
|
||||
{
|
||||
ApplicationMappingId = 1,
|
||||
Tag = "{Regex1}",
|
||||
Regex = "[0-9]"
|
||||
}));
|
||||
|
||||
mockUnitOfWork.Verify(x => x.CompleteAsync(), Times.Never);
|
||||
mockRegexMappingRepository.Verify(x => x.AddAsync(It.IsAny<RegexMapping>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Update_Exception()
|
||||
{
|
||||
var updatedRegex = new RegexMapping()
|
||||
{
|
||||
RegexMappingId = 1,
|
||||
ApplicationMappingId = 2,
|
||||
Tag = "{Regex50}",
|
||||
Regex = "[0-9]*"
|
||||
};
|
||||
|
||||
mockRegexMappingRepository.Setup(repository => repository.FindByRegexMappingIdAsync(It.IsAny<int>()))
|
||||
.ThrowsAsync(new Exception("Test")).Verifiable();
|
||||
|
||||
Assert.Throws<ServiceException>(() =>
|
||||
service.Update(updatedRegex));
|
||||
|
||||
mockUnitOfWork.Verify(x => x.CompleteAsync(), Times.Never);
|
||||
mockRegexMappingRepository.Verify(x => x.FindByRegexMappingIdAsync(It.IsAny<int>()), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Delete_Success()
|
||||
{
|
||||
mockRegexMappingRepository.Setup(repository => repository.FindByRegexMappingIdAsync(It.IsAny<int>()))
|
||||
.ReturnsAsync(new RegexMapping()
|
||||
{
|
||||
RegexMappingId = 1,
|
||||
ApplicationMappingId = 1,
|
||||
Tag = "{Regex5}",
|
||||
Regex = "[0-9]"
|
||||
})
|
||||
.Verifiable();
|
||||
|
||||
mockRegexMappingRepository.Setup(repository => repository.Remove(It.IsAny<RegexMapping>()))
|
||||
.Verifiable();
|
||||
|
||||
service.DeleteAsync(1);
|
||||
|
||||
mockRegexMappingRepository.Verify(x => x.FindByRegexMappingIdAsync(It.IsAny<int>()), Times.Once());
|
||||
mockUnitOfWork.Verify(x => x.Complete(), Times.Once());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Delete_Exception()
|
||||
{
|
||||
var deleteRegex = new RegexMapping()
|
||||
{
|
||||
RegexMappingId = 1,
|
||||
ApplicationMappingId = 2,
|
||||
Tag = "{Regex5}",
|
||||
Regex = "[0-9]*"
|
||||
};
|
||||
|
||||
mockRegexMappingRepository.Setup(repository => repository.FindByRegexMappingIdAsync(It.IsAny<int>()))
|
||||
.ThrowsAsync(new Exception("Test")).Verifiable();
|
||||
|
||||
Assert.Throws<ServiceException>(() =>
|
||||
service.Update(deleteRegex));
|
||||
|
||||
mockUnitOfWork.Verify(x => x.CompleteAsync(), Times.Never);
|
||||
mockRegexMappingRepository.Verify(x => x.FindByRegexMappingIdAsync(It.IsAny<int>()), Times.Once());
|
||||
}
|
||||
}
|
||||
}
|
||||
+597
@@ -0,0 +1,597 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using LCU.Api.Internal.ArchiverApi.Services;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Models;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
using LCU.Library.Internal.CoreApiWrapperModel.CoreModels.ApplicationHistories;
|
||||
namespace LCU.Api.Internal.ArchiverApiTest;
|
||||
|
||||
public class ReportServiceTest
|
||||
{
|
||||
private ReportService _reportService;
|
||||
private Mock<ICoreApiWrapperService> _mockCoreApiWrapperService;
|
||||
private Mock<IApplicationMappingService> _mockApplicationMappingService;
|
||||
private Mock<IRegexMappingService> _mockRegexMappingService;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_mockCoreApiWrapperService = new Mock<ICoreApiWrapperService>();
|
||||
_mockApplicationMappingService = new Mock<IApplicationMappingService>();
|
||||
_mockRegexMappingService = new Mock<IRegexMappingService>();
|
||||
_reportService = new ReportService(_mockCoreApiWrapperService.Object, _mockApplicationMappingService.Object, _mockRegexMappingService.Object);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetReportsToArchive_OK()
|
||||
{
|
||||
var testReports = new List<Report>()
|
||||
{
|
||||
new Report()
|
||||
{
|
||||
ReportName = "Test",
|
||||
QueueNumber = "1234",
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021")
|
||||
}
|
||||
};
|
||||
var archiveRequest = new ArchiveRequest();
|
||||
var applicationHistories = new List<ApplicationHistory>()
|
||||
{
|
||||
new ApplicationHistory()
|
||||
{
|
||||
ApplicationName = "Test",
|
||||
ApplicationNumber = 1,
|
||||
QueueNumber = 1234,
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021")
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetApplicationHistories(archiveRequest)).ReturnsAsync(applicationHistories);
|
||||
|
||||
var result = _reportService.GetReportsToArchiveAsync(archiveRequest).Result;
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual("Test", result.FirstOrDefault().ReportName);
|
||||
Assert.AreEqual("1234", result.FirstOrDefault().QueueNumber);
|
||||
Assert.AreEqual(Convert.ToDateTime("1/1/2021"), result.FirstOrDefault().StopDateTime);
|
||||
Assert.AreEqual("Test", result.FirstOrDefault().DisplayReportName);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetReportsToArchive_DispalyReportName_FromApplicationMapping()
|
||||
{
|
||||
var testApplicationMapping1 = new ApplicationMapping()
|
||||
{
|
||||
Identifier = "1",
|
||||
DesignatedName = "Test_NEW_1",
|
||||
ParameterMappings = new List<ParameterMapping>()
|
||||
{
|
||||
new ParameterMapping()
|
||||
{
|
||||
ParameterCode = "TestingCode",
|
||||
ParameterValue = "TestingParameterValue"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var testApplicationMapping2 = new ApplicationMapping()
|
||||
{
|
||||
Identifier = "1",
|
||||
DesignatedName = "Test_NEW",
|
||||
ParameterMappings = new List<ParameterMapping>()
|
||||
{
|
||||
new ParameterMapping()
|
||||
{
|
||||
ParameterCode = "TestingCode2",
|
||||
ParameterValue = "TestingParameterValue2"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var applicationMappings = new List<ApplicationMapping>()
|
||||
{
|
||||
testApplicationMapping1,
|
||||
testApplicationMapping2
|
||||
};
|
||||
|
||||
var testReports = new List<Report>()
|
||||
{
|
||||
new Report()
|
||||
{
|
||||
ReportName = "Test",
|
||||
QueueNumber = "1234",
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021")
|
||||
}
|
||||
};
|
||||
var archiveRequest = new ArchiveRequest();
|
||||
var applicationHistories = new List<ApplicationHistory>()
|
||||
{
|
||||
new ApplicationHistory()
|
||||
{
|
||||
ApplicationName = "Test",
|
||||
ApplicationNumber = 1,
|
||||
QueueNumber = 1234,
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021"),
|
||||
QueueApplicationParameters = new List<QueueApplicationParameter>()
|
||||
{
|
||||
new QueueApplicationParameter()
|
||||
{
|
||||
QueueNumber = 1234,
|
||||
ApplicationNumber = 1,
|
||||
ParameterCode = "TestingCode",
|
||||
ParameterValue = "TestingParameterValue"
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetApplicationHistories(archiveRequest)).ReturnsAsync(applicationHistories);
|
||||
_mockApplicationMappingService.Setup(x => x.GetAsync()).ReturnsAsync(applicationMappings);
|
||||
|
||||
var result = _reportService.GetReportsToArchiveAsync(archiveRequest).Result;
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual("Test", result.FirstOrDefault().ReportName);
|
||||
Assert.AreEqual("1234", result.FirstOrDefault().QueueNumber);
|
||||
Assert.AreEqual(Convert.ToDateTime("1/1/2021"), result.FirstOrDefault().StopDateTime);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetReportsToArchive_Exception()
|
||||
{
|
||||
var archiveRequest = new ArchiveRequest();
|
||||
_mockCoreApiWrapperService.Setup(x => x.GetApplicationHistories(archiveRequest)).Throws(new Exception("Error"));
|
||||
Assert.ThrowsAsync<Exception>(() => _reportService.GetReportsToArchiveAsync(archiveRequest));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeteriminApplicationMapping_Return_CorrectApplicationMapping1()
|
||||
{
|
||||
var testApplicationMapping1 = new ApplicationMapping()
|
||||
{
|
||||
Identifier = "1",
|
||||
DesignatedName = "Test_NEW",
|
||||
ParameterMappings = new List<ParameterMapping>()
|
||||
{
|
||||
new ParameterMapping()
|
||||
{
|
||||
ParameterCode = "TestingCode",
|
||||
ParameterValue = "TestingParameterValue"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var testApplicationMapping2 = new ApplicationMapping()
|
||||
{
|
||||
Identifier = "1",
|
||||
DesignatedName = "Test_NEW",
|
||||
ParameterMappings = new List<ParameterMapping>()
|
||||
{
|
||||
new ParameterMapping()
|
||||
{
|
||||
ParameterCode = "TestingCode2",
|
||||
ParameterValue = "TestingParameterValue2"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
List<ApplicationMapping> applicationMappings = new List<ApplicationMapping>()
|
||||
{
|
||||
testApplicationMapping1,
|
||||
testApplicationMapping2
|
||||
};
|
||||
|
||||
ApplicationHistory applicationHistory = new ApplicationHistory()
|
||||
{
|
||||
ApplicationName = "Test",
|
||||
ApplicationNumber = 1,
|
||||
QueueNumber = 1234,
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021"),
|
||||
QueueApplicationParameters = new List<QueueApplicationParameter>()
|
||||
{
|
||||
new QueueApplicationParameter()
|
||||
{
|
||||
QueueNumber = 1234,
|
||||
ApplicationNumber = 1,
|
||||
ParameterCode = "TestingCode",
|
||||
ParameterValue = "TestingParameterValue"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var result = _reportService.DeteriminApplicationMapping(applicationMappings, applicationHistory);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testApplicationMapping1, result);
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void DeteriminApplicationMapping_Return_testApplicationMapping1_MatchBothParameters()
|
||||
{
|
||||
var testApplicationMapping1 = new ApplicationMapping()
|
||||
{
|
||||
Identifier = "1",
|
||||
DesignatedName = "Test_NEW",
|
||||
ParameterMappings = new List<ParameterMapping>()
|
||||
{
|
||||
new ParameterMapping()
|
||||
{
|
||||
ParameterCode = "TestingCode",
|
||||
ParameterValue = "TestingParameterValue"
|
||||
},
|
||||
new ParameterMapping()
|
||||
{
|
||||
ParameterCode = "TestingCode2",
|
||||
ParameterValue = "TestingParameterValue2"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var testApplicationMapping2 = new ApplicationMapping()
|
||||
{
|
||||
Identifier = "1",
|
||||
DesignatedName = "Test_NEW",
|
||||
ParameterMappings = new List<ParameterMapping>()
|
||||
{
|
||||
new ParameterMapping()
|
||||
{
|
||||
ParameterCode = "TestingCode2",
|
||||
ParameterValue = "TestingParameterValue2"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
List<ApplicationMapping> applicationMappings = new List<ApplicationMapping>()
|
||||
{
|
||||
testApplicationMapping1,
|
||||
testApplicationMapping2
|
||||
};
|
||||
|
||||
ApplicationHistory applicationHistory = new ApplicationHistory()
|
||||
{
|
||||
ApplicationName = "Test",
|
||||
ApplicationNumber = 1,
|
||||
QueueNumber = 1234,
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021"),
|
||||
QueueApplicationParameters = new List<QueueApplicationParameter>()
|
||||
{
|
||||
new QueueApplicationParameter()
|
||||
{
|
||||
QueueNumber = 1234,
|
||||
ApplicationNumber = 1,
|
||||
ParameterCode = "TestingCode",
|
||||
ParameterValue = "TestingParameterValue"
|
||||
},
|
||||
new QueueApplicationParameter()
|
||||
{
|
||||
QueueNumber = 1234,
|
||||
ApplicationNumber = 1,
|
||||
ParameterCode = "TestingCode2",
|
||||
ParameterValue = "TestingParameterValue2"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var result = _reportService.DeteriminApplicationMapping(applicationMappings, applicationHistory);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testApplicationMapping1, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeteriminApplicationMapping_Return_Null_ParameterCodeNoMatch()
|
||||
{
|
||||
var testApplicationMapping1 = new ApplicationMapping()
|
||||
{
|
||||
Identifier = "1",
|
||||
DesignatedName = "Test_NEW",
|
||||
ParameterMappings = new List<ParameterMapping>()
|
||||
{
|
||||
new ParameterMapping()
|
||||
{
|
||||
ParameterCode = "TestingCode",
|
||||
ParameterValue = "TestingParameterValue"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var testApplicationMapping2 = new ApplicationMapping()
|
||||
{
|
||||
Identifier = "1",
|
||||
DesignatedName = "Test_NEW",
|
||||
ParameterMappings = new List<ParameterMapping>()
|
||||
{
|
||||
new ParameterMapping()
|
||||
{
|
||||
ParameterCode = "TestingCode2",
|
||||
ParameterValue = "TestingParameterValue2"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
List<ApplicationMapping> applicationMappings = new List<ApplicationMapping>()
|
||||
{
|
||||
testApplicationMapping1,
|
||||
testApplicationMapping2
|
||||
};
|
||||
|
||||
ApplicationHistory applicationHistory = new ApplicationHistory()
|
||||
{
|
||||
ApplicationName = "Test",
|
||||
ApplicationNumber = 1,
|
||||
QueueNumber = 1234,
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021"),
|
||||
QueueApplicationParameters = new List<QueueApplicationParameter>()
|
||||
{
|
||||
new QueueApplicationParameter()
|
||||
{
|
||||
QueueNumber = 1234,
|
||||
ApplicationNumber = 1,
|
||||
ParameterCode = "TestingCode_NOPE",
|
||||
ParameterValue = "TestingParameterValue"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var result = _reportService.DeteriminApplicationMapping(applicationMappings, applicationHistory);
|
||||
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeteriminApplicationMapping_Return_Null_ParameterValueNoMatch()
|
||||
{
|
||||
var testApplicationMapping1 = new ApplicationMapping()
|
||||
{
|
||||
Identifier = "1",
|
||||
DesignatedName = "Test_NEW",
|
||||
ParameterMappings = new List<ParameterMapping>()
|
||||
{
|
||||
new ParameterMapping()
|
||||
{
|
||||
ParameterCode = "TestingCode",
|
||||
ParameterValue = "TestingParameterValue"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var testApplicationMapping2 = new ApplicationMapping()
|
||||
{
|
||||
Identifier = "1",
|
||||
DesignatedName = "Test_NEW",
|
||||
ParameterMappings = new List<ParameterMapping>()
|
||||
{
|
||||
new ParameterMapping()
|
||||
{
|
||||
ParameterCode = "TestingCode2",
|
||||
ParameterValue = "TestingParameterValue2"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
List<ApplicationMapping> applicationMappings = new List<ApplicationMapping>()
|
||||
{
|
||||
testApplicationMapping1,
|
||||
testApplicationMapping2
|
||||
};
|
||||
|
||||
ApplicationHistory applicationHistory = new ApplicationHistory()
|
||||
{
|
||||
ApplicationName = "Test",
|
||||
ApplicationNumber = 1,
|
||||
QueueNumber = 1234,
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021"),
|
||||
QueueApplicationParameters = new List<QueueApplicationParameter>()
|
||||
{
|
||||
new QueueApplicationParameter()
|
||||
{
|
||||
QueueNumber = 1234,
|
||||
ApplicationNumber = 1,
|
||||
ParameterCode = "TestingCode",
|
||||
ParameterValue = "TestingParameterValue_NOPE"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var result = _reportService.DeteriminApplicationMapping(applicationMappings, applicationHistory);
|
||||
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeteriminApplicationMapping_Return_Null_DoesNotMatchBothParameters()
|
||||
{
|
||||
var testApplicationMapping1 = new ApplicationMapping()
|
||||
{
|
||||
Identifier = "1",
|
||||
DesignatedName = "Test_NEW",
|
||||
ParameterMappings = new List<ParameterMapping>()
|
||||
{
|
||||
new ParameterMapping()
|
||||
{
|
||||
ParameterCode = "TestingCode",
|
||||
ParameterValue = "TestingParameterValue"
|
||||
},
|
||||
new ParameterMapping()
|
||||
{
|
||||
ParameterCode = "TestingCode2",
|
||||
ParameterValue = "TestingParameterValue2"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var testApplicationMapping2 = new ApplicationMapping()
|
||||
{
|
||||
Identifier = "1",
|
||||
DesignatedName = "Test_NEW",
|
||||
ParameterMappings = new List<ParameterMapping>()
|
||||
{
|
||||
new ParameterMapping()
|
||||
{
|
||||
ParameterCode = "TestingCode2",
|
||||
ParameterValue = "TestingParameterValue2"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
List<ApplicationMapping> applicationMappings = new List<ApplicationMapping>()
|
||||
{
|
||||
testApplicationMapping1,
|
||||
testApplicationMapping2
|
||||
};
|
||||
|
||||
ApplicationHistory applicationHistory = new ApplicationHistory()
|
||||
{
|
||||
ApplicationName = "Test",
|
||||
ApplicationNumber = 1,
|
||||
QueueNumber = 1234,
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021"),
|
||||
QueueApplicationParameters = new List<QueueApplicationParameter>()
|
||||
{
|
||||
new QueueApplicationParameter()
|
||||
{
|
||||
QueueNumber = 1234,
|
||||
ApplicationNumber = 1,
|
||||
ParameterCode = "TestingCode",
|
||||
ParameterValue = "TestingParameterValue"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var result = _reportService.DeteriminApplicationMapping(applicationMappings, applicationHistory);
|
||||
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeteriminApplicationMapping_Return_SingleWithParameters_CorrectApplicationMapping1()
|
||||
{
|
||||
var testApplicationMapping1 = new ApplicationMapping()
|
||||
{
|
||||
Identifier = "1",
|
||||
DesignatedName = "Test_NEW",
|
||||
ParameterMappings = new List<ParameterMapping>()
|
||||
{
|
||||
new ParameterMapping()
|
||||
{
|
||||
ParameterCode = "TestingCode",
|
||||
ParameterValue = "TestingParameterValue"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
List<ApplicationMapping> applicationMappings = new List<ApplicationMapping>()
|
||||
{
|
||||
testApplicationMapping1
|
||||
};
|
||||
|
||||
ApplicationHistory applicationHistory = new ApplicationHistory()
|
||||
{
|
||||
ApplicationName = "Test",
|
||||
ApplicationNumber = 1,
|
||||
QueueNumber = 1234,
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021"),
|
||||
QueueApplicationParameters = new List<QueueApplicationParameter>()
|
||||
{
|
||||
new QueueApplicationParameter()
|
||||
{
|
||||
QueueNumber = 1234,
|
||||
ApplicationNumber = 1,
|
||||
ParameterCode = "TestingCode",
|
||||
ParameterValue = "TestingParameterValue"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var result = _reportService.DeteriminApplicationMapping(applicationMappings, applicationHistory);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testApplicationMapping1, result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeteriminApplicationMapping_Return_SingleWithParameters_NoMatch_Null()
|
||||
{
|
||||
var testApplicationMapping1 = new ApplicationMapping()
|
||||
{
|
||||
Identifier = "1",
|
||||
DesignatedName = "Test_NEW",
|
||||
ParameterMappings = new List<ParameterMapping>()
|
||||
{
|
||||
new ParameterMapping()
|
||||
{
|
||||
ParameterCode = "TestingCode_NoMatch",
|
||||
ParameterValue = "TestingParameterValue"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
List<ApplicationMapping> applicationMappings = new List<ApplicationMapping>()
|
||||
{
|
||||
testApplicationMapping1
|
||||
};
|
||||
|
||||
ApplicationHistory applicationHistory = new ApplicationHistory()
|
||||
{
|
||||
ApplicationName = "Test",
|
||||
ApplicationNumber = 1,
|
||||
QueueNumber = 1234,
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021"),
|
||||
QueueApplicationParameters = new List<QueueApplicationParameter>()
|
||||
{
|
||||
new QueueApplicationParameter()
|
||||
{
|
||||
QueueNumber = 1234,
|
||||
ApplicationNumber = 1,
|
||||
ParameterCode = "TestingCode",
|
||||
ParameterValue = "TestingParameterValue"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var result = _reportService.DeteriminApplicationMapping(applicationMappings, applicationHistory);
|
||||
|
||||
Assert.Null(result);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DeteriminApplicationMapping_Return_SingleWithOutParameters_CorrectApplicationMapping1()
|
||||
{
|
||||
var testApplicationMapping1 = new ApplicationMapping()
|
||||
{
|
||||
Identifier = "1",
|
||||
DesignatedName = "Test_NEW",
|
||||
ApplicationOverrideName = "Test-File"
|
||||
};
|
||||
|
||||
List<ApplicationMapping> applicationMappings = new List<ApplicationMapping>()
|
||||
{
|
||||
testApplicationMapping1
|
||||
};
|
||||
|
||||
ApplicationHistory applicationHistory = new ApplicationHistory()
|
||||
{
|
||||
ApplicationName = "Test",
|
||||
ApplicationNumber = 1,
|
||||
QueueNumber = 1234,
|
||||
StopDateTime = Convert.ToDateTime("1/1/2021"),
|
||||
QueueApplicationParameters = new List<QueueApplicationParameter>()
|
||||
{
|
||||
new QueueApplicationParameter()
|
||||
{
|
||||
QueueNumber = 1234,
|
||||
ApplicationNumber = 1,
|
||||
ParameterCode = "TestingCode",
|
||||
ParameterValue = "TestingParameterValue"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var result = _reportService.DeteriminApplicationMapping(applicationMappings, applicationHistory);
|
||||
|
||||
Assert.NotNull(result);
|
||||
Assert.AreEqual(testApplicationMapping1, result);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiLib.Extensions
|
||||
{
|
||||
public static class QueryableIncludeAll
|
||||
{
|
||||
public static IQueryable<ApplicationMapping> IncludeAll(this IQueryable<ApplicationMapping> queryable)
|
||||
{
|
||||
return queryable.Include(applicationMapping => applicationMapping.ParameterMappings).Include(applicationMapping => applicationMapping.RegexMappings);
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Description>1.0.0 - Initial Creation</Description>
|
||||
<PackageReleaseNotes>1.0.0 - Initial Creation</PackageReleaseNotes>
|
||||
<Version>1.0.0</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="EntityFramework" Version="6.4.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.10" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LCU.Library.Internal.ArchiverApiModel\LCU.Library.Internal.ArchiverApiModel.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiLib.Persistence
|
||||
{
|
||||
public class AppDbContext : DbContext
|
||||
{
|
||||
public DbSet<ApplicationMapping> ApplicationMappings { get; set; }
|
||||
public DbSet<ParameterMapping> ParameterMappings { get; set; }
|
||||
public DbSet<RegexMapping> RegexMappings { get; set; }
|
||||
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
builder.Entity<ApplicationMapping>().ToTable("ApplicationMapping");
|
||||
builder.Entity<ParameterMapping>().ToTable("ParameterMapping");
|
||||
builder.Entity<RegexMapping>().ToTable("RegexMapping");
|
||||
}
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using LCU.Library.Internal.ArchiverApiLib.Extensions;
|
||||
using LCU.Library.Internal.ArchiverApiLib.Persistence;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiLib.Repositories
|
||||
{
|
||||
public class ApplicationMappingRepository : BaseRepository, IApplicationMappingRepository
|
||||
{
|
||||
public ApplicationMappingRepository(AppDbContext context) : base(context) { }
|
||||
|
||||
public async Task<IEnumerable<ApplicationMapping>> ListAsync()
|
||||
{
|
||||
return await _context.ApplicationMappings.IncludeAll().ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<ApplicationMapping> FindByIdAsync(int id)
|
||||
{
|
||||
return await _context.ApplicationMappings.Where(applicationMapping => applicationMapping.ApplicationMappingId == id).IncludeAll().FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ApplicationMapping>> FindByIdentifierAsync(string identifier)
|
||||
{
|
||||
return await _context.ApplicationMappings.Where(applicationMapping => applicationMapping.Identifier == identifier).IncludeAll().ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<ApplicationMapping> AddAsync(ApplicationMapping applicationMapping)
|
||||
{
|
||||
var result = await _context.ApplicationMappings.AddAsync(applicationMapping);
|
||||
return result.Entity;
|
||||
}
|
||||
|
||||
public void Update(ApplicationMapping applicationMapping)
|
||||
{
|
||||
_context.ApplicationMappings.Update(applicationMapping);
|
||||
}
|
||||
|
||||
public void Remove(ApplicationMapping applicationMapping)
|
||||
{
|
||||
_context.ApplicationMappings.Remove(applicationMapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
using LCU.Library.Internal.ArchiverApiLib.Persistence;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiLib.Repositories
|
||||
{
|
||||
public abstract class BaseRepository
|
||||
{
|
||||
protected readonly AppDbContext _context;
|
||||
|
||||
public BaseRepository(AppDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiLib.Repositories
|
||||
{
|
||||
public interface IApplicationMappingRepository
|
||||
{
|
||||
Task<IEnumerable<ApplicationMapping>> ListAsync();
|
||||
Task<ApplicationMapping> FindByIdAsync(int id);
|
||||
Task<IEnumerable<ApplicationMapping>> FindByIdentifierAsync(string identifier);
|
||||
Task<ApplicationMapping> AddAsync(ApplicationMapping applicationMapping);
|
||||
void Update(ApplicationMapping applicationMapping);
|
||||
void Remove(ApplicationMapping applicationMapping);
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiLib.Repositories
|
||||
{
|
||||
public interface IRegexMappingRepository
|
||||
{
|
||||
Task<IEnumerable<RegexMapping>> ListAsync();
|
||||
Task<RegexMapping> FindByApplicationMappingIdAsync(int id);
|
||||
Task<RegexMapping> FindByRegexMappingIdAsync(int id);
|
||||
Task<RegexMapping> AddAsync(RegexMapping regexMapping);
|
||||
void Update(RegexMapping regexMapping);
|
||||
void Remove(RegexMapping regexMapping);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiLib.Repositories
|
||||
{
|
||||
public interface IUnitOfWork
|
||||
{
|
||||
Task CompleteAsync();
|
||||
void Complete();
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
using LCU.Library.Internal.ArchiverApiLib.Persistence;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using LCU.Library.Internal.ArchiverApiLib.Extensions;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiLib.Repositories
|
||||
{
|
||||
public class RegexMappingRepository : BaseRepository, IRegexMappingRepository
|
||||
{
|
||||
public RegexMappingRepository(AppDbContext context) : base(context) { }
|
||||
|
||||
public async Task<RegexMapping> AddAsync(RegexMapping regexMapping)
|
||||
{
|
||||
var result = await _context.RegexMappings.AddAsync(regexMapping);
|
||||
return result.Entity;
|
||||
}
|
||||
|
||||
public async Task<RegexMapping> FindByApplicationMappingIdAsync(int id)
|
||||
{
|
||||
return await _context.RegexMappings.Where(regexMapping => regexMapping.ApplicationMappingId == id).FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<RegexMapping> FindByRegexMappingIdAsync(int id)
|
||||
{
|
||||
return await _context.RegexMappings.Where(regexMapping => regexMapping.RegexMappingId == id).FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RegexMapping>> ListAsync()
|
||||
{
|
||||
return await _context.RegexMappings.ToListAsync();
|
||||
}
|
||||
|
||||
public void Remove(RegexMapping regexMapping)
|
||||
{
|
||||
_context.RegexMappings.Remove(regexMapping);
|
||||
}
|
||||
|
||||
public void Update(RegexMapping regexMapping)
|
||||
{
|
||||
_context.RegexMappings.Update(regexMapping);
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
using LCU.Library.Internal.ArchiverApiLib.Persistence;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiLib.Repositories
|
||||
{
|
||||
public class UnitOfWork : IUnitOfWork
|
||||
{
|
||||
private readonly AppDbContext _context;
|
||||
|
||||
public UnitOfWork(AppDbContext context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task CompleteAsync()
|
||||
{
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public void Complete()
|
||||
{
|
||||
_context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiModel.Entities
|
||||
{
|
||||
public class ApplicationMapping
|
||||
{
|
||||
public int ApplicationMappingId { get; set; }
|
||||
[StringLength(200, ErrorMessage = "The Identifier value cannot exceed 200 characters.")]
|
||||
public string Identifier { get; set; }
|
||||
[StringLength(200, ErrorMessage = "The DesignatedName value cannot exceed 200 characters.")]
|
||||
public string DesignatedName { get; set; }
|
||||
[StringLength(200, ErrorMessage = "The ApplicationOverrideName value cannot exceed 200 characters.")]
|
||||
public string ApplicationOverrideName { get; set; }
|
||||
|
||||
[ForeignKey("ApplicationMappingId")]
|
||||
public List<ParameterMapping> ParameterMappings { get; set; }
|
||||
[ForeignKey("ApplicationMappingId")]
|
||||
public List<RegexMapping> RegexMappings { get; set; }
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
namespace LCU.Library.Internal.ArchiverApiModel.Entities
|
||||
{
|
||||
public class ParameterMapping
|
||||
{
|
||||
public int ParameterMappingId { get; set; }
|
||||
public int ApplicationMappingId { get; set; }
|
||||
public string ParameterCode { get; set; }
|
||||
public string ParameterValue { get; set; }
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiModel.Entities
|
||||
{
|
||||
public class RegexMapping
|
||||
{
|
||||
public int RegexMappingId { get; set; }
|
||||
[Required]
|
||||
public int ApplicationMappingId { get; set; }
|
||||
[Required]
|
||||
public string Tag { get; set; }
|
||||
[Required]
|
||||
public string Regex { get; set; }
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<Description>
|
||||
1.0.0 - Initial Creation
|
||||
1.1.0 - Addition of ApplicationMapping and ParameterMapping.
|
||||
1.2.0 - ArchiveRequest removed location base and added extensions.
|
||||
1.3.0 - Added ReturnResponse to ArchiveRequest
|
||||
1.4.0 - Added DayFromDate to ArchiveRequest
|
||||
1.5.0 - Added seprate namespaces for Models and Entities. Added ApplicationOverrideName to Report.
|
||||
1.6.0 - Update to use MassTransit and ApiResponse upgrade.
|
||||
1.7.0 - Update ApiResponse.Models nuget
|
||||
1.8.0 - Upgraded FileOperations package version
|
||||
</Description>
|
||||
<PackageReleaseNotes>
|
||||
1.0.0 - Initial Creation
|
||||
1.1.0 - Addition of ApplicationMapping and ParameterMapping.
|
||||
1.2.0 - ArchiveRequest removed location base and added extensions.
|
||||
1.3.0 - Added ReturnResponse to ArchiveRequest
|
||||
1.4.0 - Added DayFromDate to ArchiveRequest
|
||||
1.5.0 - Added seprate namespaces for Models and Entities. Added ApplicationOverrideName to Report.
|
||||
1.6.0 - Update to use MassTransit and ApiResponse upgrade.
|
||||
1.7.0 - Update ApiResponse.Models nuget
|
||||
1.8.0 - Upgraded FileOperations package version
|
||||
</PackageReleaseNotes>
|
||||
<Version>1.8.0</Version>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LCU.Library.Internal.ApiResponse.Models" Version="3.3.0" />
|
||||
<PackageReference Include="LCU.Library.Internal.FileOperationsModels" Version="4.1.0" />
|
||||
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
using LCU.Library.Internal.ApiResponse.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiModel.Models
|
||||
{
|
||||
public class ArchiveRequest : ReturnResponse
|
||||
{
|
||||
[Required]
|
||||
public List<string> ArchiveIdentifiers { get; set; }
|
||||
[Required]
|
||||
public List<string> AllowedExensions { get; set; }
|
||||
public DateTime? EffectiveDate { get; set; }
|
||||
public int DaysFromDate { get; set; } = 0;
|
||||
[Required]
|
||||
public string ArchiveDestinationBase { get; set; }
|
||||
public bool SucceedIfEmpty { get; set; } = false;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiModel.Models
|
||||
{
|
||||
public class ArchiveRequestResponse
|
||||
{
|
||||
public ArchiveRequestResponse()
|
||||
{
|
||||
IsSuccessful = true;
|
||||
MessageStack = new List<string>();
|
||||
}
|
||||
public bool IsSuccessful { get; set; }
|
||||
public List<string> MessageStack { get; set; }
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
using LCU.Library.Internal.FileOperationsModels.Models;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiModel.Models
|
||||
{
|
||||
public class ArchiveResponsePayload
|
||||
{
|
||||
public ArchiveRequest ArchiveRequest { get; set; }
|
||||
public BulkOperationRequest<MoveFileRequest> BulkOperationRequest { get; set; }
|
||||
public ArchiveRequestResponse ArchiveRequestResponse { get; set; }
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
namespace LCU.Library.Internal.ArchiverApiModel.Models
|
||||
{
|
||||
public class ErrorDetail
|
||||
{
|
||||
public string Filename { get; set; }
|
||||
public string FileLocation { get; set; }
|
||||
public string Destination { get; set; }
|
||||
public string Description { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using LCU.Library.Internal.ArchiverApiModel.Entities;
|
||||
|
||||
namespace LCU.Library.Internal.ArchiverApiModel.Models
|
||||
{
|
||||
public class Report
|
||||
{
|
||||
public string ReportName { get; set; }
|
||||
public string QueueNumber { get; set; }
|
||||
public DateTime StopDateTime { get; set; }
|
||||
[NotMapped]
|
||||
public string DestinationQueueAndTimeStamp
|
||||
{
|
||||
get
|
||||
{
|
||||
return $"_{QueueNumber}_{ArchiveTimeStampString}";
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public string ArchiveTimeStampString
|
||||
{
|
||||
get
|
||||
{
|
||||
return DateTime.Now.ToString("MMddyyyyHHmmss");
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public string DisplayReportName
|
||||
{
|
||||
get
|
||||
{
|
||||
return ApplicationMapping?.DesignatedName == null ? FinalReportName : ApplicationMapping.DesignatedName;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public string FinalReportName
|
||||
{
|
||||
get
|
||||
{
|
||||
return ApplicationMapping?.ApplicationOverrideName == null ? ReportName : ApplicationMapping.ApplicationOverrideName;
|
||||
}
|
||||
}
|
||||
[NotMapped]
|
||||
public ApplicationMapping ApplicationMapping { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public bool HasRegexMapping { get
|
||||
{
|
||||
return ApplicationMapping?.RegexMappings != null && ApplicationMapping.RegexMappings.Any();
|
||||
}
|
||||
}
|
||||
|
||||
public string BuildDestinationName(string fullFileName, string extension)
|
||||
{
|
||||
var extensionIndex = fullFileName.ToUpper().IndexOf($".{extension.ToUpper()}");
|
||||
var fileName = fullFileName.Substring(0,extensionIndex);
|
||||
var destinationFileName = FinalReportName == fileName && !HasRegexMapping ? DisplayReportName : fileName;
|
||||
var destinationName = $"{destinationFileName}{DestinationQueueAndTimeStamp}.{extension}";
|
||||
return destinationName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
# Introduction
|
||||
Archiver Api was created to help archive/move files to different locations. Dna/Automic runs and stores applications(Reports, Statements, Notices) in a way that we need this API to gather the necessary requirements to move the files. Archiver Api takes in an ArchiveRequest that has Identifiers, date range, DNA's base path, and where the files should be moved to. Based on the data retrieved from the CoreApiWrapper we can determine more precisely where the files are and if we need to use an alternative name. The Api then uses FileOperationsApi to help bulk move the files.
|
||||
|
||||
# Process
|
||||
1. Fill out ArchiveRequest.
|
||||
- Currently we have 3 controller end points that will use the date supplied to create a data range and the config to fill out the necessary ArchiveRequest model.
|
||||
2. Queue the ArchiveRequest.
|
||||
3. Retrieve data from CoreApiWrapper using the supplied ArchiveRequest data.
|
||||
4. Fill out a BulkOperations<MoveFile> to send to FileOperationsApi.
|
||||
5. Send to FileOperationsApi.
|
||||
6. Await response from FileOperationsApi.
|
||||
7. Check that the files were in fact moved and if not send an error message to the configured error recipients.
|
||||
|
||||
# Net 8 Upgrade
|
||||
Added necessary changes for Net 8 version.
|
||||
Removed one nuget package that was marked vulnerable when updating to Net 8 (Microsoft.AspNetCore.Authentication.OpenIdConnect Version="5.0.1"), does not appear to be used.
|
||||
|
||||
For future, may want to update deprecated nuget packages.
|
||||
@@ -0,0 +1,71 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: archiver-api
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
run: archiver-api
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
annotations:
|
||||
vault.hashicorp.com/agent-inject: "true"
|
||||
vault.hashicorp.com/agent-init-first: "true"
|
||||
vault.hashicorp.com/role: "archiver-api"
|
||||
vault.hashicorp.com/agent-inject-secret-archiverapi_configuration.json: "/secret/data/archiver-api/configuration"
|
||||
vault.hashicorp.com/agent-inject-template-archiverapi_configuration.json: |
|
||||
{{- with secret "/secret/data/archiver-api/configuration" -}}
|
||||
{
|
||||
"Primary":{
|
||||
"SeqApiKey": "{{.Data.data.SeqApiKey}}",
|
||||
"Connections": {
|
||||
"SQL": {
|
||||
"ArchiverApiDb": "{{.Data.data.ArchiverApiSqlConnectionString}}"
|
||||
}
|
||||
}
|
||||
},
|
||||
"ConnectionConfiguration": {
|
||||
"UserName": "{{.Data.data.QueueUserName}}",
|
||||
"Password": "{{.Data.data.QueuePassword}}"
|
||||
}
|
||||
}
|
||||
{{- end}}
|
||||
labels:
|
||||
run: archiver-api
|
||||
spec:
|
||||
serviceAccountName: svc-archiverapi
|
||||
containers:
|
||||
- name: archiver-api
|
||||
image: landmarkcu/archiver-api:{{version}}
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- containerPort: 80
|
||||
livenessProbe:
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
httpGet:
|
||||
path: /status
|
||||
port: 80
|
||||
readinessProbe:
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
httpGet:
|
||||
path: /status
|
||||
port: 80
|
||||
volumeMounts:
|
||||
- mountPath: /etc/localtime
|
||||
name: tz-config
|
||||
- name: volume-appsettings
|
||||
mountPath: /app/config/mapped-appsettings
|
||||
volumes:
|
||||
- name: tz-config
|
||||
hostPath:
|
||||
path: /usr/share/zoneinfo/America/Chicago
|
||||
type: "File"
|
||||
- name: volume-appsettings
|
||||
configMap:
|
||||
name: archiverapi-configmap
|
||||
imagePullSecrets:
|
||||
- name: regcred
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: archiver-api
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/rewrite-target: /$2
|
||||
nginx.ingress.kubernetes.io/x-forwarded-prefix: "/archiver-api"
|
||||
spec:
|
||||
ingressClassName: nginx
|
||||
rules:
|
||||
- host:
|
||||
http:
|
||||
paths:
|
||||
- path: /archiver-api(/|$)(.*)
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: archiver-api
|
||||
port:
|
||||
number: 80
|
||||
@@ -0,0 +1,4 @@
|
||||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: landmarkcu
|
||||
@@ -0,0 +1,14 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: archiver-api
|
||||
labels:
|
||||
run: archiver-api
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 80
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
run: archiver-api
|
||||
@@ -0,0 +1,5 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: svc-archiverapi
|
||||
namespace: landmarkcu
|
||||
@@ -0,0 +1,6 @@
|
||||
resources:
|
||||
- ServiceAccount.yaml
|
||||
- Namespaces.yaml
|
||||
- Deployment.yaml
|
||||
- Service.yaml
|
||||
- Ingress.yaml
|
||||
@@ -0,0 +1,9 @@
|
||||
resources:
|
||||
- configmap.yaml
|
||||
bases:
|
||||
- ../../base
|
||||
patchesStrategicMerge:
|
||||
- set_appsettings_deployment.yaml
|
||||
- set_deployment_image.yaml
|
||||
- set_ingress_annotation.yaml
|
||||
namespace: landmarkcu
|
||||
@@ -0,0 +1,12 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: archiver-api
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: archiver-api
|
||||
env:
|
||||
- name: ASPNETCORE_ENVIRONMENT
|
||||
value: "Development"
|
||||
@@ -0,0 +1,10 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: archiver-api
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: archiver-api
|
||||
image: local/archiver-api:1.0
|
||||
@@ -0,0 +1,6 @@
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: archiver-api
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/x-forwarded-prefix: ":30000/archiver-api"
|
||||
@@ -0,0 +1,25 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: archiverapi-configmap
|
||||
data:
|
||||
primary.json: |
|
||||
{
|
||||
"Primary": {
|
||||
"SeqUrl": "https://seq.lcu-internal.com",
|
||||
"NotificationApiEmail": "https://prd-notifications-api.apps.azure.lcu-internal.com/api/Email",
|
||||
"FileOperationApiBulkMoveFile": "https://fileoperationsapi.lcu-internal.com/api/FileOperations/BulkMoveFile",
|
||||
"FileOperationApiBuildDynamicFileList": "https://fileoperationsapi.lcu-internal.com/DynamicFile/BuildDynamicFileList",
|
||||
"FileOperationApiValidateFileExists": "https://fileoperationsapi.lcu-internal.com/FileValidation/ValidateFileExists",
|
||||
"CoreApiWrapperGetApplicationHistory": "https://api.lcu-internal.com/core-api-wrapper/api/core/ApplicationHistory/GetApplicationHistory",
|
||||
"DnaBasePath": "\\\\D2dnamfs01p\\dnagold\\Prod\\OSI\\RPTS",
|
||||
"ErrorRecipients": [ "[email protected]" ],
|
||||
"FeatureFlags": {
|
||||
"RunArchiverConsumer": false,
|
||||
"RunResponseConsumer": false
|
||||
}
|
||||
},
|
||||
"ConnectionConfiguration": {
|
||||
"HostUrl": "rabbitmq.lcu-internal.com"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
resources:
|
||||
- configmap.yaml
|
||||
bases:
|
||||
- ../../base
|
||||
patchesStrategicMerge:
|
||||
- set_appsettings_deployment.yaml
|
||||
namespace: landmarkcu
|
||||
@@ -0,0 +1,12 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: archiver-api
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: archiver-api
|
||||
env:
|
||||
- name: ASPNETCORE_ENVIRONMENT
|
||||
value: "Production"
|
||||
@@ -0,0 +1,25 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: archiverapi-configmap
|
||||
data:
|
||||
primary.json: |
|
||||
{
|
||||
"Primary": {
|
||||
"SeqUrl": "https://qa-seq.lcu-internal.com",
|
||||
"NotificationApiEmail":"https://qa-notifications-api.apps.azure.lcu-internal.com/api/Email",
|
||||
"FileOperationApiBulkMoveFile": "https://qa-fileoperationsapi.lcu-internal.com/api/FileOperations/BulkMoveFile",
|
||||
"FileOperationApiBuildDynamicFileList": "https://qa-fileoperationsapi.lcu-internal.com/DynamicFile/BuildDynamicFileList",
|
||||
"FileOperationApiValidateFileExists": "https://qa-fileoperationsapi.lcu-internal.com/FileValidation/ValidateFileExists",
|
||||
"CoreApiWrapperGetApplicationHistory": "https://qa-api.lcu-internal.com/core-api-wrapper/api/core/ApplicationHistory/GetApplicationHistory",
|
||||
"DnaBasePath": "\\\\zeus\\DataIntegrationsQA\\AutomicArchive\\TEST_DNA",
|
||||
"ErrorRecipients": [ "[email protected]", "[email protected]" ],
|
||||
"FeatureFlags": {
|
||||
"RunArchiverConsumer": false,
|
||||
"RunResponseConsumer": false
|
||||
}
|
||||
},
|
||||
"ConnectionConfiguration": {
|
||||
"HostUrl": "qa-rabbitmq.lcu-internal.com"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
resources:
|
||||
- configmap.yaml
|
||||
bases:
|
||||
- ../../base
|
||||
patchesStrategicMerge:
|
||||
- set_appsettings_deployment.yaml
|
||||
namespace: landmarkcu
|
||||
@@ -0,0 +1,12 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: archiver-api
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: archiver-api
|
||||
env:
|
||||
- name: ASPNETCORE_ENVIRONMENT
|
||||
value: "Development"
|
||||
@@ -0,0 +1,25 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: archiverapi-configmap
|
||||
data:
|
||||
primary.json: |
|
||||
{
|
||||
"Primary": {
|
||||
"SeqUrl": "https://uat-seq.lcu-internal.com",
|
||||
"NotificationApiEmail": "https://uat-notifications-api.apps.azure.lcu-internal.com/api/Email",
|
||||
"FileOperationApiBulkMoveFile": "https://uat-fileoperationsapi.lcu-internal.com/api/FileOperations/BulkMoveFile",
|
||||
"FileOperationApiBuildDynamicFileList": "https://uat-fileoperationsapi.lcu-internal.com/DynamicFile/BuildDynamicFileList",
|
||||
"FileOperationApiValidateFileExists": "https://uat-fileoperationsapi.lcu-internal.com/FileValidation/ValidateFileExists",
|
||||
"CoreApiWrapperGetApplicationHistory": "https://uat-api.lcu-internal.com/core-api-wrapper/api/core/ApplicationHistory/GetApplicationHistory",
|
||||
"DnaBasePath": "\\\\zeus\\DataIntegrationsUAT\\AutomicArchive\\TEST_DNA",
|
||||
"ErrorRecipients": [ "[email protected]", "[email protected]" ],
|
||||
"FeatureFlags": {
|
||||
"RunArchiverConsumer": false,
|
||||
"RunResponseConsumer": false
|
||||
}
|
||||
},
|
||||
"ConnectionConfiguration": {
|
||||
"HostUrl": "uat-rabbitmq.lcu-internal.com"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
resources:
|
||||
- configmap.yaml
|
||||
bases:
|
||||
- ../../base
|
||||
patchesStrategicMerge:
|
||||
- set_appsettings_deployment.yaml
|
||||
namespace: landmarkcu
|
||||
@@ -0,0 +1,12 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: archiver-api
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: archiver-api
|
||||
env:
|
||||
- name: ASPNETCORE_ENVIRONMENT
|
||||
value: "Staging"
|
||||
@@ -0,0 +1,67 @@
|
||||
parameters:
|
||||
- name: target_environment
|
||||
displayName: Target Environment
|
||||
type: string
|
||||
default: qa
|
||||
values:
|
||||
- qa
|
||||
- uat
|
||||
- prd
|
||||
- name: k8s_namespace
|
||||
displayName: K8s Namespace to deploy to
|
||||
type: string
|
||||
default: landmarkcu
|
||||
values:
|
||||
- landmarkcu
|
||||
variables:
|
||||
- template: ./config-files/${{ parameters.target_environment }}-pvars.yaml
|
||||
- name: source_branch_name
|
||||
value: $[replace(replace(variables['Build.SourceBranch'], 'refs/heads/', ''), '/', '-')]
|
||||
- name: docker_container_repository_name
|
||||
value: landmarkcu/lcu.api.internal.archiver-archiver
|
||||
resources:
|
||||
repositories:
|
||||
- repository: azdo_pipeline_templates
|
||||
type: git
|
||||
name: Infrastructure Platform/azdo-pipeline-templates
|
||||
ref: main
|
||||
stages:
|
||||
# DOTNET BUILD AND NUGET PUSH
|
||||
- template: dotnet-nuget-build-push.yaml@azdo_pipeline_templates
|
||||
parameters:
|
||||
azdo_agent_pool: $(pvar_azdo_agent_pool_nuget)
|
||||
azure_artifacts_feed: 'LCU-Internal'
|
||||
|
||||
# DACPAC BUILD AND PUSH
|
||||
- template: db-build-deploy.yaml@azdo_pipeline_templates
|
||||
parameters:
|
||||
azdo_agent_pool: $(pvar_azdo_agent_pool_db)
|
||||
azdo_deployment_environment: $(pvar_azdo_deployment_environment_db)
|
||||
sql_project_path: './LCU.Api.Internal.ArchiverApiSql/LCU.Api.Internal.ArchiverApiSql.sqlproj'
|
||||
built_sql_dacpac_file_path: './LCU.Api.Internal.ArchiverApiSql/bin/Release/LCU.Api.Internal.ArchiverApiSql.dacpac'
|
||||
name_of_artifact: LCU_Api_Internal_ArchiverApiSql_dacpac
|
||||
db_name: $(pvar_LCU_Api_Internal_ArchiverApiSql_db_name)
|
||||
sql_server_name: $(pvar_LCU_Api_Internal_ArchiverApiSql_sql_server_name)
|
||||
|
||||
# DOCKER BUILD AND PUSH
|
||||
- template: docker-build-push.yaml@azdo_pipeline_templates
|
||||
parameters:
|
||||
azdo_agent_pool: $(pvar_azdo_agent_pool)
|
||||
docker_registry_service_connection: $(pvar_docker_registry_service_connection)
|
||||
docker_container_repository_name: $(docker_container_repository_name)
|
||||
dockerfile_path: ./Dockerfile
|
||||
docker_image_tags: |
|
||||
build-$(Build.BuildId)
|
||||
$(source_branch_name)
|
||||
# K8S DEPLOY
|
||||
- template: k8s-deploy.yaml@azdo_pipeline_templates
|
||||
parameters:
|
||||
dependsOn: CI
|
||||
condition: or(eq(variables['Build.SourceBranchName'], 'develop'), eq(variables['Build.SourceBranchName'], 'master'))
|
||||
azdo_agent_pool: $(pvar_azdo_agent_pool)
|
||||
kubectl_version: $(pvar_kubectl_version)
|
||||
k8s_service_connection: $(pvar_k8s_service_connection)
|
||||
k8s_namespace: ${{ parameters.k8s_namespace }}
|
||||
k8s_kustomization_path: ./kustomize/overlays/${{ parameters.target_environment }}
|
||||
docker_registry_service_connection: $(pvar_docker_registry_service_connection)
|
||||
docker_image_to_deploy: $(docker_container_repository_name):build-$(Build.BuildId)
|
||||
@@ -0,0 +1,10 @@
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- '*'
|
||||
exclude:
|
||||
- 'master'
|
||||
- 'develop'
|
||||
extends:
|
||||
template: azure-k8s-pipeline.yaml
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- 'master'
|
||||
extends:
|
||||
template: azure-k8s-pipeline.yaml
|
||||
parameters:
|
||||
target_environment: prd
|
||||
k8s_namespace: landmarkcu
|
||||
@@ -0,0 +1,9 @@
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- 'develop'
|
||||
extends:
|
||||
template: azure-k8s-pipeline.yaml
|
||||
parameters:
|
||||
target_environment: qa
|
||||
k8s_namespace: landmarkcu
|
||||
@@ -0,0 +1,9 @@
|
||||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- 'master'
|
||||
extends:
|
||||
template: azure-k8s-pipeline.yaml
|
||||
parameters:
|
||||
target_environment: uat
|
||||
k8s_namespace: landmarkcu
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user