AIHITService
This commit is contained in:
@@ -1,16 +0,0 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using PARR.AIHIT.Models;
|
|
||||||
|
|
||||||
namespace PARR.AIHIT.Context
|
|
||||||
{
|
|
||||||
internal class AIHContext : DbContext
|
|
||||||
{
|
|
||||||
public DbSet<EK> EKs { get; set; }
|
|
||||||
public AIHContext() { }
|
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
||||||
{
|
|
||||||
optionsBuilder.UseSqlServer(@"Data Source=10.248.19.97; Initial Catalog=mao2;User ID=awhit-ipp-parr;pwd=ET3h$9y1LH#D;TrustServerCertificate=true;");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
19
PARR.AIHIT/AIHIT/Context/AIHITContext.cs
Normal file
19
PARR.AIHIT/AIHIT/Context/AIHITContext.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PARR.AIHIT.Models;
|
||||||
|
|
||||||
|
namespace PARR.AIHIT.Context
|
||||||
|
{
|
||||||
|
internal class AIHITContext : DbContext
|
||||||
|
{
|
||||||
|
public AIHITContext(DbContextOptions<AIHITContext> options) : base(options) { }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public DbSet<EK> EKs { get; set; }
|
||||||
|
|
||||||
|
//protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
|
//{
|
||||||
|
// optionsBuilder.UseSqlServer(@"Data Source=10.248.19.97; Initial Catalog=mao2;User ID=awhit-ipp-parr;pwd=ET3h$9y1LH#D;TrustServerCertificate=true;");
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
using PARR.AIHIT.Models;
|
||||||
using PARR.DAL.Models;
|
using PARR.DAL.Models;
|
||||||
using PARR.DAL.Models.AIHIT;
|
using PARR.DAL.Models.AIHIT;
|
||||||
using PARR.DAL.Models.V1;
|
using PARR.DAL.Models.V1;
|
||||||
@@ -35,6 +36,10 @@ namespace PARR.AIHIT.MappingProfiles
|
|||||||
// .ForMember(d => d.OS, o => o.MapFrom(s => s.OS))
|
// .ForMember(d => d.OS, o => o.MapFrom(s => s.OS))
|
||||||
// .ForMember(d => d.DB, o => o.MapFrom(s => s.DB))
|
// .ForMember(d => d.DB, o => o.MapFrom(s => s.DB))
|
||||||
// .ForMember(d => d.APP, o => o.MapFrom(s => s.APP));
|
// .ForMember(d => d.APP, o => o.MapFrom(s => s.APP));
|
||||||
|
|
||||||
|
CreateMap<EK, RawDataEK>();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ namespace PARR.AIHIT.Models
|
|||||||
public string? CTSDirection { get; set; }
|
public string? CTSDirection { get; set; }
|
||||||
[Key]
|
[Key]
|
||||||
[Column("ID")]
|
[Column("ID")]
|
||||||
public int? ID { get; set; }
|
public int? AIHID { get; set; }
|
||||||
[Column("недостоверные_данные")]
|
[Column("недостоверные_данные")]
|
||||||
public char? IsUnreliableData { get; set; }
|
public char? IsUnreliableData { get; set; }
|
||||||
[Column("РГ_смены")]
|
[Column("РГ_смены")]
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.10" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.10" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
42
PARR.AIHIT/AIHIT/Services/AIHITService.cs
Normal file
42
PARR.AIHIT/AIHIT/Services/AIHITService.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
using Microsoft.Data.SqlClient;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PARR.AIHIT.Context;
|
||||||
|
using PARR.AIHIT.Models;
|
||||||
|
|
||||||
|
namespace PARR.AIHIT.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 List<EK>? GetEKList(string respArea)
|
||||||
|
{
|
||||||
|
var parameters = new List<SqlParameter>() { new SqlParameter("@зо",respArea)};
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = context.Set<EK>().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");
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
PARR.AIHIT/AIHIT/Services/IAIHITService.cs
Normal file
9
PARR.AIHIT/AIHIT/Services/IAIHITService.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using PARR.AIHIT.Models;
|
||||||
|
|
||||||
|
namespace PARR.AIHIT.Services
|
||||||
|
{
|
||||||
|
internal interface IAIHITService
|
||||||
|
{
|
||||||
|
List<EK>? GetEKList(string respArea);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,8 +3,7 @@ using MailKit.Search;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using MimeKit;
|
using MimeKit;
|
||||||
using PARR.AIHIT.Context;
|
using PARR.AIHIT.Services;
|
||||||
using PARR.AIHIT.Models;
|
|
||||||
using PARR.AIHIT.Settings;
|
using PARR.AIHIT.Settings;
|
||||||
using PARR.DAL.Contracts;
|
using PARR.DAL.Contracts;
|
||||||
using PARR.DAL.Extensions;
|
using PARR.DAL.Extensions;
|
||||||
@@ -36,6 +35,8 @@ namespace PARR.AIHIT
|
|||||||
private readonly IApplicationInHostService appInHostService;
|
private readonly IApplicationInHostService appInHostService;
|
||||||
private readonly IRawDataEKService rawDataEKService;
|
private readonly IRawDataEKService rawDataEKService;
|
||||||
private readonly ISettingService settingService;
|
private readonly ISettingService settingService;
|
||||||
|
private readonly IAIHITService aihitService;
|
||||||
|
private readonly IApplicationService applicationService;
|
||||||
|
|
||||||
public List<ApplicationType> AppTypes { get; private set; } = new List<ApplicationType>();
|
public List<ApplicationType> AppTypes { get; private set; } = new List<ApplicationType>();
|
||||||
|
|
||||||
@@ -53,7 +54,8 @@ namespace PARR.AIHIT
|
|||||||
IApplicationTypeService appTypeService,
|
IApplicationTypeService appTypeService,
|
||||||
IApplicationInHostService appInHostService,
|
IApplicationInHostService appInHostService,
|
||||||
IRawDataEKService rawDataEKService,
|
IRawDataEKService rawDataEKService,
|
||||||
ISettingService settingService
|
ISettingService settingService,
|
||||||
|
IAIHITService aihitService
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
this.hostService = hostService;
|
this.hostService = hostService;
|
||||||
@@ -63,6 +65,7 @@ namespace PARR.AIHIT
|
|||||||
this.appInHostService = appInHostService;
|
this.appInHostService = appInHostService;
|
||||||
this.rawDataEKService = rawDataEKService;
|
this.rawDataEKService = rawDataEKService;
|
||||||
this.settingService = settingService;
|
this.settingService = settingService;
|
||||||
|
this.aihitService = aihitService;
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.mailService = mailService;
|
this.mailService = mailService;
|
||||||
this.syncherSettings = syncherSettings;
|
this.syncherSettings = syncherSettings;
|
||||||
@@ -219,25 +222,11 @@ namespace PARR.AIHIT
|
|||||||
//Запускаем хранимую процедуру в АИХ ИТ и складываем в таблицу RawDataEKs, предварительно почистив старые данные
|
//Запускаем хранимую процедуру в АИХ ИТ и складываем в таблицу RawDataEKs, предварительно почистив старые данные
|
||||||
foreach (var respArea in respAreas)
|
foreach (var respArea in respAreas)
|
||||||
{
|
{
|
||||||
var eksFromAIHIT = new List<EK>();
|
var eksFromAIHIT = aihitService.GetEKList(respArea.Value)?.ToList();
|
||||||
using (AIHContext db = new AIHContext())
|
|
||||||
{
|
if (eksFromAIHIT == null)
|
||||||
var zo = new Microsoft.Data.SqlClient.SqlParameter
|
continue;
|
||||||
{
|
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Удаляем текущие данные по зоне ответственности respArea
|
//Удаляем текущие данные по зоне ответственности respArea
|
||||||
var toDelete = rawDataEKService.Get().Where(rd => rd.ResponseArea == respArea.Value).ToList();
|
var toDelete = rawDataEKService.Get().Where(rd => rd.ResponseArea == respArea.Value).ToList();
|
||||||
toDelete.ForEach(d => rawDataEKService.Delete(d));
|
toDelete.ForEach(d => rawDataEKService.Delete(d));
|
||||||
@@ -245,55 +234,10 @@ namespace PARR.AIHIT
|
|||||||
foreach (var ek in eksFromAIHIT)
|
foreach (var ek in eksFromAIHIT)
|
||||||
{
|
{
|
||||||
// создаем
|
// создаем
|
||||||
var mappedEK = new RawDataEK()
|
var mappedEK = mapper.Map<RawDataEK>(ek);
|
||||||
{
|
|
||||||
Id = Guid.NewGuid(),
|
mappedEK.Id = Guid.NewGuid();
|
||||||
DateCreated = DateTimeOffset.UtcNow,
|
mappedEK.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
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!await rawDataEKService.CreateAsync(mappedEK) || !await rawDataEKService.CommitAsync())
|
if (!await rawDataEKService.CreateAsync(mappedEK) || !await rawDataEKService.CommitAsync())
|
||||||
{
|
{
|
||||||
@@ -347,7 +291,7 @@ namespace PARR.AIHIT
|
|||||||
foundHost.Status = mappedHost.Status;
|
foundHost.Status = mappedHost.Status;
|
||||||
isChanged = true;
|
isChanged = true;
|
||||||
}
|
}
|
||||||
else if (!foundHost.WorkGroup!.Equals(mappedHost.WorkGroup))
|
else if (mappedHost.WorkGroup != null && !foundHost.WorkGroup!.Equals(mappedHost.WorkGroup))
|
||||||
{
|
{
|
||||||
foundHost.WorkGroup = mappedHost.WorkGroup;
|
foundHost.WorkGroup = mappedHost.WorkGroup;
|
||||||
isChanged = true;
|
isChanged = true;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using PARR.AIHIT.Context;
|
using PARR.AIHIT.Context;
|
||||||
|
using PARR.AIHIT.Services;
|
||||||
using PARR.AIHIT.Settings;
|
using PARR.AIHIT.Settings;
|
||||||
|
|
||||||
namespace PARR.AIHIT
|
namespace PARR.AIHIT
|
||||||
@@ -14,11 +15,20 @@ namespace PARR.AIHIT
|
|||||||
configuration.GetSection(nameof(SyncherSettings)).Bind(syncherSettings);
|
configuration.GetSection(nameof(SyncherSettings)).Bind(syncherSettings);
|
||||||
services.AddSingleton(syncherSettings);
|
services.AddSingleton(syncherSettings);
|
||||||
|
|
||||||
|
services.AddDbContext<AIHITContext>(options =>
|
||||||
|
options.UseSqlServer(
|
||||||
|
configuration.GetConnectionString("AihitConnection")
|
||||||
|
));
|
||||||
|
|
||||||
services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
|
services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
|
||||||
|
|
||||||
services.AddTransient<ISyncher, Syncher>();
|
services.AddTransient<ISyncher, Syncher>();
|
||||||
|
services.AddTransient<IAIHITService,AIHITService>();
|
||||||
|
|
||||||
//services.AddDbContext <AIHContext> (options =>
|
|
||||||
|
|
||||||
|
|
||||||
|
//services.AddDbContext <AIHITContext> (options =>
|
||||||
//{
|
//{
|
||||||
// options.UseSqlServer("server=(10.248.19.97);uid=awhit-ipp-parr;pwd=ET3h$9y1LH#D");
|
// options.UseSqlServer("server=(10.248.19.97);uid=awhit-ipp-parr;pwd=ET3h$9y1LH#D");
|
||||||
//});
|
//});
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"DefaultConnection": "Server=10.99.253.184;Database=parr;User Id=app_parr; Password=PosdfkhT&)%sdfligL&%5546;"
|
"DefaultConnection": "Server=10.99.253.184;Database=parr;User Id=app_parr; Password=PosdfkhT&)%sdfligL&%5546;",
|
||||||
|
"AihitConnection": "Data Source=10.248.19.97; Initial Catalog=mao2;User ID=awhit-ipp-parr;pwd=ET3h$9y1LH#D;TrustServerCertificate=true;"
|
||||||
},
|
},
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"LogLevel": {
|
"LogLevel": {
|
||||||
|
|||||||
Reference in New Issue
Block a user