feat(aititMainLoader): Сделана основная логика загрущки данных из АИХ ИТ в очередь сообщений
This commit is contained in:
71
PARR.AIHITMainLoader/Services/AihitService.cs
Normal file
71
PARR.AIHITMainLoader/Services/AihitService.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.AIHITMainLoader.Context;
|
||||
using PARR.AIHITMainLoader.Models;
|
||||
|
||||
namespace PARR.AIHITMainLoader.Services
|
||||
{
|
||||
internal class AihitService : IAihitService
|
||||
{
|
||||
private readonly AIHITContext context;
|
||||
private readonly ILogger<AihitService> logger;
|
||||
|
||||
public AihitService(
|
||||
AIHITContext context,
|
||||
ILogger<AihitService> logger
|
||||
)
|
||||
{
|
||||
this.context = context;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<IMainData> GetPtkData(string respArea)
|
||||
{
|
||||
var parameters = new List<SqlParameter>() { new SqlParameter("@зо", respArea) };
|
||||
|
||||
try
|
||||
{
|
||||
var result = context.Set<PtkData>().FromSqlRaw($"EXEC mao2.dbo.sp_IPP_PARR_PTK_get_EK @зо", parameters.ToArray()).AsEnumerable();
|
||||
|
||||
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 new List<IMainData>();
|
||||
}
|
||||
|
||||
|
||||
public IEnumerable<IMainData> GetCvkData(string respArea)
|
||||
{
|
||||
var parameters = new List<SqlParameter>() { new SqlParameter("@зо", respArea) };
|
||||
|
||||
try
|
||||
{
|
||||
var result = context.Set<CvkData>().FromSqlRaw($"EXEC mao2.dbo.sp_IPP_PARR_PTK_get_EK_CVK @зо", parameters.ToArray()).AsEnumerable();
|
||||
|
||||
if (result == null || !result.Any())
|
||||
{
|
||||
logger.LogWarning($"Процедура sp_IPP_PARR_PTK_get_EK_CVK вернула пустой список ЭК");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, $"Ошибка при выполнении ХП sp_IPP_PARR_PTK_get_EK_CVK({respArea})");
|
||||
}
|
||||
|
||||
return new List<IMainData>();
|
||||
}
|
||||
}
|
||||
}
|
||||
10
PARR.AIHITMainLoader/Services/IAihitService.cs
Normal file
10
PARR.AIHITMainLoader/Services/IAihitService.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using PARR.AIHITMainLoader.Models;
|
||||
|
||||
namespace PARR.AIHITMainLoader.Services
|
||||
{
|
||||
internal interface IAihitService
|
||||
{
|
||||
IEnumerable<IMainData> GetPtkData(string respArea);
|
||||
IEnumerable<IMainData> GetCvkData(string respArea);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user