651 lines
34 KiB
C#
651 lines
34 KiB
C#
using System.Text.Json.Serialization;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.OpenApi.Models;
|
|
using Newtonsoft.Json;
|
|
using Serilog;
|
|
using MassTransit;
|
|
using LCU.Library.Internal.LcuMassTransit;
|
|
using LCU.Library.Internal.LcuMassTransitModels;
|
|
using LCU.Library.Internal.Logging;
|
|
using LCU.Library.Internal.Logging.Models;
|
|
using LCU.Library.Internal.Logging.Middleware;
|
|
using LCU.Library.Internal.Configuration;
|
|
using LCU.Library.Internal.ApiSecurity;
|
|
using LCU.Library.Internal.Status;
|
|
using LCU.API.Internal.DocumentIngestor.Configurations;
|
|
using LCU.API.Internal.DocumentIngestor.Consumers;
|
|
using LCU.API.Internal.DocumentIngestor.DataAccess;
|
|
using LCU.API.Internal.DocumentIngestor.Services;
|
|
using LCU.API.Internal.DocumentIngestor.Services.IngestionOperationServices;
|
|
using LCU.API.Internal.DocumentIngestor.Services.IndexParserServices;
|
|
using LCU.API.Internal.DocumentIngestor.Services.DocumentProcessorServices;
|
|
using LCU.API.Internal.DocumentIngestor.Services.QueueServices;
|
|
using LCU.API.Internal.DocumentIngestor.Services.MicroApiServices;
|
|
using LCU.API.Internal.DocumentIngestor.Services.AttributeDeterminingServices;
|
|
using LCU.API.Internal.DocumentIngestor.Services.PdfParserServices;
|
|
using LCU.API.Internal.DocumentIngestor.Services.MemberNotificationInfoDeterminingServices;
|
|
using LCU.API.Internal.DocumentIngestorLib.Repositories;
|
|
using LCU.API.Internal.DocumentIngestorLib.Persistence;
|
|
using LCU.Api.Internal.DispatcherSharedLib;
|
|
using LCU.API.Internal.DocumentIngestor.Initializers;
|
|
using LCU.API.Internal.DocumentIngestor.Security;
|
|
using LCU.Library.Internal.LCUServiceFactory;
|
|
using LCU.Library.Internal.LCUServiceFactory.Configurations;
|
|
using Microsoft.ApplicationInsights.DependencyCollector;
|
|
using Microsoft.ApplicationInsights.Extensibility;
|
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.Identity.Web;
|
|
using Microsoft.ApplicationInsights.AspNetCore.Extensions;
|
|
|
|
string MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
|
|
|
|
var builder = BuildBuilder(args);
|
|
BuildServicesAndConfigurations(builder);
|
|
BuildAppAndRun(builder);
|
|
|
|
WebApplicationBuilder BuildBuilder(string[] args)
|
|
{
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.Configuration.AddJsonFile("/app/config/environment-appsettings/appsettings.json", optional: true, reloadOnChange: true);
|
|
builder.Configuration.AddJsonFile("/app/config/workload-appsettings/appsettings.json", optional: true, reloadOnChange: true);
|
|
builder.Configuration.AddJsonFile("/vault/secrets/document-ingestor-azure-ad-client-secret.json", optional: true, reloadOnChange: true);
|
|
builder.Configuration.AddJsonFile("/vault/secrets/document-ingestor-application-insights-instrumentation-key.json", optional: true, reloadOnChange: true);
|
|
builder.Configuration.AddJsonFile("/vault/secrets/document-ingestor-document-manager.json", optional: true, reloadOnChange: true);
|
|
builder.Configuration.AddJsonFile("/vault/secrets/document-ingestor-queue-password.json", optional: true, reloadOnChange: true);
|
|
builder.Configuration.AddJsonFile("/vault/secrets/document-ingestor-queue-user-name.json", optional: true, reloadOnChange: true);
|
|
builder.Configuration.AddJsonFile("/vault/secrets/document-ingestor-database-connection.json", optional: true, reloadOnChange: true);
|
|
builder.Configuration.AddJsonFile("/vault/secrets/document-ingestor-environment-from-vault.json", optional: true, reloadOnChange: true);
|
|
builder.Configuration.AddJsonFile("/vault/secrets/document-ingestor-document-ingestor-api-key.json", optional: true, reloadOnChange: true);
|
|
builder.Configuration.AddJsonFile("/vault/secrets/document-ingestor-seq-api-key.json", optional: true, reloadOnChange: true);
|
|
builder.Configuration.AddJsonFile("/vault/secrets/document-ingestor-mobile-banking-api-key.json", optional: true, reloadOnChange: true);
|
|
builder.Host.UseSerilog();
|
|
return builder;
|
|
}
|
|
|
|
void BuildServicesAndConfigurations(WebApplicationBuilder builder)
|
|
{
|
|
var services = builder.Services;
|
|
var configuration = builder.Configuration;
|
|
|
|
var apiConfiguration = configuration.Bind<ApiConfiguration>(services, "Primary");
|
|
configuration.Bind<FileOperationsApiConfiguration>(services);
|
|
configuration.Bind<CoreApiWrapperConfiguration>(services);
|
|
configuration.Bind<DocumentTypeUploaderConfiguration>(services);
|
|
configuration.Bind<NotificationApiConfiguration>(services);
|
|
configuration.Bind<MemberPreferencesApiConfiguration>(services);
|
|
configuration.Bind<DispatcherJobCreationConfiguration>(services);
|
|
configuration.Bind<DocumentTypeRetrieverConfiguration>(services);
|
|
configuration.Bind<DocumentCodeDetailCacheConfiguration>(services);
|
|
configuration.Bind<DigitalBankingConfiguration>(services);
|
|
var security = configuration.Bind<SecurityConfiguration>(services, "Security");
|
|
var dbConfiguration = configuration.Bind<SqlConnectionConfiguration>(services);
|
|
var servicesFactoryConfiguration = configuration.Bind<ServicesFactoryConfiguration>(services);
|
|
|
|
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|
.AddMicrosoftIdentityWebApi(configuration.GetSection("AzureAd"));
|
|
services.AddAuthorization(options =>
|
|
{
|
|
options.AddPolicy("user_token", policy =>
|
|
{
|
|
policy.AuthenticationSchemes.Add(JwtBearerDefaults.AuthenticationScheme);
|
|
policy.RequireAuthenticatedUser();
|
|
});
|
|
options.DefaultPolicy = options.GetPolicy("user_token")!;
|
|
|
|
options.AddPolicy(SetDocumentNotificationStatusPolicy.Name, policyBuilder => SetDocumentNotificationStatusPolicy.PolicyFactory(policyBuilder, security));
|
|
});
|
|
services.AddSingleton<IAuthorizationHandler, GroupMembershipRequirementHandler>();
|
|
|
|
var insightsServiceOptions = new ApplicationInsightsServiceOptions() { ConnectionString = configuration["ApplicationInsights:InstrumentationKey"] };
|
|
services.AddApplicationInsightsTelemetry(insightsServiceOptions);
|
|
services.AddSingleton<ITelemetryInitializer, CloudRoleNameTelemetryInitializer>();
|
|
services.ConfigureTelemetryModule<DependencyTrackingTelemetryModule>((module,o)=>{
|
|
module.IncludeDiagnosticSourceActivities.Add("MassTransit");
|
|
});
|
|
|
|
services.AddMemoryCache();
|
|
|
|
services.AddDbContext<AppDbContext>(options =>
|
|
{
|
|
options.UseSqlServer
|
|
(
|
|
dbConfiguration.ConnectionString,
|
|
sql => sql.EnableRetryOnFailure(dbConfiguration.MaxRetryCount, dbConfiguration.MaxRetryDelay, null)
|
|
);
|
|
});
|
|
|
|
var loggerConfiguration = new LoggingConfiguration(apiConfiguration.AppName,
|
|
apiConfiguration.SeqApiKey,
|
|
apiConfiguration.SeqUrl);
|
|
var lcuLogging = new LcuLogging(loggerConfiguration);
|
|
lcuLogging.UseLcuLogging();
|
|
|
|
services.AddCors(options =>
|
|
{
|
|
options.AddPolicy(MyAllowSpecificOrigins,
|
|
builder =>
|
|
{
|
|
builder.WithOrigins(
|
|
apiConfiguration.CorsAllowedOrigins
|
|
).AllowAnyHeader().AllowAnyMethod();
|
|
});
|
|
});
|
|
|
|
var connectionConfiguration = MassTransitConfigurationSetUp.AddConnectionConfiguration(ref services, configuration);
|
|
//debugging
|
|
Console.WriteLine(JsonConvert.SerializeObject(connectionConfiguration));
|
|
|
|
var receiveEndpointConfigurations = new ReceiveEndpointConfigurations()
|
|
{
|
|
BatchIngestionReceiveEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration,
|
|
"BatchIngestionReceiveEndpoint"),
|
|
DocumentIngestorReceiveEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration,
|
|
"DocumentIngestorReceiveEndpoint"),
|
|
DocumentIngestorProcessingReceiveEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration,
|
|
"DocumentIngestorProcessingReceiveEndpoint"),
|
|
DocumentIngestorCompletionReceiveEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration,
|
|
"DocumentIngestorCompletionReceiveEndpoint"),
|
|
PdfPartitionerEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration, "PdfPartitionerEndpoint"),
|
|
PdfPartitionerCompletionEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration,
|
|
"PdfPartitionerCompletionEndpoint"),
|
|
UploadCompletionEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration,
|
|
"UploadCompletionEndpoint"),
|
|
MemberDocumentNotifierEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration,
|
|
"MemberDocumentNotifierEndpoint"),
|
|
MemberNotificationCompletionEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration,
|
|
"MemberNotificationCompletionEndpoint"),
|
|
IngestionFolderCleanUpReceiveEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration,
|
|
"IngestionFolderCleanUpReceiveEndpoint"),
|
|
GatherMemberNotificationInfoReceiveEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration,
|
|
"GatherMemberNotificationInfoReceiveEndpoint"),
|
|
BatchUpdateMemberNotificationDataEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration,
|
|
"BatchUpdateMemberNotificationDataEndpoint"),
|
|
ProcessStatusTypeEmailReceiveEndpoint = MassTransitConfigurationSetUp.GetReceiveEndpointConfiguration(configuration, "ProcessStatusTypeEmailReceiveEndpoint")
|
|
};
|
|
services.AddSingleton(receiveEndpointConfigurations);
|
|
//debugging
|
|
Console.WriteLine(JsonConvert.SerializeObject(receiveEndpointConfigurations));
|
|
|
|
services.AddLCUStatusServicesWithApiHealthCheck(configuration);
|
|
|
|
AddMassTransitServices(ref services, connectionConfiguration, receiveEndpointConfigurations, apiConfiguration);
|
|
AddDocumentIngestorServices(services);
|
|
AddDocumentIngestorDaos(services);
|
|
AddDocumentIngestorLib(ref services);
|
|
services.AddHttpClient();
|
|
services.AddDispatcherServices(configuration);
|
|
|
|
services.AddLCUServiceFactoryAndValidateServiceRegistration<IIndexParserService>(servicesFactoryConfiguration);
|
|
services.AddLCUServiceFactoryAndValidateServiceRegistration<IPdfIndexParserService>(servicesFactoryConfiguration);
|
|
services.AddLCUServiceFactoryAndValidateServiceRegistration<IPdfParserService>(servicesFactoryConfiguration);
|
|
services.AddLCUServiceFactoryAndValidateServiceRegistration<IDocumentProcessingService>(servicesFactoryConfiguration);
|
|
|
|
services.AddControllers().AddJsonOptions(options => options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()));
|
|
services.AddEndpointsApiExplorer();
|
|
services.AddSwaggerGen(c =>
|
|
{
|
|
c.SwaggerDoc("v1", new OpenApiInfo { Title = $"{apiConfiguration.AppName}", Version = "v1" });
|
|
|
|
var authority = $"https://login.microsoftonline.com/{configuration.GetSection("AzureAd")["TenantId"]}";
|
|
c.AddSecurityDefinition
|
|
(
|
|
nameof(SecuritySchemeType.OpenIdConnect),
|
|
new OpenApiSecurityScheme
|
|
{
|
|
Type = SecuritySchemeType.OAuth2,
|
|
Flows = new OpenApiOAuthFlows
|
|
{
|
|
AuthorizationCode = new OpenApiOAuthFlow
|
|
{
|
|
AuthorizationUrl = new Uri($"{authority}/oauth2/v2.0/authorize"),
|
|
TokenUrl = new Uri($"{authority}/oauth2/v2.0/token")
|
|
}
|
|
}
|
|
}
|
|
);
|
|
c.AddSecurityRequirement
|
|
(
|
|
new OpenApiSecurityRequirement
|
|
{
|
|
{
|
|
new OpenApiSecurityScheme
|
|
{
|
|
Reference = new OpenApiReference
|
|
{
|
|
Type = ReferenceType.SecurityScheme,
|
|
Id = nameof(SecuritySchemeType.OpenIdConnect)
|
|
}
|
|
},
|
|
Array.Empty<string>()
|
|
}
|
|
}
|
|
);
|
|
|
|
c.AddSecurityDefinition("ApiKey", new OpenApiSecurityScheme
|
|
{
|
|
In = ParameterLocation.Header,
|
|
Name = "ApiKey"
|
|
});
|
|
c.AddSecurityDefinition("ApiClient", new OpenApiSecurityScheme
|
|
{
|
|
In = ParameterLocation.Header,
|
|
Name = "Client"
|
|
});
|
|
c.AddSecurityRequirement
|
|
(
|
|
new OpenApiSecurityRequirement
|
|
{
|
|
{
|
|
new OpenApiSecurityScheme
|
|
{
|
|
Reference = new OpenApiReference
|
|
{
|
|
Type = ReferenceType.SecurityScheme,
|
|
Id = "ApiKey"
|
|
}
|
|
},
|
|
Array.Empty<string>()
|
|
}
|
|
}
|
|
);
|
|
c.AddSecurityRequirement
|
|
(
|
|
new OpenApiSecurityRequirement
|
|
{
|
|
{
|
|
new OpenApiSecurityScheme
|
|
{
|
|
Reference = new OpenApiReference
|
|
{
|
|
Type = ReferenceType.SecurityScheme,
|
|
Id = "ApiClient"
|
|
}
|
|
},
|
|
Array.Empty<string>()
|
|
}
|
|
}
|
|
);
|
|
});
|
|
|
|
services.AddApiKeySecurity(configuration);
|
|
}
|
|
|
|
void AddMassTransitServices(ref IServiceCollection services,
|
|
ConnectionConfiguration connectionConfiguration,
|
|
ReceiveEndpointConfigurations receiveEndpointConfigurations,
|
|
ApiConfiguration apiConfiguration)
|
|
{
|
|
services.AddMassTransit(x =>
|
|
{
|
|
x.AddConsumer<BatchIngestionConsumer>();
|
|
x.AddConsumer<IngestorIndexConsumer>();
|
|
x.AddConsumer<IngestorProcessingConsumer>();
|
|
x.AddConsumer<IngestorCompletionConsumer>();
|
|
x.AddConsumer<IngestionFolderCleanUpConsumer>();
|
|
x.AddConsumer<PdfPartitionerConsumer>();
|
|
x.AddConsumer<PdfPartitionerCompletionConsumer>();
|
|
x.AddConsumer<UploadCompletionConsumer>();
|
|
x.AddConsumer<MemberDocumentNotifierConsumer>();
|
|
x.AddConsumer<MemberNotificationCompletionConsumer>();
|
|
x.AddConsumer<GatherMemberNotificationInfoConsumer>();
|
|
x.AddConsumer<BatchUpdateMemberNotificationDataConsumer>();
|
|
x.AddConsumer<ProcessStatusTypeEmailConsumer>();
|
|
|
|
x.UsingRabbitMq((context, cfg) =>
|
|
{
|
|
cfg.Host(connectionConfiguration.HostUrl, "/", host =>
|
|
{
|
|
host.Username(connectionConfiguration.UserName);
|
|
host.Password(connectionConfiguration.Password);
|
|
});
|
|
cfg.UseTimeout(t => t.Timeout = TimeSpan.FromSeconds(420));
|
|
|
|
if (apiConfiguration.FeatureFlags.RunBatchIngestionConsumer)
|
|
{
|
|
cfg.ReceiveEndpoint(receiveEndpointConfigurations.BatchIngestionReceiveEndpoint.ReceiveEndpoint, e =>
|
|
{
|
|
e.ConfigureConsumer<BatchIngestionConsumer>(context);
|
|
e.SetQuorumQueue();
|
|
e.PrefetchCount = receiveEndpointConfigurations.BatchIngestionReceiveEndpoint.PrefetchLimit;
|
|
e.UseTimeout(t => t.Timeout = TimeSpan.FromSeconds(420));
|
|
});
|
|
}
|
|
|
|
if (apiConfiguration.FeatureFlags.RunIngestorIndexConsumer)
|
|
{
|
|
cfg.ReceiveEndpoint(receiveEndpointConfigurations.DocumentIngestorReceiveEndpoint.ReceiveEndpoint, e =>
|
|
{
|
|
e.ConfigureConsumer<IngestorIndexConsumer>(context);
|
|
e.SetQuorumQueue();
|
|
e.PrefetchCount = receiveEndpointConfigurations.DocumentIngestorReceiveEndpoint.PrefetchLimit;
|
|
e.UseTimeout(t => t.Timeout = TimeSpan.FromSeconds(420));
|
|
});
|
|
}
|
|
|
|
if (apiConfiguration.FeatureFlags.RunIngestorProcessingConsumer)
|
|
{
|
|
cfg.ReceiveEndpoint(receiveEndpointConfigurations.DocumentIngestorProcessingReceiveEndpoint.ReceiveEndpoint, e =>
|
|
{
|
|
e.ConfigureConsumer<IngestorProcessingConsumer>(context);
|
|
e.SetQuorumQueue();
|
|
e.PrefetchCount = receiveEndpointConfigurations.DocumentIngestorProcessingReceiveEndpoint.PrefetchLimit;
|
|
e.UseTimeout(t => t.Timeout = TimeSpan.FromSeconds(420));
|
|
});
|
|
}
|
|
|
|
if (apiConfiguration.FeatureFlags.RunIngestorCompletionConsumer)
|
|
{
|
|
cfg.ReceiveEndpoint(receiveEndpointConfigurations.DocumentIngestorCompletionReceiveEndpoint.ReceiveEndpoint, e =>
|
|
{
|
|
e.ConfigureConsumer<IngestorCompletionConsumer>(context);
|
|
e.SetQuorumQueue();
|
|
e.PrefetchCount = receiveEndpointConfigurations.DocumentIngestorCompletionReceiveEndpoint.PrefetchLimit;
|
|
e.UseTimeout(t => t.Timeout = TimeSpan.FromSeconds(420));
|
|
});
|
|
}
|
|
|
|
if (apiConfiguration.FeatureFlags.RunIngestionFolderCleanUpConsumer)
|
|
{
|
|
cfg.ReceiveEndpoint(receiveEndpointConfigurations.IngestionFolderCleanUpReceiveEndpoint.ReceiveEndpoint, e =>
|
|
{
|
|
e.ConfigureConsumer<IngestionFolderCleanUpConsumer>(context);
|
|
e.SetQuorumQueue();
|
|
e.PrefetchCount = receiveEndpointConfigurations.IngestionFolderCleanUpReceiveEndpoint.PrefetchLimit;
|
|
e.UseTimeout(t => t.Timeout = TimeSpan.FromSeconds(420));
|
|
});
|
|
}
|
|
|
|
if (apiConfiguration.FeatureFlags.RunPdfPartitionerConsumer)
|
|
{
|
|
cfg.ReceiveEndpoint(receiveEndpointConfigurations.PdfPartitionerEndpoint.ReceiveEndpoint, e =>
|
|
{
|
|
e.ConfigureConsumer<PdfPartitionerConsumer>(context);
|
|
e.SetQuorumQueue();
|
|
e.PrefetchCount = receiveEndpointConfigurations.PdfPartitionerEndpoint.PrefetchLimit;
|
|
e.UseTimeout(t => t.Timeout = TimeSpan.FromSeconds(420));
|
|
});
|
|
}
|
|
|
|
if (apiConfiguration.FeatureFlags.RunPdfPartitionerCompletionConsumer)
|
|
{
|
|
cfg.ReceiveEndpoint(receiveEndpointConfigurations.PdfPartitionerCompletionEndpoint.ReceiveEndpoint, e =>
|
|
{
|
|
e.ConfigureConsumer<PdfPartitionerCompletionConsumer>(context);
|
|
e.SetQuorumQueue();
|
|
e.PrefetchCount = receiveEndpointConfigurations.PdfPartitionerCompletionEndpoint.PrefetchLimit;
|
|
e.UseTimeout(t => t.Timeout = TimeSpan.FromSeconds(420));
|
|
});
|
|
}
|
|
|
|
if (apiConfiguration.FeatureFlags.RunUploadCompletionConsumer)
|
|
{
|
|
cfg.ReceiveEndpoint(receiveEndpointConfigurations.UploadCompletionEndpoint.ReceiveEndpoint, e =>
|
|
{
|
|
e.ConfigureConsumer<UploadCompletionConsumer>(context);
|
|
e.SetQuorumQueue();
|
|
e.PrefetchCount = receiveEndpointConfigurations.UploadCompletionEndpoint.PrefetchLimit;
|
|
e.UseTimeout(t => t.Timeout = TimeSpan.FromSeconds(420));
|
|
});
|
|
}
|
|
|
|
if (apiConfiguration.FeatureFlags.RunMemberDocumentNotifierConsumer)
|
|
{
|
|
cfg.ReceiveEndpoint(receiveEndpointConfigurations.MemberDocumentNotifierEndpoint.ReceiveEndpoint, e =>
|
|
{
|
|
e.ConfigureConsumer<MemberDocumentNotifierConsumer>(context);
|
|
e.SetQuorumQueue();
|
|
e.PrefetchCount = receiveEndpointConfigurations.MemberDocumentNotifierEndpoint.PrefetchLimit;
|
|
e.UseTimeout(t => t.Timeout = TimeSpan.FromSeconds(420));
|
|
});
|
|
}
|
|
|
|
if (apiConfiguration.FeatureFlags.RunMemberNotificationCompletionConsumer)
|
|
{
|
|
cfg.ReceiveEndpoint(receiveEndpointConfigurations.MemberNotificationCompletionEndpoint.ReceiveEndpoint, e =>
|
|
{
|
|
e.ConfigureConsumer<MemberNotificationCompletionConsumer>(context);
|
|
e.SetQuorumQueue();
|
|
e.PrefetchCount = receiveEndpointConfigurations.MemberNotificationCompletionEndpoint.PrefetchLimit;
|
|
e.UseTimeout(t => t.Timeout = TimeSpan.FromSeconds(420));
|
|
});
|
|
}
|
|
|
|
if (apiConfiguration.FeatureFlags.RunGatherMemberNotificationInfoConsumer)
|
|
{
|
|
cfg.ReceiveEndpoint(receiveEndpointConfigurations.GatherMemberNotificationInfoReceiveEndpoint.ReceiveEndpoint, e =>
|
|
{
|
|
e.ConfigureConsumer<GatherMemberNotificationInfoConsumer>(context);
|
|
e.SetQuorumQueue();
|
|
e.PrefetchCount = receiveEndpointConfigurations.GatherMemberNotificationInfoReceiveEndpoint.PrefetchLimit;
|
|
e.UseTimeout(t => t.Timeout = TimeSpan.FromSeconds(420));
|
|
});
|
|
}
|
|
|
|
if (apiConfiguration.FeatureFlags.RunBatchUpdateMemberNotificationDataConsumer)
|
|
{
|
|
cfg.ReceiveEndpoint(receiveEndpointConfigurations.BatchUpdateMemberNotificationDataEndpoint.ReceiveEndpoint, e =>
|
|
{
|
|
e.ConfigureConsumer<BatchUpdateMemberNotificationDataConsumer>(context);
|
|
e.SetQuorumQueue();
|
|
e.PrefetchCount = receiveEndpointConfigurations.BatchUpdateMemberNotificationDataEndpoint.PrefetchLimit;
|
|
e.UseTimeout(t => t.Timeout = TimeSpan.FromSeconds(420));
|
|
});
|
|
}
|
|
if (apiConfiguration.FeatureFlags.RunProcessStatusTypeSummaryConsumer)
|
|
{
|
|
cfg.ReceiveEndpoint(receiveEndpointConfigurations.ProcessStatusTypeEmailReceiveEndpoint.ReceiveEndpoint, e =>
|
|
{
|
|
e.ConfigureConsumer<ProcessStatusTypeEmailConsumer>(context);
|
|
e.SetQuorumQueue();
|
|
e.PrefetchCount = receiveEndpointConfigurations.ProcessStatusTypeEmailReceiveEndpoint.PrefetchLimit;
|
|
e.UseTimeout(t => t.Timeout = TimeSpan.FromSeconds(420));
|
|
});
|
|
}
|
|
});
|
|
});
|
|
services.AddMassTransitHostedService();
|
|
}
|
|
|
|
void AddDocumentIngestorServices(IServiceCollection services)
|
|
{
|
|
services.AddScoped<IIngestorRunInfoService, IngestorRunInfoService>();
|
|
services.AddScoped<IDocumentProcessingInfoService, DocumentProcessingInfoService>();
|
|
services.AddScoped<IOwnerOverrideInfoService, OwnerOverrideInfoService>();
|
|
services.AddScoped<IProcessingLogService, ProcessingLogService>();
|
|
services.AddScoped<IDocumentTypeArchiveDeleteInfoService, DocumentTypeArchiveDeleteInfoService>();
|
|
services.AddScoped<IProcessStatusTypeEmailService, ProcessStatusTypeEmailService>();
|
|
services.AddScoped<IDocumentReprocessingService, DocumentReprocessingService>();
|
|
services.AddScoped<IUploadCompletionReprocessingService, UploadCompletionReprocessingService>();
|
|
services.AddScoped<IPdfPartitionerRunInfoService, PdfPartitionerRunInfoService>();
|
|
services.AddScoped<IPdfPartitionerLogService, PdfPartitionerLogService>();
|
|
services.AddScoped<IMemberNotificationInfoService, MemberNotificationInfoService>();
|
|
services.AddScoped<IMemberDocumentNotifierService, MemberDocumentNotifierService>();
|
|
services.AddScoped<IMemberNotificationCompletionService, MemberNotificationCompletionService>();
|
|
services.AddScoped<IOsgPreprocessorService, OsgPreprocessorService>();
|
|
services.AddScoped<IOsgPreprocessorInfoService, OsgPreprocessorInfoService>();
|
|
services.AddTransient<IResponseQueue, ResponseQueue>();
|
|
|
|
AddIngestionOperationServices(services);
|
|
AddQueueServices(services);
|
|
AddIngestorIndexServices(services);
|
|
AddIngestorPdfIndexServices(services);
|
|
AddIngestorPdfParserServices(services);
|
|
AddIngestorProcessingServices(services);
|
|
AddMemberNotificationInfoDeterminingServices(services);
|
|
AddMicroApiServices(services);
|
|
AddValueDeterminingServices(services);
|
|
}
|
|
|
|
void AddIngestionOperationServices(IServiceCollection services)
|
|
{
|
|
services.AddScoped<IBatchIngestionService, BatchIngestionService>();
|
|
services.AddScoped<IIndexService, IndexService>();
|
|
services.AddScoped<IDocumentProcessorService, DocumentProcessorService>();
|
|
services.AddScoped<ICompletionService, CompletionService>();
|
|
services.AddScoped<IIngestionFolderCleanUpService, IngestionFolderCleanUpService>();
|
|
services.AddScoped<IPdfPartitionerService, PdfPartitionerService>();
|
|
services.AddScoped<IPdfPartitionerCompletionService, PdfPartitionerCompletionService>();
|
|
services.AddScoped<IUploadCompletionService, UploadCompletionService>();
|
|
services.AddScoped<IGatherMemberNotificationInfoService, GatherMemberNotificationInfoService>();
|
|
services.AddScoped<IBatchUpdateMemberNotificationDataService, BatchUpdateMemberNotificationDataService>();
|
|
}
|
|
|
|
void AddQueueServices(IServiceCollection services)
|
|
{
|
|
services.AddScoped<IQueueBatchIngestionService, QueueBatchIngestionService>();
|
|
services.AddScoped<IQueueDocumentIngestorService, QueueDocumentIngestorService>();
|
|
services.AddScoped<IQueueDocumentProcessingService, QueueDocumentProcessingService>();
|
|
services.AddScoped<IQueueCompletionService, QueueCompletionService>();
|
|
services.AddScoped<IQueueIngestionFolderCleanUpService, QueueIngestionFolderCleanUpService>();
|
|
services.AddScoped<IQueuePdfPartitionerService, QueuePdfPartitionerService>();
|
|
services.AddScoped<IQueuePdfPartitionerCompletionService, QueuePdfPartitionerCompletionService>();
|
|
services.AddScoped<IQueueMemberDocumentNotifierService, QueueMemberDocumentNotifierService>();
|
|
services.AddScoped<IQueueMemberNotificationCompletionService, QueueMemberNotificationCompletionService>();
|
|
services.AddScoped<IQueueGatherMemberNotificationInfoService, QueueGatherMemberNotificationInfoService>();
|
|
services.AddScoped<IQueueBatchUpdateMemberNotificationDataService, QueueBatchUpdateMemberNotificationDataService>();
|
|
services.AddScoped<IQueueProcessStatusTypeEmailService, QueueProcessStatusTypeEmailService>();
|
|
}
|
|
|
|
void AddIngestorIndexServices(IServiceCollection services)
|
|
{
|
|
services.AddScoped<IIndexParserService, FosTaxStatementIndexService>();
|
|
services.AddScoped<IIndexParserService, FosDnaDocumentIndexService>();
|
|
services.AddScoped<IIndexParserService, FosLoanStatementIndexService>();
|
|
services.AddScoped<IIndexParserService, OsgDnaNoticesIndexService>();
|
|
services.AddScoped<IIndexParserService, OsgHistoricalDocumentIndexService>();
|
|
services.AddScoped<IIndexParserService, XdiDnaNoticeDocumentIndexService>();
|
|
services.AddScoped<IIndexParserService, XdiActionNoticeDocumentIndexService>();
|
|
services.AddScoped<IIndexParserService, OsgWeilandStatementIndexService>();
|
|
services.AddScoped<IIndexParserService, OsgTaxStatementIndexService>();
|
|
services.AddScoped<IIndexParserService, OsgDnaNoticeSplitIndexService>();
|
|
services.AddScoped<IIndexParserService, OsgTemenosNoticeDocumentIndexService>();
|
|
services.AddScoped<IIndexParserService, OsgVehicleTaxStatementIndexService>();
|
|
}
|
|
|
|
void AddIngestorPdfIndexServices(IServiceCollection services)
|
|
{
|
|
services.AddScoped<IPdfIndexParserService, FosLoanStatementIndexService>();
|
|
services.AddScoped<IPdfIndexParserService, OsgDnaNoticesIndexService>();
|
|
services.AddScoped<IPdfIndexParserService, OsgHistoricalDocumentIndexService>();
|
|
}
|
|
|
|
void AddIngestorPdfParserServices(IServiceCollection services)
|
|
{
|
|
services.AddScoped<IPdfParserService, FosLoanStatementPdfService>();
|
|
services.AddScoped<IPdfParserService, OsgDnaNoticesPdfService>();
|
|
services.AddScoped<IPdfParserService, OsgHistoricalDocumentPdfService>();
|
|
}
|
|
|
|
void AddIngestorProcessingServices(IServiceCollection services)
|
|
{
|
|
services.AddScoped<IDocumentProcessingService, FosTaxStatementProcessingService>();
|
|
services.AddScoped<IDocumentProcessingService, FosDnaDocumentProcessingService>();
|
|
services.AddScoped<IDocumentProcessingService, FosLoanStatementProcessingService>();
|
|
services.AddScoped<IDocumentProcessingService, OsgDnaNoticesProcessingService>();
|
|
services.AddScoped<IDocumentProcessingService, OsgHistoricalDocumentProcessingService>();
|
|
services.AddScoped<IDocumentProcessingService, XdiDnaNoticeDocumentProcessingService>();
|
|
services.AddScoped<IDocumentProcessingService, XdiActionNoticesProcessingService>();
|
|
services.AddScoped<IDocumentProcessingService, OsgWeilandStatementProcessingService>();
|
|
services.AddScoped<IDocumentProcessingService, OsgTaxStatementProcessingService>();
|
|
services.AddScoped<IDocumentProcessingService, OsgDnaNoticeSplitProcessingService>();
|
|
services.AddScoped<IDocumentProcessingService, OsgTemenosNoticeProcessingService>();
|
|
services.AddScoped<IDocumentProcessingService, OsgVehicleTaxStatementProcessingService>();
|
|
}
|
|
|
|
void AddMemberNotificationInfoDeterminingServices(IServiceCollection services)
|
|
{
|
|
services.AddScoped<IMemberNotificationInfoDeterminingService, MemberNotificationInfoDeterminingService>();
|
|
services.AddScoped<IPrimaryNotificationInfoDeterminingService, PrimaryNotificationInfoDeterminingService>();
|
|
services.AddScoped<IAccountNotificationInfoDeterminingService, AccountNotificationInfoDeterminingService>();
|
|
}
|
|
|
|
void AddMicroApiServices(IServiceCollection services)
|
|
{
|
|
services.AddScoped<IDocumentTypeUploaderApiService, DocumentTypeUploaderApiService>();
|
|
services.AddScoped<IFileOperationsApiService, FileOperationsApiService>();
|
|
services.AddScoped<INotificationApiService, NotificationApiService>();
|
|
services.AddScoped<ICoreApiWrapperService, CoreApiWrapperService>();
|
|
services.AddScoped<IDocumentTypeRetrieverService, DocumentTypeRetrieverService>();
|
|
services.AddScoped<IMemberPreferencesApiService, MemberPreferencesApiService>();
|
|
}
|
|
|
|
void AddValueDeterminingServices(IServiceCollection services)
|
|
{
|
|
services.AddScoped<IPrimaryOwnerDeterminingService, PrimaryOwnerDeterminingService>();
|
|
services.AddScoped<IAccountOwnerDeterminingService, AccountOwnerDeterminingService>();
|
|
}
|
|
|
|
void AddDocumentIngestorDaos(IServiceCollection services)
|
|
{
|
|
services.AddScoped<IDocumentTypeUploaderApiDao, DocumentTypeUploaderApiDao>();
|
|
services.AddScoped<ICoreApiWrapperDao, CoreApiWrapperDao>();
|
|
services.AddScoped<IFileOperationsApiDao, FileOperationsApiDao>();
|
|
services.AddScoped<INotificationApiDao, NotificationApiDao>();
|
|
services.AddScoped<IDocumentTypeRetrieverDao, DocumentTypeRetrieverDao>();
|
|
services.AddScoped<IMemberPreferencesApiDao, MemberPreferencesApiDao>();
|
|
}
|
|
|
|
void AddDocumentIngestorLib(ref IServiceCollection services)
|
|
{
|
|
services.AddScoped<IUnitOfWork, UnitOfWork>();
|
|
services.AddScoped<IIngestorRunInfoRepository, IngestorRunInfoRepository>();
|
|
services.AddScoped<IDocumentProcessingInfoRepository, DocumentProcessingInfoRepository>();
|
|
services.AddScoped<IOwnerOverrideInfoRepository, OwnerOverrideInfoRepository>();
|
|
services.AddScoped<IProcessingLogRepository, ProcessingLogRepository>();
|
|
services.AddScoped<IDocumentTypeArchiveDeleteInfoRepository, DocumentTypeArchiveDeleteInfoRepository>();
|
|
services.AddScoped<IPdfPartitionerRunInfoRepository, PdfPartitionerRunInfoRepository>();
|
|
services.AddScoped<IPdfPartitionerLogRepository, PdfPartitionerLogRepository>();
|
|
services.AddScoped<IMemberNotificationInfoRepository, MemberNotificationInfoRepository>();
|
|
services.AddScoped<IOsgPreprocessorInfoRepository, OsgPreprocessorInfoRepository>();
|
|
}
|
|
|
|
void BuildAppAndRun(WebApplicationBuilder builder)
|
|
{
|
|
var app = builder.Build();
|
|
|
|
// Configure the HTTP request pipeline.
|
|
if (app.Environment.IsDevelopment())
|
|
{
|
|
app.UseDeveloperExceptionPage();
|
|
}
|
|
|
|
app.UseSwagger(c=>
|
|
{
|
|
c.PreSerializeFilters.Add((swaggerDoc, request) =>
|
|
{
|
|
const string prefixHeader = "X-Forwarded-Prefix";
|
|
if (!request.Headers.ContainsKey(prefixHeader)) return;
|
|
|
|
var serverUrl = request.Headers[prefixHeader];
|
|
swaggerDoc.Servers = new List<OpenApiServer>()
|
|
{
|
|
new() { Description = serverUrl, Url = serverUrl }
|
|
};
|
|
});
|
|
});
|
|
app.UseSwaggerUI(c =>
|
|
{
|
|
c.RoutePrefix = "swagger";
|
|
c.SwaggerEndpoint("v1/swagger.json", "LCU.API.Internal.DocumentIngestor v1");
|
|
c.OAuthClientId(app.Configuration.GetSection("AzureAd")["ClientId"]);
|
|
c.OAuthUsePkce();
|
|
c.OAuthScopes(app.Configuration.GetSection("Swagger")["OAuthScope"]);
|
|
});
|
|
app.UseMiddleware<RequestResponseLoggingMiddleware>();
|
|
app.UseSerilogRequestLogging(options =>
|
|
{
|
|
options.EnrichDiagnosticContext = RequestResponseLoggingMiddleware.RequestDataParser.EnrichFromRequest;
|
|
});
|
|
|
|
app.UseRouting();
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
app.UseCors(MyAllowSpecificOrigins);
|
|
app.UseHttpsRedirection();
|
|
app.MapControllers();
|
|
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
|
|
|
|
app.Run();
|
|
}
|