-
Notifications
You must be signed in to change notification settings - Fork 0
Added Generate Statement job #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
82 changes: 0 additions & 82 deletions
82
...rocessing.SchedulerService/TransactionProcessing.SchedulerService.Jobs/BaseBoostrapper.cs
This file was deleted.
Oops, something went wrong.
84 changes: 84 additions & 0 deletions
84
...onProcessing.SchedulerService/TransactionProcessing.SchedulerService.Jobs/Bootstrapper.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| namespace TransactionProcessing.SchedulerService.Jobs; | ||
|
|
||
| using System; | ||
| using System.Net.Http; | ||
| using System.Threading.Tasks; | ||
| using System.Threading; | ||
| using DataGeneration; | ||
| using EstateManagement.Client; | ||
| using EstateManagement.DataTransferObjects.Responses; | ||
| using Microsoft.Extensions.DependencyInjection; | ||
| using Quartz; | ||
| using SecurityService.Client; | ||
| using SecurityService.DataTransferObjects.Responses; | ||
| using TransactionProcessor.Client; | ||
|
|
||
| public static class Bootstrapper{ | ||
|
|
||
| internal static IJobExecutionContext JobExecutionContext; | ||
|
|
||
| internal static ServiceProvider ServiceProvider; | ||
|
|
||
| internal static IServiceCollection Services; | ||
|
|
||
| public static void ConfigureServices(IJobExecutionContext jobExecutionContext){ | ||
| Bootstrapper.Services = new ServiceCollection(); | ||
| Bootstrapper.JobExecutionContext = jobExecutionContext; | ||
|
|
||
| HttpClientHandler httpClientHandler = new HttpClientHandler{ | ||
| ServerCertificateCustomValidationCallback = (message, | ||
| cert, | ||
| chain, | ||
| errors) => { | ||
| return true; | ||
| } | ||
| }; | ||
| HttpClient httpClient = new HttpClient(httpClientHandler); | ||
|
|
||
| Bootstrapper.Services.AddSingleton(httpClient); | ||
| Bootstrapper.Services.AddSingleton<ISecurityServiceClient, SecurityServiceClient>(); | ||
| Bootstrapper.Services.AddSingleton<IEstateClient, EstateClient>(); | ||
| Bootstrapper.Services.AddSingleton<ITransactionProcessorClient, TransactionProcessorClient>(); | ||
| Bootstrapper.Services.AddSingleton<Func<String, String>>(container => serviceName => { return jobExecutionContext.MergedJobDataMap.GetString(serviceName); }); | ||
|
|
||
| Bootstrapper.ServiceProvider = Bootstrapper.Services.BuildServiceProvider(); | ||
| } | ||
|
|
||
| public static T GetService<T>() | ||
| { | ||
| return Bootstrapper.ServiceProvider.GetService<T>(); | ||
| } | ||
| } | ||
|
|
||
| public class BaseJob{ | ||
| protected ITransactionDataGenerator CreateTransactionDataGenerator(String clientId, String clientSecret, RunningMode runningMode){ | ||
| ISecurityServiceClient securityServiceClient = Bootstrapper.GetService<ISecurityServiceClient>(); | ||
| IEstateClient estateClient = Bootstrapper.GetService<IEstateClient>(); | ||
| TransactionProcessorClient transactionProcessorClient = Bootstrapper.GetService<TransactionProcessorClient>(); | ||
| Func<String, String> baseAddressFunc = Bootstrapper.GetService<Func<String, String>>(); | ||
|
|
||
| ITransactionDataGenerator g = new TransactionDataGenerator(securityServiceClient, | ||
| estateClient, | ||
| transactionProcessorClient, | ||
| baseAddressFunc("EstateManagementApi"), | ||
| baseAddressFunc("FileProcessorApi"), | ||
| baseAddressFunc("TestHostApi"), | ||
| clientId, | ||
| clientSecret, | ||
| 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 async Task<MerchantResponse> GetMerchant(String accessToken, Guid estateId, Guid merchantId, CancellationToken cancellationToken){ | ||
| IEstateClient estateClient = Bootstrapper.GetService<IEstateClient>(); | ||
| return await estateClient.GetMerchant(accessToken, estateId, merchantId, cancellationToken); | ||
| } | ||
| } | ||
33 changes: 0 additions & 33 deletions
33
...onProcessing.SchedulerService.Jobs/GenerateFileUploads/GenerateFileUploadsBootstrapper.cs
This file was deleted.
Oops, something went wrong.
100 changes: 0 additions & 100 deletions
100
...TransactionProcessing.SchedulerService.Jobs/GenerateFileUploads/GenerateFileUploadsJob.cs
This file was deleted.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
...ng.SchedulerService/TransactionProcessing.SchedulerService.Jobs/GenerateFileUploadsJob.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| namespace TransactionProcessing.SchedulerService.Jobs | ||
| { | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Threading.Tasks; | ||
| using DataGeneration; | ||
| using EstateManagement.DataTransferObjects.Responses; | ||
| using Quartz; | ||
|
|
||
| [DisallowConcurrentExecution] | ||
| public class GenerateFileUploadsJob : BaseJob, IJob | ||
| { | ||
| #region Methods | ||
| public async Task Execute(IJobExecutionContext context) | ||
| { | ||
| Bootstrapper.ConfigureServices(context); | ||
|
|
||
| String clientId = context.MergedJobDataMap.GetString("ClientId"); | ||
| String clientSecret = context.MergedJobDataMap.GetString("ClientSecret"); | ||
| Guid estateId = context.MergedJobDataMap.GetGuidValueFromString("EstateId"); | ||
| Guid merchantId = context.MergedJobDataMap.GetGuidValueFromString("MerchantId"); | ||
|
|
||
| String accessToken = await this.GetToken(clientId, | ||
| clientSecret, | ||
| context.CancellationToken); | ||
|
|
||
| ITransactionDataGenerator t = CreateTransactionDataGenerator(clientId, clientSecret, RunningMode.Live); | ||
|
|
||
| MerchantResponse merchant = await this.GetMerchant(accessToken, estateId, merchantId, context.CancellationToken); | ||
|
|
||
| List<ContractResponse> contracts = await t.GetMerchantContracts(merchant, context.CancellationToken); | ||
| DateTime fileDate = DateTime.Now; | ||
| foreach (ContractResponse contract in contracts){ | ||
| // Generate a file and upload | ||
| await t.SendUploadFile(fileDate, contract, merchant, context.CancellationToken); | ||
| } | ||
| } | ||
|
|
||
|
|
||
|
|
||
| #endregion | ||
| } | ||
| } |
26 changes: 26 additions & 0 deletions
26
...edulerService/TransactionProcessing.SchedulerService.Jobs/GenerateMerchantStatementJob.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| namespace TransactionProcessing.SchedulerService.Jobs; | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Threading.Tasks; | ||
| using DataGeneration; | ||
| using EstateManagement.DataTransferObjects.Responses; | ||
| using Quartz; | ||
|
|
||
| public class GenerateMerchantStatementJob : BaseJob, IJob | ||
| { | ||
| public async Task Execute(IJobExecutionContext context) | ||
| { | ||
| Bootstrapper.ConfigureServices(context); | ||
| String clientId = context.MergedJobDataMap.GetString("ClientId"); | ||
| String clientSecret = context.MergedJobDataMap.GetString("ClientSecret"); | ||
| Guid estateId = context.MergedJobDataMap.GetGuidValueFromString("EstateId"); | ||
|
|
||
| ITransactionDataGenerator t = this.CreateTransactionDataGenerator(clientId, clientSecret, RunningMode.Live); | ||
|
|
||
| List<MerchantResponse> merchants = await t.GetMerchants(estateId, context.CancellationToken); | ||
| foreach (MerchantResponse merchantResponse in merchants){ | ||
| await t.GenerateMerchantStatement(merchantResponse.EstateId, merchantResponse.MerchantId, DateTime.Now, context.CancellationToken); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / SonarCloud
Server certificates should be verified during SSL/TLS connections