ApiAipService.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using AipGateway.API.Application;
  2. using AipGateway.API.Application.Interfaces.Services;
  3. using AipGateway.API.Domain.Models.Response;
  4. using AipGateway.AIP.Service.Services.Interfaces;
  5. namespace AipGateway.AIP.Service.Services
  6. {
  7. public class ApiAipService : BaseService, IApiAipService
  8. {
  9. private readonly ILogger<ApiAipService> _log;
  10. public ApiAipService(ILogger<ApiAipService> log, IAipFileService aipFileService)
  11. : base(aipFileService)
  12. {
  13. _log = log;
  14. }
  15. public async Task<GeneralResponse> DownloadAipInfo()
  16. {
  17. try
  18. {
  19. var task = Task.Run(() =>
  20. {
  21. int result = _aipFileService.DownloadAipFileInformations();
  22. return result;
  23. });
  24. int result = await task;
  25. return new GeneralResponse
  26. {
  27. errorCode = 0,
  28. errorMessage = GlobalConstants.API_RESULT_SUCCESS,
  29. effectCount = result,
  30. };
  31. }
  32. catch (Exception e)
  33. {
  34. _log.LogError($"{e}");
  35. throw;
  36. }
  37. }
  38. public async Task<List<AipLabel>> GetLabels()
  39. {
  40. try
  41. {
  42. var task = Task.Run(() =>
  43. {
  44. return _aipFileService.aipFileManager.SensitivityLabels();
  45. });
  46. List<AipLabel> result = await task;
  47. return result;
  48. }
  49. catch (Exception)
  50. {
  51. throw;
  52. }
  53. }
  54. public async Task<List<AipLabel>> GetPolicies()
  55. {
  56. try
  57. {
  58. var task = Task.Run(() =>
  59. {
  60. return _aipFileService.aipFileManager.ListSensitivityLabels();
  61. });
  62. List<AipLabel> result = await task;
  63. return result;
  64. }
  65. catch (Exception)
  66. {
  67. throw;
  68. }
  69. }
  70. public async Task<List<AipTemplate>> GetProtections()
  71. {
  72. try
  73. {
  74. var task = Task.Run(() =>
  75. {
  76. return _aipFileService.aipFileManager.GetTemplates();
  77. });
  78. List<AipTemplate> result = await task;
  79. return result;
  80. }
  81. catch (Exception)
  82. {
  83. throw;
  84. }
  85. }
  86. }
  87. }