using Microsoft.Data.SqlClient; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using PARR.AIHITLoader.Context; using PARR.AIHITLoader.Models; namespace PARR.AIHITLoader.Services { internal class AIHITService : IAIHITService { private readonly AIHITContext context; private readonly ILogger logger; public AIHITService(AIHITContext context, ILogger logger) { this.context = context; this.logger = logger; } public List? GetEKList(string respArea) { var parameters = new List() { new SqlParameter("@зо", respArea) }; try { var result = context.Set().FromSqlRaw($"EXEC mao2.dbo.sp_IPP_PARR_PTK_get_EK @зо", parameters.ToArray()).ToList(); if (result == null || !result.Any()) { logger.LogWarning($"Процедура sp_IPP_PARR_PTK_get_EK вернула пустой список ЭК"); } return result; } catch (Exception ex) { logger.LogError(ex, $"Ошибка при выполнении ХП sp_IPP_PARR_PTK_get_EK({respArea})"); } return null; } } }