AIHITService
This commit is contained in:
@@ -3,8 +3,7 @@ using MailKit.Search;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MimeKit;
|
||||
using PARR.AIHIT.Context;
|
||||
using PARR.AIHIT.Models;
|
||||
using PARR.AIHIT.Services;
|
||||
using PARR.AIHIT.Settings;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Extensions;
|
||||
@@ -36,6 +35,8 @@ namespace PARR.AIHIT
|
||||
private readonly IApplicationInHostService appInHostService;
|
||||
private readonly IRawDataEKService rawDataEKService;
|
||||
private readonly ISettingService settingService;
|
||||
private readonly IAIHITService aihitService;
|
||||
private readonly IApplicationService applicationService;
|
||||
|
||||
public List<ApplicationType> AppTypes { get; private set; } = new List<ApplicationType>();
|
||||
|
||||
@@ -53,7 +54,8 @@ namespace PARR.AIHIT
|
||||
IApplicationTypeService appTypeService,
|
||||
IApplicationInHostService appInHostService,
|
||||
IRawDataEKService rawDataEKService,
|
||||
ISettingService settingService
|
||||
ISettingService settingService,
|
||||
IAIHITService aihitService
|
||||
)
|
||||
{
|
||||
this.hostService = hostService;
|
||||
@@ -63,6 +65,7 @@ namespace PARR.AIHIT
|
||||
this.appInHostService = appInHostService;
|
||||
this.rawDataEKService = rawDataEKService;
|
||||
this.settingService = settingService;
|
||||
this.aihitService = aihitService;
|
||||
this.logger = logger;
|
||||
this.mailService = mailService;
|
||||
this.syncherSettings = syncherSettings;
|
||||
@@ -219,25 +222,11 @@ namespace PARR.AIHIT
|
||||
//Запускаем хранимую процедуру в АИХ ИТ и складываем в таблицу RawDataEKs, предварительно почистив старые данные
|
||||
foreach (var respArea in respAreas)
|
||||
{
|
||||
var eksFromAIHIT = new List<EK>();
|
||||
using (AIHContext db = new AIHContext())
|
||||
{
|
||||
var zo = new Microsoft.Data.SqlClient.SqlParameter
|
||||
{
|
||||
ParameterName = "@зо",
|
||||
SqlDbType = System.Data.SqlDbType.NVarChar,
|
||||
Direction = System.Data.ParameterDirection.Input,
|
||||
Size = 60,
|
||||
Value = respArea.Value
|
||||
};
|
||||
eksFromAIHIT = db.EKs.FromSqlRaw($"EXEC mao2.dbo.sp_IPP_PARR_PTK_get_EK @зо", zo).ToList();
|
||||
if (eksFromAIHIT == null || !eksFromAIHIT.Any())
|
||||
{
|
||||
logger.LogWarning($"Процедура sp_IPP_PARR_PTK_get_EK вурнула пустой список ЭК");
|
||||
return;
|
||||
var eksFromAIHIT = aihitService.GetEKList(respArea.Value)?.ToList();
|
||||
|
||||
if (eksFromAIHIT == null)
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
//Удаляем текущие данные по зоне ответственности respArea
|
||||
var toDelete = rawDataEKService.Get().Where(rd => rd.ResponseArea == respArea.Value).ToList();
|
||||
toDelete.ForEach(d => rawDataEKService.Delete(d));
|
||||
@@ -245,55 +234,10 @@ namespace PARR.AIHIT
|
||||
foreach (var ek in eksFromAIHIT)
|
||||
{
|
||||
// создаем
|
||||
var mappedEK = new RawDataEK()
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
DateCreated = DateTimeOffset.UtcNow,
|
||||
IP = ek.IP,
|
||||
Metka = ek.Metka,
|
||||
IsActive = ek.IsActive,
|
||||
IsImportant = ek.IsImportant,
|
||||
CreateTime = ek.CreateTime.ToString(),
|
||||
AdditionalInfo = ek.AdditionalInfo,
|
||||
ResponseArea = ek.ResponseArea,
|
||||
EKCategory = ek.EKCategory,
|
||||
EKFindCode = ek.EKFindCode,
|
||||
ProductCode = ek.ProductCode,
|
||||
ServiceCode = ek.ServiceCode,
|
||||
ShortName = ek.ShortName,
|
||||
ResponsibleByEK = ek.ResponsibleByEK,
|
||||
PlannedTimeToRepair = ek.PlannedTimeToRepair.ToString(),
|
||||
EKSubCategory = ek.EKSubCategory,
|
||||
FullName = ek.FullName,
|
||||
Prescription = ek.Prescription,
|
||||
Company = ek.Company,
|
||||
WorkGroup = ek.WorkGroup,
|
||||
Location = ek.Location,
|
||||
EKRevizor = ek.EKRevizor,
|
||||
EKRegister = ek.EKRegister,
|
||||
NetworkName = ek.NetworkName,
|
||||
Status = ek.Status,
|
||||
EKType = ek.EKType,
|
||||
EndExplotationDate = ek.EndExplotationDate.ToString(),
|
||||
StartExplotationDate = ek.StartExplotationDate.ToString(),
|
||||
TargetRepairTime = ek.TargetRepairTime,
|
||||
SysModTime = ek.SysModTime.ToString(),
|
||||
SysModUser = ek.SysModUser,
|
||||
NewEKFindCode = ek.NewEKFindCode,
|
||||
OldEKFindCode = ek.OldEKFindCode,
|
||||
CTSDirection = ek.CTSDirection,
|
||||
AIHID = ek.ID,
|
||||
IsUnreliableData = ek.IsUnreliableData,
|
||||
ShiftWorkGroup = ek.ShiftWorkGroup,
|
||||
ClientSoftware = ek.ClientSoftware,
|
||||
ClientOS = ek.ClientOS,
|
||||
DBType = ek.DBType,
|
||||
APPType = ek.APPType,
|
||||
CKBSServerType = ek.CKBSServerType,
|
||||
IBServerType = ek.IBServerType,
|
||||
InfrastructureServerType = ek.InfrastructureServerType,
|
||||
MonitoringServerType = ek.MonitoringServerType
|
||||
};
|
||||
var mappedEK = mapper.Map<RawDataEK>(ek);
|
||||
|
||||
mappedEK.Id = Guid.NewGuid();
|
||||
mappedEK.DateCreated = DateTimeOffset.UtcNow;
|
||||
|
||||
if (!await rawDataEKService.CreateAsync(mappedEK) || !await rawDataEKService.CommitAsync())
|
||||
{
|
||||
@@ -347,7 +291,7 @@ namespace PARR.AIHIT
|
||||
foundHost.Status = mappedHost.Status;
|
||||
isChanged = true;
|
||||
}
|
||||
else if (!foundHost.WorkGroup!.Equals(mappedHost.WorkGroup))
|
||||
else if (mappedHost.WorkGroup != null && !foundHost.WorkGroup!.Equals(mappedHost.WorkGroup))
|
||||
{
|
||||
foundHost.WorkGroup = mappedHost.WorkGroup;
|
||||
isChanged = true;
|
||||
|
||||
Reference in New Issue
Block a user