AuthKeyLoadingInvocable.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using AipGateway.AIP;
  2. using AipGateway.API.Application.Interfaces.Services;
  3. using AipGateway.API.Domain.Models.App;
  4. using AipGateway.API.Domain.Models.Response;
  5. using AipGateway.API.Services;
  6. using AipGateway.API.Services.Interfaces;
  7. using Coravel.Invocable;
  8. using System.Diagnostics;
  9. namespace AipGateway.API.Scheduler
  10. {
  11. public class AuthKeyLoadingInvocable : IInvocable
  12. {
  13. private readonly ILogger<AuthKeyLoadingInvocable> _log;
  14. private readonly IApiAuthService _apiAuthService;
  15. public AuthKeyLoadingInvocable(ILogger<AuthKeyLoadingInvocable> log, IApiAuthService apiAuthService)
  16. {
  17. _log = log;
  18. _apiAuthService = apiAuthService;
  19. }
  20. public Task Invoke()
  21. {
  22. Stopwatch sw = Stopwatch.StartNew();
  23. sw.Start();
  24. _log.LogInformation("*** AuthKeyLoadingInvocable Schedule Job Start.");
  25. try
  26. {
  27. //var task = Task.Run(() =>
  28. //{
  29. _apiAuthService.LoadAuthInformation();
  30. //});
  31. //await task;
  32. }
  33. catch (Exception e)
  34. {
  35. _log.LogError($"*** AuthKeyLoadingInvocable.LoadLinkedApiKeys Exception: {e}");
  36. }
  37. sw.Stop();
  38. _log.LogInformation("*** AuthKeyLoadingInvocable Schedule Job ..End. {0,6} ms.", sw.ElapsedMilliseconds.ToString("#,##0"));
  39. return Task.CompletedTask;
  40. }
  41. }
  42. }