49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
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<AihitService> logger;
|
|
private readonly AIHITContext context;
|
|
|
|
public AihitService(
|
|
ILogger<AihitService> logger,
|
|
AIHITContext context
|
|
)
|
|
{
|
|
this.logger = logger;
|
|
this.context = context;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Получение данных из АИХ ИТ вызовом хранимой процедуры в базе данных
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public IEnumerable<AihitData>? 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;
|
|
}
|
|
}
|
|
}
|