Синхронизация данных АИХ ИТ с ПАРР
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using AutoMapper;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Models.AIHIT;
|
||||
using PARR.DAL.Models.V1;
|
||||
using System.Xml;
|
||||
@@ -18,7 +19,11 @@ namespace PARR.AIHIT.MappingProfiles
|
||||
.ForMember(d => d.WorkGroup, o => o.MapFrom(s => (s.Attributes!["РАБОЧАЯ_ГР_ОТВ_ЗА_ЭК"] != null) ? s.Attributes!["РАБОЧАЯ_ГР_ОТВ_ЗА_ЭК"]!.Value.Trim() : ""))
|
||||
.ForMember(d => d.Responsible, o => o.MapFrom(s => s.Attributes!["ОТВЕТСТВЕННЫЙ_ЗА_ЭК"]!.Value.Trim()));
|
||||
|
||||
CreateMap<Models.EK, RawDataEK>();
|
||||
CreateMap<RawDataEK, Host>()
|
||||
.ForMember(d => d.HostName, o => o.MapFrom(s => s.EKFindCode))//TODO Определить имя хоста по
|
||||
.ForMember(d => d.IP, o => o.MapFrom(s => s.IP))
|
||||
.ForMember(d => d.Status, o => o.MapFrom(s => s.Status))
|
||||
.ForMember(d => d.WorkGroup, o => o.MapFrom(s => s.WorkGroup));
|
||||
//CreateMap<PARR.DAL.Models.Host, PARR.DAL.Models.Host>()
|
||||
// .ForMember(d => d.HostName, o => o.MapFrom(s => s.HostName))
|
||||
// .ForMember(d => d.IP, o => o.MapFrom(s => s.IP))
|
||||
|
||||
@@ -6,9 +6,12 @@ using MimeKit;
|
||||
using PARR.AIHIT.Settings;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Extensions;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Models.AIHIT;
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.AIHIT;
|
||||
using PARR.DAL.Services.Interfaces.V1;
|
||||
using PARR.Mail.Services;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
@@ -20,6 +23,10 @@ namespace PARR.AIHIT
|
||||
private readonly ILogger<Syncher> logger;
|
||||
private readonly IMailService mailService;
|
||||
private readonly SyncherSettings syncherSettings;
|
||||
private readonly V1_IHostService V1_hostService;
|
||||
private readonly V1_IApplicationTypeService V1_appTypeService;
|
||||
private readonly V1_IApplicationInHostService V1_appInHostService;
|
||||
private readonly V1_IApplicationService V1_appService;
|
||||
private readonly IHostService hostService;
|
||||
private readonly IMapper mapper;
|
||||
private readonly IApplicationService appService;
|
||||
@@ -28,12 +35,16 @@ namespace PARR.AIHIT
|
||||
private readonly IRawDataEKService rawDataEKService;
|
||||
private readonly ISettingService settingService;
|
||||
|
||||
public List<V1_ApplicationType> AppTypes { get; private set; } = new List<V1_ApplicationType>();
|
||||
public List<ApplicationType> AppTypes { get; private set; } = new List<ApplicationType>();
|
||||
|
||||
public Syncher(
|
||||
ILogger<Syncher> logger,
|
||||
IMailService mailService,
|
||||
SyncherSettings syncherSettings,
|
||||
V1_IHostService V1_hostService,
|
||||
V1_IApplicationService V1_appService,
|
||||
V1_IApplicationTypeService V1_appTypeService,
|
||||
V1_IApplicationInHostService V1_appInHostService,
|
||||
IHostService hostService,
|
||||
IMapper mapper,
|
||||
IApplicationService appService,
|
||||
@@ -53,6 +64,10 @@ namespace PARR.AIHIT
|
||||
this.logger = logger;
|
||||
this.mailService = mailService;
|
||||
this.syncherSettings = syncherSettings;
|
||||
this.V1_hostService = V1_hostService;
|
||||
this.V1_appService = V1_appService;
|
||||
this.V1_appTypeService = V1_appTypeService;
|
||||
this.V1_appInHostService = V1_appInHostService;
|
||||
}
|
||||
|
||||
private async Task GetAppTypesAsync()
|
||||
@@ -103,15 +118,15 @@ namespace PARR.AIHIT
|
||||
if (!linkEK.StartsWith("ВРТ")) continue;
|
||||
|
||||
// var foundHost = await hostService.GetHostAsync(ip, linkEK, regionalEK);
|
||||
var foundHost = await hostService.GetHostWithAppsAsync(ip, linkEK, regionalEK);
|
||||
var foundHost = await V1_hostService.GetHostWithAppsAsync(ip, linkEK, regionalEK);
|
||||
var mappedHost = mapper.Map<V1_Host>(vm);
|
||||
|
||||
var hostApplications = await GetAndFillApplicationsAsync(vm);
|
||||
var hostApplications = await V1_GetAndFillApplicationsAsync(vm);
|
||||
|
||||
if (foundHost == null)
|
||||
{
|
||||
// создаем
|
||||
if (!await hostService.CreateAsync(mappedHost) || !await hostService.CommitAsync())
|
||||
if (!await V1_hostService.CreateAsync(mappedHost) || !await V1_hostService.CommitAsync())
|
||||
{
|
||||
logger.LogError($"Не удалось создать узел {mappedHost.IP} {mappedHost.RegionalEK}");
|
||||
continue;
|
||||
@@ -121,7 +136,7 @@ namespace PARR.AIHIT
|
||||
|
||||
|
||||
// Синхронизация Applications
|
||||
await SyncApplicationAndHostAsync(foundHost, hostApplications);
|
||||
await V1_SyncApplicationAndHostAsync(foundHost, hostApplications);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -170,14 +185,14 @@ namespace PARR.AIHIT
|
||||
if (isChanged)
|
||||
{
|
||||
foundHost.DateModified = DateTimeOffset.UtcNow;
|
||||
if (!await hostService.CommitAsync())
|
||||
if (!await V1_hostService.CommitAsync())
|
||||
logger.LogError($"Не удалось обновить узел {mappedHost.IP} {mappedHost.RegionalEK}");
|
||||
else
|
||||
logger.LogInformation($"----- Обновлён Host: {mappedHost.Id}, {mappedHost.LinkEK} -----");
|
||||
}
|
||||
|
||||
// Синхронизация Applications
|
||||
await SyncApplicationAndHostAsync(foundHost, hostApplications, true);
|
||||
await V1_SyncApplicationAndHostAsync(foundHost, hostApplications, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,7 +209,7 @@ namespace PARR.AIHIT
|
||||
|
||||
public async Task InvokeFromDatabase()
|
||||
{
|
||||
|
||||
await GetAppTypesAsync();
|
||||
/*
|
||||
//Получаем зоны ответственности из БД
|
||||
var respAreas = settingService.Get().Where(ra => ra.Group == AIHTITSettings.RespAreaGroupName).ToList();
|
||||
@@ -294,11 +309,63 @@ namespace PARR.AIHIT
|
||||
var statusList = settingService.Get().Where(s => s.Group == AIHTITSettings.StatusGroupName).Select(s => s.Value.Trim()).ToList();
|
||||
if (statusList == null || statusList.Count == 0) return;
|
||||
|
||||
var eks = rawDataEKService.Get().Where(e => e.IsActive == "t" && (e.Status != null && statusList.Contains(e.Status.Trim()))).ToList();
|
||||
var eks = rawDataEKService.Get().Where(e => e.IsActive == "t"
|
||||
&& (e.Status != null && statusList.Contains(e.Status.Trim()))
|
||||
).ToList();
|
||||
|
||||
foreach (var ek in eks)
|
||||
{
|
||||
if (ek.IP == null) continue;
|
||||
var foundHost = await hostService.GetHostWithAppsAsync(ek.IP);
|
||||
var mappedHost = mapper.Map<Host>(ek);
|
||||
|
||||
var hostApplications = await GetAndFillApplicationsAsync(ek);
|
||||
|
||||
if (foundHost == null)
|
||||
{
|
||||
// создаем
|
||||
if (!await hostService.CreateAsync(mappedHost) || !await hostService.CommitAsync())
|
||||
{
|
||||
logger.LogError($"Не удалось создать узел {mappedHost.IP}");
|
||||
continue;
|
||||
}
|
||||
else
|
||||
logger.LogInformation($"----- Создан Host: {mappedHost.Id} -----");
|
||||
|
||||
|
||||
// Синхронизация Applications
|
||||
await SyncApplicationAndHostAsync(foundHost, hostApplications);
|
||||
}
|
||||
else
|
||||
{
|
||||
// обновляем
|
||||
var isChanged = false;
|
||||
if (!foundHost.Status!.Equals(mappedHost.Status))
|
||||
{
|
||||
foundHost.Status = mappedHost.Status;
|
||||
isChanged = true;
|
||||
}
|
||||
else if (!foundHost.WorkGroup!.Equals(mappedHost.WorkGroup))
|
||||
{
|
||||
foundHost.WorkGroup = mappedHost.WorkGroup;
|
||||
isChanged = true;
|
||||
}
|
||||
|
||||
if (isChanged)
|
||||
{
|
||||
foundHost.DateModified = DateTimeOffset.UtcNow;
|
||||
if (!await hostService.CommitAsync())
|
||||
logger.LogError($"Не удалось обновить узел {mappedHost.IP}");
|
||||
else
|
||||
logger.LogInformation($"----- Обновлён Host: {mappedHost.Id} -----");
|
||||
}
|
||||
|
||||
// Синхронизация Applications
|
||||
await SyncApplicationAndHostAsync(foundHost, hostApplications, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
private async Task SyncApplicationAndHostAsync(V1_Host? host, List<V1_Application> hostApplications, bool isUpdateDateModified = false)
|
||||
private async Task V1_SyncApplicationAndHostAsync(V1_Host? host, List<V1_Application> hostApplications, bool isUpdateDateModified = false)
|
||||
{
|
||||
var isUpdated = false;
|
||||
if (host == null)
|
||||
@@ -316,7 +383,7 @@ namespace PARR.AIHIT
|
||||
logger.LogInformation($"Host: {host.Id}, {host.LinkEK} добавление нового приложения Application {changedHostApp.Name}");
|
||||
|
||||
var newAppHost = new V1_ApplicationInHost { Id = Guid.NewGuid(), ApplicationId = changedHostApp.Id, HostId = host.Id };
|
||||
if (!await appInHostService.CreateAsync(newAppHost))
|
||||
if (!await V1_appInHostService.CreateAsync(newAppHost))
|
||||
logger.LogError($"Не удалось создать ApplicationInHost {changedHostApp.Name}, host: {host.Id}, {host.LinkEK}");
|
||||
|
||||
isUpdated = true;
|
||||
@@ -330,11 +397,11 @@ namespace PARR.AIHIT
|
||||
if (appToRemove == null)
|
||||
{
|
||||
//todo remove appToRemove
|
||||
var obj = await appInHostService.Get().FirstOrDefaultAsync(t => t.ApplicationId == app.Id && t.HostId == host.Id);
|
||||
var obj = await V1_appInHostService.Get().FirstOrDefaultAsync(t => t.ApplicationId == app.Id && t.HostId == host.Id);
|
||||
if (obj != null)
|
||||
{
|
||||
logger.LogInformation($"Host: {host.Id}, {host.LinkEK} удаление неактуального приложения Application {app.Application?.Name}");
|
||||
appInHostService.Delete(obj);
|
||||
V1_appInHostService.Delete(obj);
|
||||
|
||||
isUpdated = true;
|
||||
}
|
||||
@@ -351,7 +418,7 @@ namespace PARR.AIHIT
|
||||
|
||||
}
|
||||
|
||||
private async Task<List<V1_Application>> GetAndFillApplicationsAsync(XmlNode vm)
|
||||
private async Task<List<V1_Application>> V1_GetAndFillApplicationsAsync(XmlNode vm)
|
||||
{
|
||||
logger.LogInformation($"--- Начало парсинга данных о программном обеспечении(СП, БД, ОС) из Xml документа от АИХ ИТ ---");
|
||||
var applications = new List<V1_Application>();
|
||||
@@ -362,21 +429,21 @@ namespace PARR.AIHIT
|
||||
var appList = GetAppFromXML(vm?.Attributes?["СП"]?.Value);
|
||||
foreach (var app in appList)
|
||||
{
|
||||
var created = await CreateAppIfNotExistAsync(app, ApplicationTypesEnum.APP);
|
||||
var created = await V1_CreateAppIfNotExistAsync(app, ApplicationTypesEnum.APP);
|
||||
if (created != null)
|
||||
applications.Add(created);
|
||||
}
|
||||
var dbList = GetAppFromXML(vm?.Attributes?["СУБД"]?.Value);
|
||||
foreach (var db in dbList)
|
||||
{
|
||||
var created = await CreateAppIfNotExistAsync(db, ApplicationTypesEnum.DB);
|
||||
var created = await V1_CreateAppIfNotExistAsync(db, ApplicationTypesEnum.DB);
|
||||
if (created != null)
|
||||
applications.Add(created);
|
||||
}
|
||||
var osList = GetAppFromXML(vm?.Attributes?["ОС"]?.Value);
|
||||
foreach (var os in appList)
|
||||
{
|
||||
var created = await CreateAppIfNotExistAsync(os, ApplicationTypesEnum.OS);
|
||||
var created = await V1_CreateAppIfNotExistAsync(os, ApplicationTypesEnum.OS);
|
||||
if (created != null)
|
||||
applications.Add(created);
|
||||
}
|
||||
@@ -386,6 +453,99 @@ namespace PARR.AIHIT
|
||||
return applications;
|
||||
}
|
||||
|
||||
private async Task SyncApplicationAndHostAsync(Host? host, List<Application> hostApplications, bool isUpdateDateModified = false)
|
||||
{
|
||||
var isUpdated = false;
|
||||
if (host == null)
|
||||
return;
|
||||
|
||||
logger.LogInformation($"--- Host: {host.Id}, начало синхронизации приложений ({hostApplications.Count()}) ---");
|
||||
|
||||
foreach (var changedHostApp in hostApplications)
|
||||
{
|
||||
var exist = host.ApplicationsInHosts.FirstOrDefault(a => a.ApplicationId == changedHostApp.Id);
|
||||
|
||||
if (exist == null)
|
||||
{
|
||||
//add
|
||||
logger.LogInformation($"Host: {host.Id}, добавление нового приложения Application {changedHostApp.Name}");
|
||||
|
||||
var newAppHost = new ApplicationInHost { Id = Guid.NewGuid(), ApplicationId = changedHostApp.Id, HostId = host.Id };
|
||||
if (!await appInHostService.CreateAsync(newAppHost))
|
||||
logger.LogError($"Не удалось создать ApplicationInHost {changedHostApp.Name}, host: {host.Id}");
|
||||
|
||||
isUpdated = true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var app in host.ApplicationsInHosts)
|
||||
{
|
||||
var appToRemove = hostApplications.FirstOrDefault(a => a.Id == app.Id);
|
||||
|
||||
if (appToRemove == null)
|
||||
{
|
||||
//todo remove appToRemove
|
||||
var obj = await appInHostService.Get().FirstOrDefaultAsync(t => t.ApplicationId == app.Id && t.HostId == host.Id);
|
||||
if (obj != null)
|
||||
{
|
||||
logger.LogInformation($"Host: {host.Id}, удаление неактуального приложения Application {app.Application?.Name}");
|
||||
appInHostService.Delete(obj);
|
||||
|
||||
isUpdated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isUpdated && isUpdateDateModified)
|
||||
host.DateModified = DateTimeOffset.UtcNow;
|
||||
|
||||
if (!await appInHostService.CommitAsync())
|
||||
logger.LogError($"Не удалось обновить ApplicationInHost для Host: {host.Id}");
|
||||
|
||||
logger.LogInformation($"=== Host: {host.Id} конец синхронизации приложений ===");
|
||||
|
||||
}
|
||||
private async Task<List<Application>> GetAndFillApplicationsAsync(RawDataEK vm)
|
||||
{
|
||||
logger.LogInformation($"--- Начало парсинга данных о программном обеспечении(СП, БД, ОС) из АИХ ИТ ---");
|
||||
var applications = new List<Application>();
|
||||
|
||||
if (vm.APPType != null)
|
||||
{
|
||||
var appList = vm.APPType.Split(new char[] { ',', ';' }).Distinct().ToList();
|
||||
foreach (var app in appList)
|
||||
{
|
||||
var created = await CreateAppIfNotExistAsync(app, ApplicationTypesEnum.APP);
|
||||
if (created != null)
|
||||
applications.Add(created);
|
||||
}
|
||||
}
|
||||
if (vm.DBType != null)
|
||||
{
|
||||
var appList = vm.DBType.Split(new char[] { ',', ';' }).Distinct().ToList();
|
||||
foreach (var app in appList)
|
||||
{
|
||||
var created = await CreateAppIfNotExistAsync(app, ApplicationTypesEnum.DB);
|
||||
if (created != null)
|
||||
applications.Add(created);
|
||||
}
|
||||
}
|
||||
if (vm.ClientOS != null)
|
||||
{
|
||||
var appList = vm.ClientOS.Split(new char[] { ',', ';' }).Distinct().ToList();
|
||||
foreach (var app in appList)
|
||||
{
|
||||
var created = await CreateAppIfNotExistAsync(app, ApplicationTypesEnum.OS);
|
||||
if (created != null)
|
||||
applications.Add(created);
|
||||
}
|
||||
}
|
||||
|
||||
logger.LogInformation($"=== Конец парсинга данных о программном обеспечении(СП, БД, ОС) из АИХ ИТ ===");
|
||||
|
||||
return applications;
|
||||
}
|
||||
|
||||
private List<string> GetAppFromXML(string? appField)
|
||||
{
|
||||
if (string.IsNullOrEmpty(appField))
|
||||
@@ -419,7 +579,38 @@ namespace PARR.AIHIT
|
||||
return osList;
|
||||
}
|
||||
|
||||
private async Task<V1_Application?> CreateAppIfNotExistAsync(string appName, ApplicationTypesEnum type)//Application application)
|
||||
private async Task<V1_Application?> V1_CreateAppIfNotExistAsync(string appName, ApplicationTypesEnum type)//Application application)
|
||||
{
|
||||
if (string.IsNullOrEmpty(appName) || string.IsNullOrWhiteSpace(appName)) return null;
|
||||
|
||||
var existApp = await V1_appService.GetByNameAsync(appName);
|
||||
if (existApp != null)
|
||||
return existApp;
|
||||
|
||||
//Создаем
|
||||
var appType = GetAppTypeByName(type);
|
||||
if (appType == null)
|
||||
{
|
||||
logger.LogError($"Не удалось создать запись в таблице Applications: {appName}, так как не получил AppType: {type.ToString()}");
|
||||
return null;
|
||||
}
|
||||
|
||||
var app = new V1_Application
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Name = appName.Trim(),
|
||||
ApplicationTypeId = appType.Id
|
||||
};
|
||||
|
||||
if (!await V1_appService.CreateAsync(app) || !await V1_appService.CommitAsync())
|
||||
logger.LogError($"Не удалось создать запись в таблице Application: {appName}, {app.ToJson()}");
|
||||
else
|
||||
logger.LogInformation($"Создана запись а таблице Application: {appName}, {app.ToJson()}");
|
||||
|
||||
return await V1_appService.GetAsync(app.Id);
|
||||
}
|
||||
|
||||
private async Task<Application?> CreateAppIfNotExistAsync(string appName, ApplicationTypesEnum type)//Application application)
|
||||
{
|
||||
if (string.IsNullOrEmpty(appName) || string.IsNullOrWhiteSpace(appName)) return null;
|
||||
|
||||
@@ -435,7 +626,7 @@ namespace PARR.AIHIT
|
||||
return null;
|
||||
}
|
||||
|
||||
var app = new DAL.Models.V1.V1_Application
|
||||
var app = new Application
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
Name = appName.Trim(),
|
||||
@@ -450,7 +641,7 @@ namespace PARR.AIHIT
|
||||
return await appService.GetAsync(app.Id);
|
||||
}
|
||||
|
||||
private V1_ApplicationType? GetAppTypeByName(ApplicationTypesEnum type)
|
||||
private ApplicationType? GetAppTypeByName(ApplicationTypesEnum type)
|
||||
{
|
||||
var existType = AppTypes.FirstOrDefault(t => t.Name == type.ToString());
|
||||
if (existType == null)
|
||||
|
||||
@@ -11,31 +11,32 @@ using PARR.API.Services.Interfaces;
|
||||
using PARR.DAL.DomainModels;
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.V1;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
public class JobController : BaseApiController
|
||||
{
|
||||
private readonly IMapper mapper;
|
||||
private readonly IJobService jobService;
|
||||
private readonly V1_IJobService jobService;
|
||||
//private readonly ISchedulerService schedulerService;
|
||||
private readonly IClientService clientService;
|
||||
private readonly IHostService hostService;
|
||||
private readonly IJobJournalService jobJournalService;
|
||||
private readonly V1_IHostService v1_hostService;
|
||||
private readonly V1_IJobJournalService jobJournalService;
|
||||
|
||||
public JobController(
|
||||
IMapper mapper,
|
||||
IJobService jobService,
|
||||
V1_IJobService jobService,
|
||||
IClientService clientService,
|
||||
IHostService hostService,
|
||||
IJobJournalService jobJournalService
|
||||
V1_IHostService v1_hostService,
|
||||
V1_IJobJournalService jobJournalService
|
||||
)
|
||||
{
|
||||
this.mapper = mapper;
|
||||
this.jobService = jobService;
|
||||
//this.schedulerService = schedulerService;
|
||||
this.clientService = clientService;
|
||||
this.hostService = hostService;
|
||||
this.v1_hostService = v1_hostService;
|
||||
this.jobJournalService = jobJournalService;
|
||||
}
|
||||
|
||||
@@ -84,7 +85,7 @@ namespace PARR.API.Controllers.V1
|
||||
var date = requestQuery.Date ?? DateTimeOffset.UtcNow;
|
||||
|
||||
// С одним IP может быть несколько информационных систем, соответственного а таблице храниться несколько записей хостов с одинаковым IP
|
||||
var hosts = await hostService.Get().Where(h => h.IP == ip).ToListAsync();
|
||||
var hosts = await v1_hostService.Get().Where(h => h.IP == ip).ToListAsync();
|
||||
|
||||
var hostJobsDict = new Dictionary<V1_Host, List<V1_Job>>();
|
||||
foreach (var host in hosts)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Models.AIHIT;
|
||||
using PARR.DAL.Models.V1;
|
||||
|
||||
@@ -13,12 +14,16 @@ namespace PARR.DAL.Context
|
||||
public DbSet<V1_JobCategory> JobCategories { get; set; }
|
||||
public DbSet<V1_JobMode> JobModes { get; set; }
|
||||
public DbSet<V1_JobStatus> JobStatuses { get; set; }
|
||||
public DbSet<V1_Host> Hosts { get; set; }
|
||||
public DbSet<V1_Host> V1_Hosts { get; set; }
|
||||
public DbSet<Host> Hosts { get; set; }
|
||||
public DbSet<V1_Job> Jobs { get; set; }
|
||||
public DbSet<V1_JobJournal> JobJournals { get; set; }
|
||||
public DbSet<V1_Application> Applications { get; set; }
|
||||
public DbSet<V1_ApplicationType> ApplicationTypes { get; set; }
|
||||
public DbSet<V1_ApplicationInHost> ApplicationsInHosts { get; set; }
|
||||
public DbSet<Application> Applications { get; set; }
|
||||
public DbSet<ApplicationType> ApplicationTypes { get; set; }
|
||||
public DbSet<ApplicationInHost> ApplicationsInHosts { get; set; }
|
||||
public DbSet<V1_Application> V1_Applications { get; set; }
|
||||
public DbSet<V1_ApplicationType> V1_ApplicationTypes { get; set; }
|
||||
public DbSet<V1_ApplicationInHost> V1_ApplicationsInHosts { get; set; }
|
||||
public DbSet<Setting> Settings { get; set; }
|
||||
public DbSet<RawDataEK> RawDataEKs { get; set; }
|
||||
//public DbSet<Scheduler> Schedulers { get; set; }
|
||||
@@ -48,7 +53,7 @@ namespace PARR.DAL.Context
|
||||
});
|
||||
|
||||
|
||||
modelBuilder.Entity<V1_ApplicationType>(f =>
|
||||
modelBuilder.Entity<ApplicationType>(f =>
|
||||
{
|
||||
f.HasData(
|
||||
new() { Id = new Guid("32c28386-6f13-4f7b-8508-be165b7fabdb"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.APP.ToString(), Description = "Поле СП xml АИХ ИТ" },
|
||||
@@ -64,7 +69,6 @@ namespace PARR.DAL.Context
|
||||
new() { Id = new Guid("50F66704-4D26-4587-BB1E-DCA70C8F4B89"), DateCreated = dateCreated, DateModified = null, Group = AIHTITSettings.RespAreaGroupName, Name = "ZAB", Value = "94-ЗАБ", Description = "Зона ответственности" },
|
||||
new() { Id = new Guid("1FD43634-4A06-4237-9727-EDFA6F3EEBE8"), DateCreated = dateCreated, DateModified = null, Group = AIHTITSettings.RespAreaGroupName, Name = "DVS", Value = "96-ДВС", Description = "Зона ответственности" },
|
||||
new() { Id = new Guid("77C73C0A-8E4D-4676-B6E2-6A112F20E346"), DateCreated = dateCreated, DateModified = null, Group = AIHTITSettings.StatusGroupName, Name = "Exploitation", Value = "3-В эксплуатации", Description = "Статус актуальных ЭК" }
|
||||
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -239,6 +239,141 @@ namespace PARR.DAL.Migrations
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Application", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("ApplicationTypeId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset?>("DateModified")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ApplicationTypeId");
|
||||
|
||||
b.ToTable("Applications");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.ApplicationInHost", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("ApplicationId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset?>("DateModified")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid>("HostId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ApplicationId");
|
||||
|
||||
b.HasIndex("HostId");
|
||||
|
||||
b.ToTable("ApplicationsInHost");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.ApplicationType", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid?>("ApplicationTypeId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset?>("DateModified")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ApplicationTypeId");
|
||||
|
||||
b.ToTable("ApplicationTypes");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = new Guid("32c28386-6f13-4f7b-8508-be165b7fabdb"),
|
||||
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
|
||||
Description = "Поле СП xml АИХ ИТ",
|
||||
Name = "APP"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = new Guid("7848a96c-cdee-48c1-a786-de9cb889723a"),
|
||||
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
|
||||
Description = "Поле ОС xml АИХ ИТ",
|
||||
Name = "OS"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = new Guid("aae2636f-b93a-42dc-873e-0764a90a0a40"),
|
||||
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
|
||||
Description = "Поле СУБД xml АИХ ИТ",
|
||||
Name = "DB"
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Host", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset?>("DateModified")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("HostName")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("IP")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("WorkGroup")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Hosts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_Application", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -283,12 +418,17 @@ namespace PARR.DAL.Migrations
|
||||
b.Property<Guid>("HostId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid?>("V1_ApplicationId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ApplicationId");
|
||||
|
||||
b.HasIndex("HostId");
|
||||
|
||||
b.HasIndex("V1_ApplicationId");
|
||||
|
||||
b.ToTable("V1_ApplicationsInHost");
|
||||
});
|
||||
|
||||
@@ -319,29 +459,6 @@ namespace PARR.DAL.Migrations
|
||||
b.HasIndex("V1_ApplicationTypeId");
|
||||
|
||||
b.ToTable("V1_ApplicationTypes");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = new Guid("32c28386-6f13-4f7b-8508-be165b7fabdb"),
|
||||
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
|
||||
Description = "Поле СП xml АИХ ИТ",
|
||||
Name = "APP"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = new Guid("7848a96c-cdee-48c1-a786-de9cb889723a"),
|
||||
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
|
||||
Description = "Поле ОС xml АИХ ИТ",
|
||||
Name = "OS"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = new Guid("aae2636f-b93a-42dc-873e-0764a90a0a40"),
|
||||
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
|
||||
Description = "Поле СУБД xml АИХ ИТ",
|
||||
Name = "DB"
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_Host", b =>
|
||||
@@ -604,6 +721,43 @@ namespace PARR.DAL.Migrations
|
||||
b.ToTable("V1_JobTypes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Application", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.ApplicationType", "ApplicationType")
|
||||
.WithMany()
|
||||
.HasForeignKey("ApplicationTypeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ApplicationType");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.ApplicationInHost", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.Application", "Application")
|
||||
.WithMany("ApplicationsInHosts")
|
||||
.HasForeignKey("ApplicationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.Host", "Host")
|
||||
.WithMany("ApplicationsInHosts")
|
||||
.HasForeignKey("HostId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Application");
|
||||
|
||||
b.Navigation("Host");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.ApplicationType", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.ApplicationType", null)
|
||||
.WithMany("ApplicationTypes")
|
||||
.HasForeignKey("ApplicationTypeId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_Application", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.V1.V1_ApplicationType", "ApplicationType")
|
||||
@@ -617,8 +771,8 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_ApplicationInHost", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.V1.V1_Application", "Application")
|
||||
.WithMany("ApplicationsInHosts")
|
||||
b.HasOne("PARR.DAL.Models.Application", "Application")
|
||||
.WithMany()
|
||||
.HasForeignKey("ApplicationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@@ -629,6 +783,10 @@ namespace PARR.DAL.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.V1.V1_Application", null)
|
||||
.WithMany("V1_ApplicationsInHosts")
|
||||
.HasForeignKey("V1_ApplicationId");
|
||||
|
||||
b.Navigation("Application");
|
||||
|
||||
b.Navigation("Host");
|
||||
@@ -637,13 +795,13 @@ namespace PARR.DAL.Migrations
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_ApplicationType", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.V1.V1_ApplicationType", null)
|
||||
.WithMany("ApplicationTypes")
|
||||
.WithMany("V1_ApplicationTypes")
|
||||
.HasForeignKey("V1_ApplicationTypeId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_Job", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.V1.V1_Application", "Application")
|
||||
b.HasOne("PARR.DAL.Models.Application", "Application")
|
||||
.WithMany()
|
||||
.HasForeignKey("ApplicationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
@@ -699,16 +857,31 @@ namespace PARR.DAL.Migrations
|
||||
b.Navigation("Status");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_Application", b =>
|
||||
modelBuilder.Entity("PARR.DAL.Models.Application", b =>
|
||||
{
|
||||
b.Navigation("ApplicationsInHosts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_ApplicationType", b =>
|
||||
modelBuilder.Entity("PARR.DAL.Models.ApplicationType", b =>
|
||||
{
|
||||
b.Navigation("ApplicationTypes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Host", b =>
|
||||
{
|
||||
b.Navigation("ApplicationsInHosts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_Application", b =>
|
||||
{
|
||||
b.Navigation("V1_ApplicationsInHosts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_ApplicationType", b =>
|
||||
{
|
||||
b.Navigation("V1_ApplicationTypes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_Host", b =>
|
||||
{
|
||||
b.Navigation("ApplicationsInHosts");
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Services.Implementation;
|
||||
using PARR.DAL.Services.Implementations;
|
||||
using PARR.DAL.Services.Implementations.AIHIT;
|
||||
using PARR.DAL.Services.Implementations.V1;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.AIHIT;
|
||||
using PARR.DAL.Services.Interfaces.V1;
|
||||
|
||||
namespace PARR.DAL
|
||||
{
|
||||
@@ -17,12 +20,16 @@ namespace PARR.DAL
|
||||
opt.UseNpgsql(configuration.GetConnectionString("DefaultConnection"))
|
||||
);
|
||||
|
||||
services.AddTransient<V1_IHostService, V1_HostService>();
|
||||
services.AddTransient<IHostService, HostService>();
|
||||
services.AddTransient<IApplicationService, ApplicationService>();
|
||||
services.AddTransient<IApplicationTypeService, ApplicationTypeService>();
|
||||
services.AddTransient<IApplicationInHostService, ApplicationInHostService>();
|
||||
services.AddTransient<IJobService, JobService>();
|
||||
services.AddTransient<IJobJournalService, JobJournalService>();
|
||||
services.AddTransient<V1_IApplicationService, V1_ApplicationService>();
|
||||
services.AddTransient<V1_IApplicationTypeService, V1_ApplicationTypeService>();
|
||||
services.AddTransient<V1_IApplicationInHostService, V1_ApplicationInHostService>();
|
||||
services.AddTransient<V1_IJobService, V1_JobService>();
|
||||
services.AddTransient<V1_IJobJournalService, V1_JobJournalService>();
|
||||
services.AddTransient<IRawDataEKService, RawDataEKService>();
|
||||
services.AddTransient<ISettingService, SettingService>();
|
||||
//services.AddTransient<ISchedulerService, SchedulerService>();
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Abstracts;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations
|
||||
{
|
||||
internal class ApplicationInHostService : BaseService<V1_ApplicationInHost>, IApplicationInHostService
|
||||
internal class ApplicationInHostService : BaseService<ApplicationInHost>, IApplicationInHostService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<ApplicationInHostService> logger;
|
||||
@@ -18,7 +18,7 @@ namespace PARR.DAL.Services.Implementations
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
protected override DbSet<V1_ApplicationInHost> EntitySet => dataContext.ApplicationsInHosts;
|
||||
protected override DbSet<ApplicationInHost> EntitySet => dataContext.ApplicationsInHosts;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Abstracts;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations
|
||||
{
|
||||
internal class ApplicationService : BaseService<V1_Application>, IApplicationService
|
||||
internal class ApplicationService : BaseService<Application>, IApplicationService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<ApplicationService> logger;
|
||||
@@ -18,11 +18,11 @@ namespace PARR.DAL.Services.Implementations
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
protected override DbSet<V1_Application> EntitySet => dataContext.Applications;
|
||||
protected override DbSet<Application> EntitySet => dataContext.Applications;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
|
||||
public async Task<V1_Application?> GetByNameAsync(string appName)
|
||||
public async Task<Application?> GetByNameAsync(string appName)
|
||||
{
|
||||
return await EntitySet.FirstOrDefaultAsync(t => t.Name.ToLower() == appName.Trim().ToLower());
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Abstracts;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations
|
||||
namespace PARR.DAL.Services.Implementation
|
||||
{
|
||||
internal class ApplicationTypeService : BaseService<V1_ApplicationType>, IApplicationTypeService
|
||||
internal class ApplicationTypeService : BaseService<ApplicationType>, IApplicationTypeService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<ApplicationTypeService> logger;
|
||||
@@ -18,7 +18,7 @@ namespace PARR.DAL.Services.Implementations
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
protected override DbSet<V1_ApplicationType> EntitySet => dataContext.ApplicationTypes;
|
||||
protected override DbSet<ApplicationType> EntitySet => dataContext.ApplicationTypes;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Abstracts;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations
|
||||
{
|
||||
internal class HostService : BaseService<V1_Host>, IHostService
|
||||
internal class HostService : BaseService<Host>, IHostService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<HostService> logger;
|
||||
|
||||
protected override DbSet<V1_Host> EntitySet => dataContext.Hosts;
|
||||
protected override DbSet<Host> EntitySet => dataContext.Hosts;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
public HostService(DataContext dataContext, ILogger<HostService> logger) : base(logger)
|
||||
@@ -21,7 +21,7 @@ namespace PARR.DAL.Services.Implementations
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public async Task<V1_Host?> GetHostWithAppsAsync(string IP, string RegionalEK)
|
||||
public async Task<Host?> GetHostWithAppsAsync(string IP)
|
||||
{
|
||||
|
||||
//try
|
||||
@@ -37,21 +37,7 @@ namespace PARR.DAL.Services.Implementations
|
||||
return await EntitySet
|
||||
.Include(t => t.ApplicationsInHosts).ThenInclude(a => a.Application).ThenInclude(t => t.ApplicationType)
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(h => h.IP == IP && h.RegionalEK == RegionalEK);
|
||||
}
|
||||
|
||||
public async Task<V1_Host?> GetHostWithAppsAsync(string IP, string linkEK, string regionalEK)
|
||||
{
|
||||
return await EntitySet
|
||||
.Include(t => t.ApplicationsInHosts).ThenInclude(a => a.Application).ThenInclude(t => t.ApplicationType)
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(h => h.IP == IP && h.LinkEK == linkEK && h.RegionalEK == regionalEK);
|
||||
}
|
||||
|
||||
|
||||
public async Task<V1_Host?> GetHostByIPAndRegionalEKAsync(string IP, string RegionalEK)
|
||||
{
|
||||
return await EntitySet.FirstOrDefaultAsync(h => h.IP == IP && h.RegionalEK == RegionalEK);
|
||||
.FirstOrDefaultAsync(h => h.IP == IP);
|
||||
}
|
||||
|
||||
//public async Task<Host?> GetHostByRegionalEKAsync(string RegionalEK)И
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Abstracts;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations
|
||||
{
|
||||
internal class JobCategoryService : BaseService<V1_JobCategory>, IJobCategoryService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<JobCategoryService> logger;
|
||||
|
||||
public JobCategoryService(DataContext dataContext, ILogger<JobCategoryService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
this.logger = logger;
|
||||
}
|
||||
protected override DbSet<V1_JobCategory> EntitySet => dataContext.JobCategories;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Extensions;
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Abstracts;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations
|
||||
{
|
||||
internal class JobJournalService : BaseService<V1_JobJournal>, IJobJournalService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<JobJournalService> logger;
|
||||
|
||||
public JobJournalService(DataContext dataContext, ILogger<JobJournalService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
this.logger = logger;
|
||||
}
|
||||
protected override DbSet<V1_JobJournal> EntitySet => dataContext.JobJournals;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
|
||||
public async Task<V1_JobJournal?> GetLastAsync(Guid jobId, Guid hostId, DateTimeOffset date)
|
||||
{
|
||||
//var n=DateTimeOffset.UtcNow;
|
||||
//var opers = await EntitySet
|
||||
// .Where(j => j.JobId == jobId && j.HostId == hostId && (j.DateOper!=DateTimeOffset.MinValue))/*date.StartOfDay()*/// && j.DateOper < date.EndOfDay()))
|
||||
// .OrderBy(t => t.DateOper)
|
||||
// .LastOrDefaultAsync();
|
||||
|
||||
var opers = await EntitySet
|
||||
.Where(j => j.JobId == jobId && j.HostId == hostId && j.DateOper.DateTime.Date == date.DateTime.Date)
|
||||
.OrderBy(t => t.DateOper)
|
||||
.LastOrDefaultAsync();
|
||||
|
||||
return opers;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Abstracts;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations
|
||||
{
|
||||
internal class JobModeService : BaseService<V1_JobMode>, IJobModeService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<JobModeService> logger;
|
||||
|
||||
public JobModeService(DataContext dataContext, ILogger<JobModeService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
this.logger = logger;
|
||||
}
|
||||
protected override DbSet<V1_JobMode> EntitySet => dataContext.JobModes;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Abstracts;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations
|
||||
{
|
||||
internal class JobService : BaseService<V1_Job>, IJobService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<JobService> logger;
|
||||
|
||||
public JobService(DataContext dataContext,ILogger<JobService> logger):base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
this.logger = logger;
|
||||
}
|
||||
protected override DbSet<V1_Job> EntitySet => dataContext.Jobs;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Abstracts;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations
|
||||
{
|
||||
internal class JobStatusService : BaseService<V1_JobStatus>, IJobStatusService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<JobStatusService> logger;
|
||||
|
||||
public JobStatusService(DataContext dataContext, ILogger<JobStatusService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
this.logger = logger;
|
||||
}
|
||||
protected override DbSet<V1_JobStatus> EntitySet => dataContext.JobStatuses;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Abstracts;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations
|
||||
{
|
||||
//internal class SchedulerService : BaseService<Scheduler>, ISchedulerService
|
||||
//{
|
||||
// private readonly DataContext dataContext;
|
||||
|
||||
// public SchedulerService(DataContext dataContext, ILogger<SchedulerService> logger) : base(logger)
|
||||
// {
|
||||
// this.dataContext = dataContext;
|
||||
// }
|
||||
// protected override DbSet<Scheduler> EntitySet => dataContext.Schedulers;
|
||||
|
||||
// protected override DataContext EntitiContext => dataContext;
|
||||
//}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IApplicationInHostService : IBaseService<V1_ApplicationInHost>
|
||||
public interface IApplicationInHostService : IBaseService<ApplicationInHost>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IApplicationService : IBaseService<V1_Application>
|
||||
public interface IApplicationService : IBaseService<Application>
|
||||
{
|
||||
Task<V1_Application?> GetByNameAsync(string appName);
|
||||
Task<Application?> GetByNameAsync(string appName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IApplicationTypeService : IBaseService<V1_ApplicationType>
|
||||
public interface IApplicationTypeService : IBaseService<ApplicationType>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IHostService : IBaseService<V1_Host>
|
||||
public interface IHostService : IBaseService<Host>
|
||||
{
|
||||
Task<V1_Host?> GetHostByIPAndRegionalEKAsync(string IP, string RegionalEK);
|
||||
Task<V1_Host?> GetHostWithAppsAsync(string IP, string linkEK, string regionalEK);
|
||||
//Task<Host?> GetHostByRegionalEKAsync(string LinkEK);
|
||||
//Task<bool> UpdateAsync(Host host);
|
||||
Task<Host?> GetHostWithAppsAsync(string IP);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
internal interface IJobCategoryService : IBaseService<V1_JobCategory>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using PARR.DAL.Models.V1;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IJobJournalService
|
||||
{
|
||||
Task<V1_JobJournal?> GetLastAsync(Guid jobId, Guid hostId, DateTimeOffset date);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
internal interface IJobModeService : IBaseService<V1_JobMode>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
public interface IJobService : IBaseService<V1_Job>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
internal interface IJobStatusService : IBaseService<V1_JobStatus>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
{
|
||||
//public interface ISchedulerService : IBaseService<Scheduler>
|
||||
//{
|
||||
//}
|
||||
}
|
||||
Reference in New Issue
Block a user