ApiAipService.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using AipGateway.AIP;
  2. using AipGateway.API.Application.Modules;
  3. using AipGateway.API.Domain.Models;
  4. namespace AipGateway.API.Services.impl
  5. {
  6. public class ApiAipService : IApiAipService
  7. {
  8. private readonly ILogger<ApiFileService> _log;
  9. private readonly IServiceProvider _provider;
  10. public ApiAipService(ILogger<ApiFileService> logger, IServiceProvider provider)
  11. {
  12. _log = logger;
  13. _provider = provider;
  14. _log.LogError("ooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo: ApiAipService");
  15. }
  16. public async Task<ApiResponseDto> DownloadAipInfo()
  17. {
  18. try
  19. {
  20. //AipFileApiService? aipFileApiService = ContainerService.provider.GetService<AipFileApiService>();
  21. AipFileApiService? aipFileApiService = _provider.GetService<AipFileApiService>();
  22. if (aipFileApiService == null)
  23. {
  24. return new ApiResponseDto
  25. {
  26. errorCode = 1,
  27. errorMessage = "AIP File 관리 서비스를 찾을 수 없습니다.",
  28. effectCount = 0,
  29. };
  30. }
  31. var task = Task.Run(() =>
  32. {
  33. aipFileApiService.DownloadAipFileInformations();
  34. return ContainerService.aipLableMap.Count + ContainerService.aipPolicyMap.Count + ContainerService.aipProtectionMap.Count;
  35. });
  36. int result = await task;
  37. return new ApiResponseDto
  38. {
  39. errorCode = 0,
  40. errorMessage = GlobalConstants.API_RESULT_SUCCESS,
  41. effectCount = result,
  42. };
  43. }
  44. catch (Exception)
  45. {
  46. throw;
  47. }
  48. }
  49. public async Task<List<AipLabel>> GetLabels()
  50. {
  51. try
  52. {
  53. var task = Task.Run(() =>
  54. {
  55. return ContainerService.aipFileManager.SensitivityLabels();
  56. });
  57. List<AipLabel> result = await task;
  58. return result;
  59. }
  60. catch (Exception)
  61. {
  62. throw;
  63. }
  64. }
  65. public async Task<List<AipLabel>> GetPolicies()
  66. {
  67. try
  68. {
  69. var task = Task.Run(() =>
  70. {
  71. return ContainerService.aipFileManager.ListSensitivityLabels();
  72. });
  73. List<AipLabel> result = await task;
  74. return result;
  75. }
  76. catch (Exception)
  77. {
  78. throw;
  79. }
  80. }
  81. public async Task<List<AipTemplate>> GetProtections()
  82. {
  83. try
  84. {
  85. var task = Task.Run(() =>
  86. {
  87. return ContainerService.aipFileManager.GetTemplates();
  88. });
  89. List<AipTemplate> result = await task;
  90. return result;
  91. }
  92. catch (Exception)
  93. {
  94. throw;
  95. }
  96. }
  97. }
  98. }