Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Microsoft.Extensions.Logging;

namespace TransactionProcessing.SchedulerService.Jobs.Configuration;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Logging;

namespace TransactionProcessing.SchedulerService.Jobs.Configuration;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Logging;

namespace TransactionProcessing.SchedulerService.Jobs.Configuration;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Microsoft.Extensions.Logging;

namespace TransactionProcessing.SchedulerService.Jobs.Configuration;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Microsoft.Extensions.Logging;

namespace TransactionProcessing.SchedulerService.Jobs.Configuration;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Microsoft.Extensions.Logging;

namespace TransactionProcessing.SchedulerService.Jobs.Configuration;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Logging;

namespace TransactionProcessing.SchedulerService.Jobs.Configuration;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using NLog;
using Quartz;
using SecurityService.Client;
using SecurityService.DataTransferObjects.Responses;
using Shared.Logger;
using SimpleResults;
using TransactionProcessing.SchedulerService.DataGenerator;
using TransactionProcessing.SchedulerService.Jobs.Common;
using TransactionProcessing.SchedulerService.Jobs.Configuration;
using TransactionProcessor.Client;
using Logger = Shared.Logger.Logger;
using LogLevel = Microsoft.Extensions.Logging.LogLevel;

namespace TransactionProcessing.SchedulerService.Jobs.Jobs;

Expand All @@ -34,19 +37,11 @@ protected ITransactionDataGeneratorService CreateTransactionDataGenerator(String
runningMode);
return g;
}

//protected async Task<String> GetToken(String clientId, String clientSecret, CancellationToken cancellationToken)
//{
// ISecurityServiceClient securityServiceClient = Bootstrapper.GetService<ISecurityServiceClient>();
// TokenResponse token = await securityServiceClient.GetToken(clientId, clientSecret, cancellationToken);

// return token.AccessToken;
//}


protected void TraceGenerated(TraceEventArgs traceArguments)
{
if (traceArguments.TraceLevel == TraceEventArgs.Level.Error){
Logger.LogError(new Exception(traceArguments.Message));
Logger.LogError(traceArguments.Message, null);
}
else if (traceArguments.TraceLevel == TraceEventArgs.Level.Warning){
Logger.LogWarning(traceArguments.Message);
Expand All @@ -56,19 +51,21 @@ protected void TraceGenerated(TraceEventArgs traceArguments)
}
}

public abstract Task ExecuteJob(IJobExecutionContext context);
public abstract Task<Result> ExecuteJob(IJobExecutionContext context);

public async Task Execute(IJobExecutionContext context){

this.CacheConfiguration(context);
Logger.LogInformation($"Running Job Group: [{this.JobGroup}] Name: [{this.JobName}]");
//this.LogConfiguration();

Logger.LogWarning($"Running Job Group: [{this.JobGroup}] Name: [{this.JobName}]");

Bootstrapper.ConfigureServices(context, this.BaseConfiguration);
Result result = await this.ExecuteJob(context);
if (result.IsFailed){
Logger.LogWarning($"Job Group: [{this.JobGroup}] Name: [{this.JobName}] failed. Exception {result.Message}");
throw new JobExecutionException(result.Message);
}

await this.ExecuteJob(context);

Logger.LogInformation($"Job Group: [{this.JobGroup}] Name: [{this.JobName}] completed");
Logger.LogWarning($"Job Group: [{this.JobGroup}] Name: [{this.JobName}] completed");
}

private void CacheConfiguration(IJobExecutionContext context){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@

namespace TransactionProcessing.SchedulerService.Jobs.Jobs
{
using System;
using System.Threading.Tasks;
using Quartz;
using Shared.Logger;
using SimpleResults;
using System;
using System.Threading.Tasks;
using TransactionProcessing.SchedulerService.Jobs.Jobs;

[DisallowConcurrentExecution]
public class GenerateFileUploadsJob : BaseJob
{
#region Methods
public override async Task ExecuteJob(IJobExecutionContext context)
public override async Task<Result> ExecuteJob(IJobExecutionContext context)
{
FileUploadJobConfig configuration = Helpers.LoadJobConfig<FileUploadJobConfig>(context.MergedJobDataMap);

ITransactionDataGeneratorService t = CreateTransactionDataGenerator(configuration.ClientId, configuration.ClientSecret, RunningMode.Live);
t.TraceGenerated += TraceGenerated;
var result = await Jobs.GenerateFileUploads(t, configuration, context.CancellationToken);
if (result.IsFailed)
throw new JobExecutionException(result.Message);
return await Jobs.GenerateFileUploads(t, configuration, context.CancellationToken);
}
#endregion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@

namespace TransactionProcessing.SchedulerService.Jobs.Jobs;

using System;
using System.Threading.Tasks;
using Quartz;
using Shared.Logger;
using SimpleResults;
using System;
using System.Threading.Tasks;
using TransactionProcessing.SchedulerService.Jobs.Jobs;

public class GenerateMerchantStatementJob : BaseJob
{
public override async Task ExecuteJob(IJobExecutionContext context)
public override async Task<Result> ExecuteJob(IJobExecutionContext context)
{
MerchantStatementJobConfig configuration = Helpers.LoadJobConfig<MerchantStatementJobConfig>(context.MergedJobDataMap);

ITransactionDataGeneratorService t = CreateTransactionDataGenerator(configuration.ClientId, configuration.ClientSecret, RunningMode.Live);
t.TraceGenerated += TraceGenerated;
var result = await Jobs.GenerateMerchantStatements(t, configuration, context.CancellationToken);
if (result.IsFailed)
throw new JobExecutionException(result.Message);
return await Jobs.GenerateMerchantStatements(t, configuration, context.CancellationToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

namespace TransactionProcessing.SchedulerService.Jobs.Jobs
{
using System.Text.Json.Nodes;
using System.Threading.Tasks;
using Quartz;
using Shared.Logger;
using SimpleResults;
using System.Text.Json.Nodes;
using System.Threading.Tasks;
using TransactionProcessing.SchedulerService.DataGenerator;
using TransactionProcessing.SchedulerService.Jobs.Jobs;

Expand All @@ -19,16 +20,14 @@ public class GenerateTransactionsJob : BaseJob

#region Methods

public override async Task ExecuteJob(IJobExecutionContext context)
public override async Task<Result> ExecuteJob(IJobExecutionContext context)
{
TransactionJobConfig configuration = Helpers.LoadJobConfig<TransactionJobConfig>(context.MergedJobDataMap);

ITransactionDataGeneratorService t = CreateTransactionDataGenerator(configuration.ClientId, configuration.ClientSecret, RunningMode.Live);
t.TraceGenerated += TraceGenerated;

var result = await Jobs.GenerateTransactions(t, configuration, context.CancellationToken);
if (result.IsFailed)
throw new JobExecutionException(result.Message);
return await Jobs.GenerateTransactions(t, configuration, context.CancellationToken);
}
#endregion
}
Expand Down
Loading