Adding
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
using LCU.Api.Internal.MaidBotLib.Models;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Requests;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Services.Action;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Consumers;
|
||||
|
||||
public class ActionCreditCardConsumer : IConsumer<ActionCreditCardRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public ActionCreditCardConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<ActionCreditCardRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Debug("Starting Action Credit Card Process.");
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(async () => await scope.ServiceProvider.GetRequiredService<IActionCreditCardImportService>().RunActionCreditCardProcess(context.Message));
|
||||
Log.Debug("Finished Action Credit Card Process.");
|
||||
}
|
||||
catch (ServiceException serviceException)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(serviceException, $"Action Credit Card Failure. " +
|
||||
$"The Action Credit Card Process Request is placed on LCU.IncentiveApi.ActionCreditCardProcess_error.");
|
||||
throw;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Action Credit Card Failure. " +
|
||||
"The Action Credit Card Process Request is placed on LCU.IncentiveApi.ActionCreditCardProcess_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
using LCU.Api.Internal.MaidBotLib.Models;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Requests;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Services.Action;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Consumers;
|
||||
|
||||
public class ActionVehicleConsumer : IConsumer<ActionVehicleRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public ActionVehicleConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<ActionVehicleRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Debug("Starting Action Vehicle Process.");
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(async () => await scope.ServiceProvider.GetRequiredService<IActionVehicleImportService>().RunActionVehicleProcess(context.Message));
|
||||
Log.Debug("Finished Action Vehicle Process.");
|
||||
}
|
||||
catch (ServiceException serviceException)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(serviceException, $"Action Vehicle Failure. " +
|
||||
$"The Action Vehicle Process Request is placed on LCU.IncentiveApi.ActionVehicleProcess_error.");
|
||||
throw;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Action Vehicle Failure. " +
|
||||
"The Action Vehicle Process Request is placed on LCU.IncentiveApi.ActionVehicleProcess_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
using LCU.Api.Internal.MaidBotLib.Models;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Requests;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Services.Allied;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Consumers;
|
||||
|
||||
public class AlliedGapMbpConsumer : IConsumer<AlliedGapMbpRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public AlliedGapMbpConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<AlliedGapMbpRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Debug("Starting Allied Gap/Mbp Process.");
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(async () => await scope.ServiceProvider.GetRequiredService<IAlliedGapMbpTransactionImportService>().RunAlliedGapMbpProcess(context.Message));
|
||||
Log.Debug("Finished Allied Gap/Mbp Process.");
|
||||
}
|
||||
catch (ServiceException serviceException)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(serviceException, $"Allied Gap/Mbp Failure. " +
|
||||
$"The Allied Gap/Mbp Process Request is placed on LCU.IncentiveApi.AlliedGapMbpProcess_error.");
|
||||
throw;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Allied Gap/Mbp Failure. " +
|
||||
"The Allied Gap/Mbp Process Request is placed on LCU.IncentiveApi.AlliedGapMbpProcess_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
using LCU.Api.Internal.MaidBotLib.Models;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Requests;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Services.Dayforce;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Consumers;
|
||||
|
||||
public class DayforceSyncProcessConsumer : IConsumer<DayforceProcessRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public DayforceSyncProcessConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<DayforceProcessRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Debug("Starting Dayforce Sync Process.");
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(async () => await scope.ServiceProvider.GetRequiredService<IDayForceSyncService>().SyncDayForceUsers(context.Message));
|
||||
Log.Debug("Finished Dayforce Sync Process.");
|
||||
}
|
||||
catch (ServiceException serviceException)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(serviceException, $"Dayforce Sync Failure. " +
|
||||
$"The Dayforce Sync Process Request is placed on LCU.IncentiveApi.DayforceSyncProcess_error.");
|
||||
throw;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Dayforce Sync Failure. " +
|
||||
$"The Dayforce Sync Failure Process Request is placed on LCU.IncentiveApi.DayforceSyncProcess_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
using LCU.Api.Internal.MaidBotLib.Models;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Requests;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Services;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Consumers;
|
||||
|
||||
public class GoalDispersalConsumer : IConsumer<GoalDispersalRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public GoalDispersalConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<GoalDispersalRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Debug("Starting Goal Dispersal Process.");
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(async () => await scope.ServiceProvider.GetRequiredService<IGoalDispersalService>().ExecuteMonthStartDispersal(context.Message));
|
||||
Log.Debug("Finished Goal Dispersal Process.");
|
||||
}
|
||||
catch (ServiceException serviceException)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(serviceException, $"Goal Dispersal Failure. " +
|
||||
$"The Goal Dispersal Process Request is placed on LCU.IncentiveApi.GoalDispersalProcess_error.");
|
||||
throw;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Goal Dispersal Failure. " +
|
||||
$"The Goal Dispersal Process Request is placed on LCU.IncentiveApi.GoalDispersalProcess_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Services.Temenos;
|
||||
using LCU.Api.Internal.MaidBotLib.Models;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Requests;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Consumers;
|
||||
|
||||
public class ImportCreditCardSalesConsumer : IConsumer<ImportCreditCardSalesRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public ImportCreditCardSalesConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<ImportCreditCardSalesRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Debug("Starting HandleImportCreditCardSales.");
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(async () => await scope.ServiceProvider.GetRequiredService<IImportCreditCardSalesService>().HandleImportCreditCardSales(context.Message));
|
||||
Log.Debug("Finished HandleImportCreditCardSales.");
|
||||
}
|
||||
catch (ServiceException serviceException)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(serviceException, $"Import Credit Card Sales Failure. " +
|
||||
$"The Import Credit Card Sales Request is placed on LCU.IncentiveApi.ImportCreditCardSales_error.");
|
||||
throw;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Import Credit Card Sales Failure. " +
|
||||
$"The Import Credit Card Sales Request is placed on LCU.IncentiveApi.ImportCreditCardSales_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Services.Temenos;
|
||||
using LCU.Api.Internal.MaidBotLib.Models;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Requests;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Consumers;
|
||||
|
||||
public class ImportIndirectVehicleSalesConsumer : IConsumer<ImportIndirectVehicleSalesRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public ImportIndirectVehicleSalesConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<ImportIndirectVehicleSalesRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Debug("Starting HandleImportIndirectVehicleSales.");
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(async () => await scope.ServiceProvider.GetRequiredService<IImportIndirectVehicleSalesService>().HandleImportIndirectVehicleSales(context.Message));
|
||||
Log.Debug("Finished HandleImportIndirectVehicleSales.");
|
||||
}
|
||||
catch (ServiceException serviceException)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(serviceException, $"Import Indirect Vehicle Sales Failure. " +
|
||||
$"The Import Indirect Vehicle Sales Request is placed on LCU.IncentiveApi.ImportIndirectVehicleSales_error.");
|
||||
throw;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Import Indirect Vehicle Sales Failure. " +
|
||||
$"The Import Indirect Vehicle Sales Request is placed on LCU.IncentiveApi.ImportIndirectVehicleSales_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
using LCU.Api.Internal.MaidBotLib.Models;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Requests;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Consumers;
|
||||
|
||||
public class IncentiveProcessesConsumer : IConsumer<IncentiveProcessRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public IncentiveProcessesConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<IncentiveProcessRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(() => scope.ServiceProvider.GetRequiredService<IDnaActivitySyncService>().HandleProcessRequest(context.Message));
|
||||
}
|
||||
catch (ServiceException serviceException)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(serviceException, $"Incentive Process Failure. " +
|
||||
$"The Process Request is placed on LCU.IncentiveApi.Process_error.");
|
||||
throw;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Incentive Process Failure. " +
|
||||
"The Process Request is placed on LCU.IncentiveApi.Process_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
using LCU.Api.Internal.MaidBotLib.Models;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Requests;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Services.NightlyDecisionServices;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Consumers;
|
||||
|
||||
public class NightlyIncentiveProcessesConsumer : IConsumer<NightlyIncentiveProcessRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public NightlyIncentiveProcessesConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<NightlyIncentiveProcessRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(() => scope.ServiceProvider.GetRequiredService<INightlyActivityDecisionService>().HandleProcessRequest(context.Message));
|
||||
}
|
||||
catch (ServiceException serviceException)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(serviceException, $"Nightly Incentive Process Failure. " +
|
||||
$"The Nightly Incentive Process Request is placed on LCU.IncentiveApi.NightlyIncentiveProcess_error.");
|
||||
throw;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Nightly Incentive Process Failure. " +
|
||||
"The Nightly Incentive Process Request is placed on LCU.IncentiveApi.NightlyIncentiveProcess_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
using LCU.Api.Internal.MaidBotLib.Models;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Requests;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Services.Payout;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Consumers;
|
||||
|
||||
public class PayoutIncentiveConsumer : IConsumer<PayoutIncentiveRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public PayoutIncentiveConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<PayoutIncentiveRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Information("Starting Payout Incentive Process.");
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(async () => await scope.ServiceProvider.GetRequiredService<IPayoutService>().RunMonthlyIncentivePayouts(context.Message));
|
||||
Log.Information("Finished Payout Incentive Process.");
|
||||
}
|
||||
catch (ServiceException serviceException)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(serviceException, $"Payout Incentive Process Failure. " +
|
||||
$"The Payout Incentive Process Request is placed on LCU.IncentiveApi.PayoutIncentiveProcess_error.");
|
||||
throw;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Payout Incentive Process Failure. " +
|
||||
$"The Payout Incentive Process Request is placed on LCU.IncentiveApi.PayoutIncentiveProcess_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
using LCU.Api.Internal.MaidBotLib.Models;
|
||||
using LCU.Library.Internal.Exceptions;
|
||||
using LCU.Library.Internal.IncentiveApiModels.Requests;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using LCU.API.Internal.Operations.IncentiveApi.Services.Reporting;
|
||||
using MassTransit;
|
||||
|
||||
namespace LCU.API.Internal.Operations.IncentiveApi.Consumers;
|
||||
|
||||
public class ReportingConsumer : IConsumer<ReportingRequest>
|
||||
{
|
||||
private readonly IServiceScopeFactory _scopeFactory;
|
||||
|
||||
public ReportingConsumer(IServiceScopeFactory scopeFactory)
|
||||
{
|
||||
_scopeFactory = scopeFactory;
|
||||
}
|
||||
|
||||
public async Task Consume(ConsumeContext<ReportingRequest> context)
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Debug("Starting Reporting Process.");
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await Task.Run(async () => await scope.ServiceProvider.GetRequiredService<IReportingService>().HandleMonthlyReporting(context.Message));
|
||||
Log.Debug("Finished Reporting Process.");
|
||||
}
|
||||
catch (ServiceException serviceException)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Error(serviceException, $"Reporting Process Failure. " +
|
||||
$"The Reporting Process Request is placed on LCU.IncentiveApi.ReportingProcess_error.");
|
||||
throw;
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
||||
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
||||
.Fatal(exception, $"Reporting Process Failure. " +
|
||||
$"The Reporting Process Request is placed on LCU.IncentiveApi.ReportingProcess_error.");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user