Таблицы сырых данных АИХ ИТ

This commit is contained in:
Mikhail Kuznetsov
2023-08-11 09:21:54 +10:00
parent 2cc8af6af5
commit 23b9d5da56
4 changed files with 293 additions and 52 deletions

View File

@@ -7,8 +7,10 @@ using PARR.AIHIT.Context;
using PARR.AIHIT.Settings;
using PARR.DAL.Contracts;
using PARR.DAL.Extensions;
using PARR.DAL.Models.AIHIT;
using PARR.DAL.Models.V1;
using PARR.DAL.Services.Interfaces;
using PARR.DAL.Services.Interfaces.AIHIT;
using PARR.Mail.Services;
using System.Text;
using System.Xml;
@@ -25,6 +27,7 @@ namespace PARR.AIHIT
private readonly IApplicationService appService;
private readonly IApplicationTypeService appTypeService;
private readonly IApplicationInHostService appInHostService;
private readonly IRawDataEKService rawDataEKService;
public List<V1_ApplicationType> AppTypes { get; private set; } = new List<V1_ApplicationType>();
@@ -36,7 +39,8 @@ namespace PARR.AIHIT
IMapper mapper,
IApplicationService appService,
IApplicationTypeService appTypeService,
IApplicationInHostService appInHostService
IApplicationInHostService appInHostService,
IRawDataEKService rawDataEKService
)
{
this.hostService = hostService;
@@ -44,6 +48,7 @@ namespace PARR.AIHIT
this.appService = appService;
this.appTypeService = appTypeService;
this.appInHostService = appInHostService;
this.rawDataEKService = rawDataEKService;
this.logger = logger;
this.mailService = mailService;
this.syncherSettings = syncherSettings;
@@ -212,6 +217,7 @@ namespace PARR.AIHIT
public async Task InvokeFromDatabase()
{
var eksFromAIHIT = new List<EK>();
//call procedure
using (AIHContext db = new AIHContext())
{
@@ -223,15 +229,28 @@ namespace PARR.AIHIT
Size = 60,
Value = "96-ДВС"
};
//.EKs.FromSql("exec sp_IPP_PARR_PTK_get_EK '88-КРАСН'");
//.ToList();
//db.Database.ExecuteSqlRaw("mao2.dbo.sp_IPP_PARR_PTK_get_EK @userName", param);
//var isConExist = db.ex
//var result = await db.Database.ExecuteSqlRawAsync("mao2.dbo.sp_IPP_PARR_PTK_get_EK @зо", zo);
//WORK!!!!db.EKs.FromSql($"EXEC mao2.dbo.sp_IPP_PARR_PTK_get_EK '88-КРАСН'").ToList();
var result = db.EKs.FromSqlRaw($"EXEC mao2.dbo.sp_IPP_PARR_PTK_get_EK @зо", zo).ToList();
eksFromAIHIT = db.EKs.FromSqlRaw($"EXEC mao2.dbo.sp_IPP_PARR_PTK_get_EK @зо", zo).ToList();
}
if (!eksFromAIHIT.Any())
{
logger.LogWarning($"Процедура sp_IPP_PARR_PTK_get_EK вурнула пустой список ЭК");
return;
}
rawDataEKService.DeleteAll();
foreach (var ek in eksFromAIHIT)
{
// создаем
var mappedEK = mapper.Map<RawDataEK>(ek);
if (!await rawDataEKService.CreateAsync(mappedEK) || !await rawDataEKService.CommitAsync())
{
logger.LogError($"Не удалось создать запись rawDataEK {mappedEK.ShortName}({mappedEK.IP})");
continue;
}
else
logger.LogInformation($"----- Создана запись rawDataEK {mappedEK.ShortName}({mappedEK.IP}) -----");
}
//get raw data
//save data
}