Compare commits

..

No commits in common. "6ff4afd4a6da337335cc67b318f50f96f7c233e8" and "692e0ef96a5f4d19c16bad8674f5bed2af05a961" have entirely different histories.

5 changed files with 0 additions and 124 deletions

View File

@ -24,9 +24,6 @@ Bin/
obj/ obj/
Obj/ Obj/
# Sample Data
/SampleData
# Visual Studio 2015 cache/options directory # Visual Studio 2015 cache/options directory
.vs/ .vs/
/wwwroot/dist/ /wwwroot/dist/

View File

@ -1,9 +0,0 @@
using System.Threading.Tasks;
using AAIntegration.SimmonsBank.API.Services;
namespace AAIntegration.SimmonsBank.API.Processes;
public interface IPuppeteerProcess
{
Task FundEnvelopes();
}

View File

@ -1,53 +0,0 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using AAIntegration.SimmonsBank.API.Configs;
using AAIntegration.SimmonsBank.API.Entities;
using AAIntegration.SimmonsBank.API.Models.Transactions;
using AAIntegration.SimmonsBank.API.Services;
using Internal;
using Microsoft.Extensions.Options;
namespace AAIntegration.SimmonsBank.API.Processes;
public class PuppeteerProcess : IPuppeteerProcess
{
private readonly EnvelopeFundConfig _config;
private readonly ILogger<PuppeteerProcess> _logger;
public PuppeteerProcess(
IOptions<EnvelopeFundConfig> config,
ILogger<PuppeteerProcess> logger)
{
_config = config.Value;
_logger = logger;
}
public async Task FundEnvelopes()
{
_logger.LogInformation($"Starting envelope funding...");
// Grab envelopes
/*List<Envelope> envelopes = envelopeService.GetAll().ToList();
bool anyTriggered = false;
foreach (Envelope env in envelopes)
{
// Check if needs triggering
if (env.Enabled && !envelopeService.HasBeenFundedThisMonth(env.Id))
{
_logger.LogInformation($"Envelope '{env.Name}' (id={env.Id}) needs funding - Has now been triggered.");
anyTriggered = true;
// Fund Envelope
envelopeService.FundEnvelopeForThisMonth(env.Id);
}
}*/
if (false)
_logger.LogInformation($"No action taken.");
else
_logger.LogInformation($"Envelope funding complete.");
}
}

View File

@ -11,8 +11,6 @@ using Microsoft.IdentityModel.Tokens;
using System.Text; using System.Text;
//using Microsoft.Build.Framework; //using Microsoft.Build.Framework;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using AAIntegration.SimmonsBank.API.Processes;
using AAIntegration.SimmonsBank.API.Workers;
internal class Program internal class Program
{ {
@ -87,10 +85,6 @@ internal class Program
builder.Services.AddScoped<ApiKeyAuthenticationHandler>(); builder.Services.AddScoped<ApiKeyAuthenticationHandler>();
builder.Services.AddSingleton<IPuppeteerProcess, PuppeteerProcess>();
builder.Services.AddHostedService<PuppeteerWorker>();
var app = builder.Build(); var app = builder.Build();
// Apply Database Migrations - This is NOT recommended for multi-node deployment!!! // Apply Database Migrations - This is NOT recommended for multi-node deployment!!!

View File

@ -1,53 +0,0 @@
using System;
using AAIntegration.SimmonsBank.API.Configs;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using AAIntegration.SimmonsBank.API.Processes;
using AAIntegration.SimmonsBank.API.Services;
namespace AAIntegration.SimmonsBank.API.Workers;
public class PuppeteerWorker : BackgroundService
{
private readonly EnvelopeFundConfig _config;
private readonly IPuppeteerProcess _puppeteerProcess;
private readonly ILogger<PuppeteerWorker> _logger;
private readonly IServiceScopeFactory _serviceScopeFactory;
public PuppeteerWorker(
IOptions<EnvelopeFundConfig> config,
IPuppeteerProcess puppeteerProcess,
ILogger<PuppeteerWorker> logger,
IServiceScopeFactory serviceScopeFactory)
{
_config = config.Value;
_puppeteerProcess = puppeteerProcess;
_logger = logger;
_serviceScopeFactory = serviceScopeFactory;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
DateTime? lastExecutedOn = null;
using (var scope = _serviceScopeFactory.CreateScope())
{
//IEnvelopeService envelopeService = scope.ServiceProvider.GetService<IEnvelopeService>();
// This is how we keep the app running (in the background)
while (!stoppingToken.IsCancellationRequested)
{
if (lastExecutedOn != null)
{
int minutesRemaining = _config.CheckIntervalInMinutes - (int)DateTime.UtcNow.Subtract(lastExecutedOn.Value).TotalMinutes;
await Task.Delay(TimeSpan.FromMinutes(minutesRemaining < 0 ? 0 : minutesRemaining), stoppingToken);
}
lastExecutedOn = DateTime.UtcNow;
_logger.LogInformation("EnvelopeFundWorker running at: {time}", DateTimeOffset.Now);
//await _puppeteerProcess.FundEnvelopes(envelopeService);
}
}
}
}