ApiDbService.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. 
  2. using Aip.Service.Models.Dto;
  3. using Aip.Service.Models.Response;
  4. using Aip.Service.Repositories;
  5. using Aip.Service.Services.Interfaces;
  6. namespace Aip.Service.Services;
  7. public class ApiDbService : BaseService, IApiDbService
  8. {
  9. private readonly ILogger<ApiDbService> _log;
  10. private readonly IApiAuthService _apiAuthService;
  11. private readonly IAipDbRepository _repo;
  12. public ApiDbService(ILogger<ApiDbService> log, IApiConfigService aipConfigService, IApiAuthService apiAuthService, IAipDbRepository repo)
  13. : base(aipConfigService)
  14. {
  15. _log = log;
  16. _apiAuthService = apiAuthService;
  17. _repo = repo;
  18. }
  19. public async Task<GeneralResponse> ReloadDatabase()
  20. {
  21. try
  22. {
  23. var task = Task.Run(() =>
  24. {
  25. int result = _apiAuthService.LoadAuthInformation();
  26. return result;
  27. });
  28. int result = await task;
  29. return new GeneralResponse
  30. {
  31. errorCode = 0,
  32. errorMessage = GlobalConstants.API_RESULT_SUCCESS,
  33. effectCount = result,
  34. };
  35. }
  36. catch (Exception)
  37. {
  38. throw;
  39. }
  40. }
  41. public async Task<List<LinkedSystemDto>> GetLinkedSystems()
  42. {
  43. try
  44. {
  45. var result = await _repo.GetLinkedSystems();
  46. return result;
  47. }
  48. catch (Exception)
  49. {
  50. throw;
  51. }
  52. }
  53. public async Task<List<LinkedServerDto>> GetLinkedServers()
  54. {
  55. try
  56. {
  57. var result = await _repo.GetLinkedServers();
  58. return result;
  59. }
  60. catch (Exception)
  61. {
  62. throw;
  63. }
  64. }
  65. public async Task<List<LinkedApiKeyDto>> GetLinkedApiKeys()
  66. {
  67. try
  68. {
  69. var result = await _repo.GetLinkedApiKeys();
  70. return result;
  71. }
  72. catch (Exception)
  73. {
  74. throw;
  75. }
  76. }
  77. public async Task<List<LinkedDecryptKeyDto>> GetLinkedDecryptKeys()
  78. {
  79. try
  80. {
  81. var result = await _repo.GetLinkedDecryptKeys();
  82. return result;
  83. }
  84. catch (Exception)
  85. {
  86. throw;
  87. }
  88. }
  89. }