diff --git a/AAIntegration.SimmonsBank.API/.gitignore b/AAIntegration.SimmonsBank.API/.gitignore index 425fb64..2a711d1 100644 --- a/AAIntegration.SimmonsBank.API/.gitignore +++ b/AAIntegration.SimmonsBank.API/.gitignore @@ -23,6 +23,7 @@ bin/ Bin/ obj/ Obj/ +screenshots/ # Sample Data /SampleData diff --git a/AAIntegration.SimmonsBank.API/Services/CacheService.cs b/AAIntegration.SimmonsBank.API/Services/CacheService.cs index fa5f7c7..fcd4c5e 100644 --- a/AAIntegration.SimmonsBank.API/Services/CacheService.cs +++ b/AAIntegration.SimmonsBank.API/Services/CacheService.cs @@ -46,6 +46,7 @@ public class CacheService : ICacheService if (!internalKeys.TryGetValue(apiKey, out var clientId)) { _logger.LogInformation("Could not find API key. Returning -1."); + PrintInternalKeys(internalKeys); return -1; } diff --git a/AAIntegration.SimmonsBank.API/Services/PuppeteerService.cs b/AAIntegration.SimmonsBank.API/Services/PuppeteerService.cs index a5c5f5d..2ba821d 100644 --- a/AAIntegration.SimmonsBank.API/Services/PuppeteerService.cs +++ b/AAIntegration.SimmonsBank.API/Services/PuppeteerService.cs @@ -25,6 +25,8 @@ using Microsoft.Extensions.Logging; using NuGet.Protocol.Core.Types; using AAIntegration.SimmonsBank.API.Models.Accounts; using AAIntegration.SimmonsBank.API.Models.Transactions; +using System.Runtime.Serialization; +using Microsoft.Extensions.Logging.Console; public interface IPuppeteerService { @@ -175,6 +177,13 @@ public class PuppeteerService : IPuppeteerService { //_logger.LogWarning($"Login Task timed out for user '{user.Id}' after {timeout} seconds"); _logger.LogError(0, ex, prefix + $"Login Task timed out after {timeout} seconds"); + await page.ScreenshotAsync(GenerateScreenshotPath()); + + string selector = @"document.querySelector('body > banno-web > bannoweb-login').shadowRoot.querySelector('div > jha-card > jha-error-message').innerHTML"; + string errorMessage = await page.EvaluateExpressionAsync(selector) + .WaitAsync(timeout, cancellationToken); + _logger.LogError(errorMessage); + return false; } finally @@ -185,6 +194,11 @@ public class PuppeteerService : IPuppeteerService return false; } + private string GenerateScreenshotPath() + { + return "screenshots/" + DateTime.UtcNow.ToString("yyyy-MM-dd_HHmmss.ffffzzz") + ".png"; + } + public async Task IsLoggedIn(User user, CancellationToken cancellationToken) { string prefix = $"Task::IsLoggedIn - {user.Id} - "; diff --git a/AAIntegration.SimmonsBank.API/Workers/PuppeteerWorker.cs b/AAIntegration.SimmonsBank.API/Workers/PuppeteerWorker.cs index 561c543..b208faf 100644 --- a/AAIntegration.SimmonsBank.API/Workers/PuppeteerWorker.cs +++ b/AAIntegration.SimmonsBank.API/Workers/PuppeteerWorker.cs @@ -63,6 +63,9 @@ public class PuppeteerWorker : BackgroundService lastExecutedOn = DateTime.UtcNow; _logger.LogInformation("PuppeteerWorker executed at: {time}", DateTimeOffset.Now); + + // TEMPORARY DON'T COMMIT!!!! + await Task.Delay(TimeSpan.FromMinutes(120), stoppingToken); } } }