using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using PARR.AIHITRelationshipsSyncer.Context; using PARR.AIHITRelationshipsSyncer.Models; using PARR.AIHITRelationshipsSyncer.Services.Interfaces; namespace PARR.AIHITRelationshipsSyncer.Services.Implementations { internal class AihitService : IAihitService { private readonly ILogger logger; private readonly AIHITContext context; public AihitService( ILogger logger, AIHITContext context ) { this.logger = logger; this.context = context; } /// /// Получение данных из АИХ ИТ вызовом хранимой процедуры в базе данных /// /// public IEnumerable? GetData() { try { var result = context.AihitDatas.FromSqlRaw($"EXEC mao2.dbo.sp_IPP_PARR_PTK_get_Relationships").ToList(); if (result == null || !result.Any()) { logger.LogWarning($"Процедура sp_IPP_PARR_PTK_get_Relationships вернула пустой список ЭК"); } return result; } catch (Exception ex) { logger.LogError(ex, $"Ошибка при выполнении ХП sp_IPP_PARR_PTK_get_Relationships"); } return null; } } }