refactor(all): Удалены из БД таблицы V1
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
{
|
||||
public interface ISyncher
|
||||
{
|
||||
Task InvokeAsync();
|
||||
Task InvokeFromDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ using PARR.AIHIT.MappingProfiles.Resolvers;
|
||||
using PARR.AIHIT.Models;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Models.AIHIT;
|
||||
using PARR.DAL.Models.V1;
|
||||
using System.Xml;
|
||||
|
||||
namespace PARR.AIHIT.MappingProfiles
|
||||
{
|
||||
@@ -12,14 +10,14 @@ namespace PARR.AIHIT.MappingProfiles
|
||||
{
|
||||
public RequestToDomain()
|
||||
{
|
||||
CreateMap<XmlNode, V1_Host>()
|
||||
.ForMember(d => d.HostName, o => o.MapFrom(s => (s.Attributes!["ХОСТ"] != null) ? s.Attributes!["ХОСТ"]!.Value.Trim() : ""))
|
||||
.ForMember(d => d.IP, o => o.MapFrom(s => s.Attributes!["IP_АДРЕС"]!.Value.Trim()))
|
||||
.ForMember(d => d.RegionalEK, o => o.MapFrom(s => s.Attributes!["РЕГИОНАЛЬНЫЙ_ЭК"]!.Value.Trim()))
|
||||
.ForMember(d => d.LinkEK, o => o.MapFrom(s => s.Attributes!["СВЯЗАННЫЙ_ЭК"]!.Value.Trim()))
|
||||
.ForMember(d => d.Status, o => o.MapFrom(s => s.Attributes!["СТАТУС"]!.Value.Trim()))
|
||||
.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<XmlNode, V1_Host>()
|
||||
// .ForMember(d => d.HostName, o => o.MapFrom(s => (s.Attributes!["ХОСТ"] != null) ? s.Attributes!["ХОСТ"]!.Value.Trim() : ""))
|
||||
// .ForMember(d => d.IP, o => o.MapFrom(s => s.Attributes!["IP_АДРЕС"]!.Value.Trim()))
|
||||
// .ForMember(d => d.RegionalEK, o => o.MapFrom(s => s.Attributes!["РЕГИОНАЛЬНЫЙ_ЭК"]!.Value.Trim()))
|
||||
// .ForMember(d => d.LinkEK, o => o.MapFrom(s => s.Attributes!["СВЯЗАННЫЙ_ЭК"]!.Value.Trim()))
|
||||
// .ForMember(d => d.Status, o => o.MapFrom(s => s.Attributes!["СТАТУС"]!.Value.Trim()))
|
||||
// .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<RawDataEK, Host>()
|
||||
.ForMember(d => d.Ek, o => o.MapFrom(s => s.EKFindCode))//TODO Определить имя хоста по
|
||||
|
||||
@@ -1,32 +1,19 @@
|
||||
using AutoMapper;
|
||||
using MailKit.Search;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MimeKit;
|
||||
using PARR.AIHIT.Services;
|
||||
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;
|
||||
|
||||
namespace PARR.AIHIT
|
||||
{
|
||||
internal class Syncher : ISyncher
|
||||
{
|
||||
private readonly ILogger<Syncher> logger;
|
||||
private readonly IMailService mailService;
|
||||
private readonly SyncherSettings syncherSettings;
|
||||
private readonly V1_IHostService V1_hostService;
|
||||
private readonly V1_IApplicationInHostService V1_appInHostService;
|
||||
private readonly V1_IApplicationService V1_appService;
|
||||
private readonly IHostService hostService;
|
||||
private readonly IMapper mapper;
|
||||
private readonly IApplicationService appService;
|
||||
@@ -34,26 +21,18 @@ namespace PARR.AIHIT
|
||||
private readonly IApplicationInHostService appInHostService;
|
||||
private readonly IRawDataEKService rawDataEKService;
|
||||
private readonly ISettingService settingService;
|
||||
private readonly IAIHITService aihitService;
|
||||
|
||||
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,
|
||||
IApplicationTypeService appTypeService,
|
||||
IApplicationInHostService appInHostService,
|
||||
IRawDataEKService rawDataEKService,
|
||||
ISettingService settingService,
|
||||
IAIHITService aihitService
|
||||
ISettingService settingService
|
||||
)
|
||||
{
|
||||
this.hostService = hostService;
|
||||
@@ -63,13 +42,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;
|
||||
this.V1_hostService = V1_hostService;
|
||||
this.V1_appService = V1_appService;
|
||||
this.V1_appInHostService = V1_appInHostService;
|
||||
}
|
||||
|
||||
private async Task GetAppTypesAsync()
|
||||
@@ -77,137 +50,6 @@ namespace PARR.AIHIT
|
||||
AppTypes = await appTypeService.Get().ToListAsync();
|
||||
}
|
||||
|
||||
public async Task InvokeAsync()
|
||||
{
|
||||
await GetAppTypesAsync();
|
||||
|
||||
|
||||
var messages = await mailService.CheckMailAsync(SearchQuery.NotSeen);
|
||||
if (!messages.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
var filtered = messages.Where(m => syncherSettings.IncludeAddressesArray.Any(i => m.Envelope.From.Mailboxes.FirstOrDefault()?.Address == i)).ToList();
|
||||
var lastMessage = filtered.OrderByDescending(f => f.Date).First();
|
||||
var attachments = await mailService.GetAttachmentsAsync(lastMessage);
|
||||
|
||||
foreach (var attachment in attachments)
|
||||
{
|
||||
if (attachment is MessagePart)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
using var stream = new MemoryStream();
|
||||
((MimePart)attachment).Content.DecodeTo(stream);
|
||||
if (stream.Position > 0) stream.Position = 0;
|
||||
|
||||
var fileName = EncodeString(((MimePart)attachment).FileName);
|
||||
logger.LogInformation($" Получен файл {fileName}");
|
||||
if (fileName.Equals("Компонентный состав регионального ЭК.xml"))
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.Load(stream);
|
||||
var vms = doc.GetElementsByTagName("Сведения");
|
||||
//var hosts = await hostService.Get().ToListAsync();
|
||||
foreach (XmlNode vm in vms)
|
||||
{
|
||||
var ip = vm?.Attributes?["IP_АДРЕС"]?.Value.Trim();
|
||||
if (ip == null) continue;
|
||||
var regionalEK = vm!.Attributes!["РЕГИОНАЛЬНЫЙ_ЭК"]!.Value.Trim();
|
||||
var linkEK = vm!.Attributes!["СВЯЗАННЫЙ_ЭК"]!.Value.Trim();
|
||||
if (!linkEK.StartsWith("ВРТ")) continue;
|
||||
|
||||
// var foundHost = await hostService.GetHostAsync(ip, linkEK, regionalEK);
|
||||
var foundHost = await V1_hostService.GetHostWithAppsAsync(ip, linkEK, regionalEK);
|
||||
var mappedHost = mapper.Map<V1_Host>(vm);
|
||||
|
||||
var hostApplications = await V1_GetAndFillApplicationsAsync(vm);
|
||||
|
||||
if (foundHost == null)
|
||||
{
|
||||
// создаем
|
||||
if (!await V1_hostService.CreateAsync(mappedHost) || !await V1_hostService.CommitAsync())
|
||||
{
|
||||
logger.LogError($"Не удалось создать узел {mappedHost.IP} {mappedHost.RegionalEK}");
|
||||
continue;
|
||||
}
|
||||
else
|
||||
logger.LogInformation($"----- Создан Host: {mappedHost.Id}, {mappedHost.LinkEK} -----");
|
||||
|
||||
|
||||
// Синхронизация Applications
|
||||
await V1_SyncApplicationAndHostAsync(foundHost, hostApplications);
|
||||
}
|
||||
else
|
||||
{
|
||||
// обновляем
|
||||
var isChanged = false;
|
||||
if (!foundHost.RegionalEK!.Equals(mappedHost.RegionalEK))
|
||||
{
|
||||
foundHost.RegionalEK = mappedHost.RegionalEK; isChanged = true;
|
||||
}
|
||||
else if (!foundHost.LinkEK!.Equals(mappedHost.LinkEK))
|
||||
{
|
||||
foundHost.LinkEK = mappedHost.LinkEK;
|
||||
isChanged = true;
|
||||
}
|
||||
else 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;
|
||||
}
|
||||
else if (!foundHost.Responsible!.Equals(mappedHost.Responsible))
|
||||
{
|
||||
foundHost.Responsible = mappedHost.Responsible;
|
||||
isChanged = true;
|
||||
}
|
||||
//else if (!foundHost.OS!.Equals(mappedHost.OS))
|
||||
//{
|
||||
// foundHost.OS = mappedHost.OS;
|
||||
// isChanged = true;
|
||||
//}
|
||||
//else if (!foundHost.DB!.Equals(mappedHost.DB))
|
||||
//{
|
||||
// foundHost.DB = mappedHost.DB;
|
||||
// isChanged = true;
|
||||
//}
|
||||
//else if (!foundHost.APP!.Equals(mappedHost.APP))
|
||||
//{
|
||||
// foundHost.APP = mappedHost.APP;
|
||||
// isChanged = true;
|
||||
//}
|
||||
|
||||
if (isChanged)
|
||||
{
|
||||
foundHost.DateModified = DateTimeOffset.UtcNow;
|
||||
if (!await V1_hostService.CommitAsync())
|
||||
logger.LogError($"Не удалось обновить узел {mappedHost.IP} {mappedHost.RegionalEK}");
|
||||
else
|
||||
logger.LogInformation($"----- Обновлён Host: {mappedHost.Id}, {mappedHost.LinkEK} -----");
|
||||
}
|
||||
|
||||
// Синхронизация Applications
|
||||
await V1_SyncApplicationAndHostAsync(foundHost, hostApplications, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//прочитано для всех
|
||||
foreach (var message in filtered)
|
||||
{
|
||||
await mailService.SetAsSeenAsync(message);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task InvokeFromDatabase()
|
||||
{
|
||||
@@ -274,7 +116,7 @@ namespace PARR.AIHIT
|
||||
|
||||
foreach (var ek in eks)
|
||||
{
|
||||
if (ek.IP == null)
|
||||
if (ek.IP == null)
|
||||
continue;
|
||||
|
||||
var foundHost = await hostService.GetHostWithAppsAsync(ek.IP);
|
||||
@@ -327,93 +169,7 @@ namespace PARR.AIHIT
|
||||
}
|
||||
}
|
||||
}
|
||||
private async Task V1_SyncApplicationAndHostAsync(V1_Host? host, List<V1_Application> hostApplications, bool isUpdateDateModified = false)
|
||||
{
|
||||
var isUpdated = false;
|
||||
if (host == null)
|
||||
return;
|
||||
|
||||
logger.LogInformation($"--- Host: {host.Id}, {host.LinkEK} начало синхронизации приложений ({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}, {host.LinkEK} добавление нового приложения Application {changedHostApp.Name}");
|
||||
|
||||
var newAppHost = new V1_ApplicationInHost { Id = Guid.NewGuid(), ApplicationId = changedHostApp.Id, HostId = host.Id };
|
||||
if (!await V1_appInHostService.CreateAsync(newAppHost))
|
||||
logger.LogError($"Не удалось создать ApplicationInHost {changedHostApp.Name}, host: {host.Id}, {host.LinkEK}");
|
||||
|
||||
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 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}");
|
||||
V1_appInHostService.Delete(obj);
|
||||
|
||||
isUpdated = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isUpdated && isUpdateDateModified)
|
||||
host.DateModified = DateTimeOffset.UtcNow;
|
||||
|
||||
if (!await appInHostService.CommitAsync())
|
||||
logger.LogError($"Не удалось обновить ApplicationInHost для Host: {host.LinkEK}, {host.Id}");
|
||||
|
||||
logger.LogInformation($"=== Host: {host.Id}, {host.LinkEK} конец синхронизации приложений ===");
|
||||
|
||||
}
|
||||
|
||||
private async Task<List<V1_Application>> V1_GetAndFillApplicationsAsync(XmlNode vm)
|
||||
{
|
||||
logger.LogInformation($"--- Начало парсинга данных о программном обеспечении(СП, БД, ОС) из Xml документа от АИХ ИТ ---");
|
||||
var applications = new List<V1_Application>();
|
||||
|
||||
//TODO GetAppFromXML(vm?.Attributes?["СП"]?.Value).ForEach(async item => await CreateAppIfNotExistAsync(item, ApplicationTypesEnum.APP));
|
||||
//GetDBFromXML(vm?.Attributes?["СУБД"]?.Value).ForEach(async item => await CreateAppIfNotExistAsync(item, ApplicationTypesEnum.DB));
|
||||
//GetOSFromXML(vm?.Attributes?["ОС"]?.Value).ForEach(async item => await CreateAppIfNotExistAsync(item, ApplicationTypesEnum.OS));
|
||||
var appList = GetAppFromXML(vm?.Attributes?["СП"]?.Value);
|
||||
foreach (var app in appList)
|
||||
{
|
||||
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 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 V1_CreateAppIfNotExistAsync(os, ApplicationTypesEnum.OS);
|
||||
if (created != null)
|
||||
applications.Add(created);
|
||||
}
|
||||
|
||||
logger.LogInformation($"=== Конец парсинга данных о программном обеспечении(СП, БД, ОС) из Xml документа от АИХ ИТ ===");
|
||||
|
||||
return applications;
|
||||
}
|
||||
|
||||
private async Task SyncApplicationAndHostAsync(Host? host, List<Application> hostApplications, bool isUpdateDateModified = false)
|
||||
{
|
||||
@@ -467,6 +223,8 @@ namespace PARR.AIHIT
|
||||
logger.LogInformation($"=== Host: {host.Id} конец синхронизации приложений ===");
|
||||
|
||||
}
|
||||
|
||||
|
||||
private async Task<List<Application>> GetAndFillApplicationsAsync(RawDataEK vm)
|
||||
{
|
||||
logger.LogInformation($"--- Начало парсинга данных о программном обеспечении(СП, БД, ОС) из АИХ ИТ ---");
|
||||
@@ -508,6 +266,7 @@ namespace PARR.AIHIT
|
||||
return applications;
|
||||
}
|
||||
|
||||
|
||||
private List<string> GetAppFromXML(string? appField)
|
||||
{
|
||||
if (string.IsNullOrEmpty(appField))
|
||||
@@ -519,6 +278,7 @@ namespace PARR.AIHIT
|
||||
return appList;
|
||||
}
|
||||
|
||||
|
||||
private List<string> GetDBFromXML(string? dbField)
|
||||
{
|
||||
if (string.IsNullOrEmpty(dbField))
|
||||
@@ -530,6 +290,7 @@ namespace PARR.AIHIT
|
||||
return dbList;
|
||||
}
|
||||
|
||||
|
||||
private List<string> GetOSFromXML(string? osField)
|
||||
{
|
||||
if (string.IsNullOrEmpty(osField))
|
||||
@@ -541,36 +302,6 @@ namespace PARR.AIHIT
|
||||
return osList;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@@ -603,6 +334,7 @@ namespace PARR.AIHIT
|
||||
return await appService.GetAsync(app.Id);
|
||||
}
|
||||
|
||||
|
||||
private ApplicationType? GetAppTypeByName(ApplicationTypesEnum type)
|
||||
{
|
||||
var existType = AppTypes.FirstOrDefault(t => t.Name == type.ToString());
|
||||
@@ -612,6 +344,7 @@ namespace PARR.AIHIT
|
||||
return existType;
|
||||
}
|
||||
|
||||
|
||||
private static string EncodeString(string str)
|
||||
{
|
||||
byte[] bStr = Encoding.GetEncoding("koi8r").GetBytes(str);
|
||||
|
||||
@@ -27,20 +27,6 @@
|
||||
public const string Metrics = Base + "/metrics";
|
||||
}
|
||||
|
||||
public static class Jobs
|
||||
{
|
||||
public const string GetAll = Base + "/jobs/";
|
||||
|
||||
public const string GetByIp = Base + "/jobs/ip/";
|
||||
//public const string Get = Base + "/schedulers/" + getParam;
|
||||
|
||||
//public const string GetAreas = Base + "/schedulers/" + getParam + "/areas";
|
||||
//public const string GetPlaces = Base + "/schedulers/" + getParam + "/places";
|
||||
//public const string GetTemplates = Base + "/schedulers/" + getParam + "/templates";
|
||||
|
||||
public const string getParam = "{id}";
|
||||
}
|
||||
|
||||
public static class AgentTask
|
||||
{
|
||||
public const string GetByIp = Base + "/agent-tasks/ip";
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
public class AgentTaskGetByIpQuery
|
||||
{
|
||||
/// <summary>
|
||||
/// По-умолчанию берётся IP-клиента
|
||||
/// По умолчанию берётся IP-клиента
|
||||
/// </summary>
|
||||
public string? Ip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// По-умолчанию расписание на сегодня
|
||||
/// По умолчанию расписание на сегодня
|
||||
/// </summary>
|
||||
public DateTimeOffset? Date { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
namespace PARR.API.Contracts.V1.Requests.Queries
|
||||
{
|
||||
public class JobGetAllQuery
|
||||
{
|
||||
/// <summary>
|
||||
/// true - вкл задания, false - выкл задания, null - все задания
|
||||
/// </summary>
|
||||
public bool? IsEnabled { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Список запланированных заданий на указанную дату
|
||||
/// </summary>
|
||||
public DateTimeOffset? StartDatePlanned { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
namespace PARR.API.Contracts.V1.Requests.Queries
|
||||
{
|
||||
public class JobGetByIpQuery
|
||||
{
|
||||
/// <summary>
|
||||
/// По-умолчанию берётся IP-клиента или указанный вручную
|
||||
/// </summary>
|
||||
public string? Ip { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// По-умолчанию расписание на сегодня или указанную дату
|
||||
/// </summary>
|
||||
public DateTimeOffset? Date { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Вернуть полностью объект Job в json формате или вернуть краткий список со временем
|
||||
/// </summary>
|
||||
public bool? IsFullResponse { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace PARR.API.Contracts.V1.Responses
|
||||
{
|
||||
public class JobModeResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public required string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
namespace PARR.API.Contracts.V1.Responses
|
||||
{
|
||||
public class JobBaseResponse
|
||||
{
|
||||
public required string Name { get; set; }
|
||||
public DateTimeOffset StartAt { get; set; }
|
||||
public int FrequencyMinute { get; set; }
|
||||
public required JobModeResponse JobMode { get; set; }
|
||||
public required string Script { get; set; }
|
||||
}
|
||||
|
||||
public class JobGetAllResponse : JobBaseResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public bool IsEnabled { get; set; }
|
||||
}
|
||||
|
||||
public class JobResponse
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class JobMinResponse
|
||||
{
|
||||
public List<JobMinScheduleResponse> Scheduled { get; set; } = new List<JobMinScheduleResponse>();
|
||||
}
|
||||
|
||||
public class JobMinScheduleResponse
|
||||
{
|
||||
public DateTimeOffset StartAt { get; set; }
|
||||
|
||||
public required string Script { get; set; }
|
||||
|
||||
public required string Name { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.API.Contracts.V1;
|
||||
using PARR.API.Contracts.V1.Requests.Queries;
|
||||
using PARR.API.Contracts.V1.Responses;
|
||||
using PARR.API.Contracts.V1.Responses.Base;
|
||||
using PARR.API.Controllers.V1.Base;
|
||||
using PARR.API.Extensions;
|
||||
using PARR.API.Services.Interfaces;
|
||||
using PARR.DAL.DomainModels;
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Interfaces.V1;
|
||||
|
||||
namespace PARR.API.Controllers.V1
|
||||
{
|
||||
public class JobController : BaseApiController
|
||||
{
|
||||
private readonly IMapper mapper;
|
||||
private readonly V1_IJobService jobService;
|
||||
//private readonly ISchedulerService schedulerService;
|
||||
private readonly IClientService clientService;
|
||||
private readonly V1_IHostService v1_hostService;
|
||||
private readonly V1_IJobJournalService jobJournalService;
|
||||
|
||||
public JobController(
|
||||
IMapper mapper,
|
||||
V1_IJobService jobService,
|
||||
IClientService clientService,
|
||||
V1_IHostService v1_hostService,
|
||||
V1_IJobJournalService jobJournalService
|
||||
)
|
||||
{
|
||||
this.mapper = mapper;
|
||||
this.jobService = jobService;
|
||||
//this.schedulerService = schedulerService;
|
||||
this.clientService = clientService;
|
||||
this.v1_hostService = v1_hostService;
|
||||
this.jobJournalService = jobJournalService;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// (НЕ РАБОТАЕТ. АДАПТАЦИЯ ПОД НОВУЮ ВЕРСИЮ) Список всех jobов постранично в соотвествии с фильтрами
|
||||
/// </summary>
|
||||
/// <param name="paginationQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.Jobs.GetAll)]
|
||||
public async Task<IActionResult> GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] JobGetAllQuery filter)
|
||||
{
|
||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
||||
IQueryable<V1_Job> query = jobService.Get().Include(t => t.JobMode).OrderBy(s => s.StartAt);
|
||||
|
||||
if (filter.IsEnabled.HasValue)
|
||||
query = query.Where(t => t.IsEnabled == filter.IsEnabled);
|
||||
|
||||
if (filter.StartDatePlanned.HasValue)
|
||||
query = query.Where(t => t.StartAt.DateTime.Date <= filter.StartDatePlanned.Value.DateTime.Date); ;
|
||||
|
||||
var jobs = await jobService.GetPage(query, paginationFilter).ToListAsync();
|
||||
|
||||
if (!jobs.Any())
|
||||
return NoContent();
|
||||
|
||||
var jobResponse = mapper.Map<List<JobGetAllResponse>>(jobs);
|
||||
var paginationResponse = new PagedResponse<JobGetAllResponse>(jobResponse, true).GetPaginatedProps(paginationFilter, query);
|
||||
|
||||
return Ok(paginationResponse);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// (НЕ РАБОТАЕТ. АДАПТАЦИЯ ПОД НОВУЮ ВЕРСИЮ) Список заданий на запуск по IP-адресу клиента исполнения
|
||||
/// </summary>
|
||||
/// <param name="requestQuery"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet(ApiRoutes.Jobs.GetByIp)]
|
||||
public async Task<IActionResult> GetByClientIP([FromQuery] JobGetByIpQuery requestQuery)
|
||||
{
|
||||
var ip = requestQuery.Ip ?? clientService.GetClientIp()?.ToString();
|
||||
if (string.IsNullOrEmpty(ip))
|
||||
return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = "Client IP address is null." } }));
|
||||
|
||||
var date = requestQuery.Date ?? DateTimeOffset.UtcNow;
|
||||
|
||||
// С одним IP может быть несколько информационных систем, соответственного а таблице храниться несколько записей хостов с одинаковым IP
|
||||
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)
|
||||
{
|
||||
var jobsHost = await jobService.Get()
|
||||
.Include(a => a.Application).ThenInclude(ah => ah.ApplicationsInHosts)/*.ThenInclude(h => h.Host)*/
|
||||
.Include(jm => jm.JobMode)
|
||||
.AsSplitQuery()
|
||||
.Where(j => j.Application != null && j.Application.ApplicationsInHosts.Any(ah => ah.HostId == host.Id) && j.IsEnabled && j.StartAt <= date)
|
||||
.ToListAsync();
|
||||
|
||||
if (jobsHost.Any())
|
||||
{
|
||||
hostJobsDict.Add(host, jobsHost);
|
||||
}
|
||||
}
|
||||
|
||||
var jobsList = new List<V1_Job>();
|
||||
var jobsToResponse = new List<V1_Job>();
|
||||
|
||||
foreach (var hostAndJobs in hostJobsDict)
|
||||
{
|
||||
foreach (var item in hostAndJobs.Value)
|
||||
{
|
||||
if (!jobsList.Contains(item))
|
||||
{
|
||||
jobsList.Add(item);
|
||||
|
||||
var plannedJobs = await GetListJobsAsync(item, hostAndJobs.Key, date);
|
||||
jobsToResponse.AddRange(plannedJobs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jobsToResponse = jobsToResponse.OrderBy(t => t.StartAt).ToList();
|
||||
|
||||
if (!jobsToResponse.Any())
|
||||
return NoContent();
|
||||
|
||||
if (requestQuery.IsFullResponse == true)
|
||||
{
|
||||
// возврат самого полного ответа
|
||||
var jobResponse = mapper.Map<List<JobGetAllResponse>>(jobsToResponse);
|
||||
return Ok(new Response<List<JobGetAllResponse>>(jobResponse, true));
|
||||
}
|
||||
|
||||
|
||||
// возврат минимального ответа
|
||||
return Ok(mapper.Map<JobMinResponse>(jobsToResponse));
|
||||
|
||||
//try
|
||||
//{
|
||||
// return Ok(jobsToResponse.ToDictionary(t => t.ScriptName, d => d.StartAt));
|
||||
//}
|
||||
//catch (ArgumentException ex)
|
||||
//{
|
||||
// return BadRequest(new Response(false, new List<ErrorModel> { new ErrorModel { Message = $"Не могу создать json объект с одинаковым значением ключа (ScriptName). {ex.Message}" } }));
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
private async Task<List<V1_Job>> GetListJobsAsync(V1_Job job, V1_Host host, DateTimeOffset queryDate)
|
||||
{
|
||||
var jobs = new List<V1_Job>();
|
||||
|
||||
#region description
|
||||
// freaq > суток или нет?
|
||||
|
||||
//-----------
|
||||
// меньше суток
|
||||
//фрек=10 мин
|
||||
// старт эт = 17:00 и != сегодня
|
||||
|
||||
//цикл 17:00 -10мин пока не начнется вчерашний день
|
||||
//цикл 17:00 +10мин пока не начентся завтрашний день
|
||||
|
||||
// елси страт эт == сегодня
|
||||
//цикл 17:00 +10мин пока не начентся завтрашний день
|
||||
|
||||
//-----------
|
||||
|
||||
// ------freaq больше суток--------
|
||||
// журнал берем последнее событие (че там со статусами? не надо пока), к нему пребавляем фрек, и смотрим == сегодня или нет, если сегодня то добавляем
|
||||
// --------------
|
||||
#endregion
|
||||
|
||||
var allDayMinutes = 1440;
|
||||
if (job.Frequency >= allDayMinutes)
|
||||
{
|
||||
//больше или = суток
|
||||
|
||||
var lastJournalItem = await jobJournalService.GetLastAsync(job.Id, host.Id, queryDate);
|
||||
if (lastJournalItem == null)
|
||||
{
|
||||
// если в истории нет записей, то запускаем сегодня в стартЭт
|
||||
// берем квери дэйт и ем задаем время из Джобс СтартЭт
|
||||
var startDateTimeNext = new DateTimeOffset(queryDate.Year, queryDate.Month, queryDate.Day, job.StartAt.Hour, job.StartAt.Minute, job.StartAt.Second, new TimeSpan(0));
|
||||
var jobToAdded = mapper.Map<V1_Job>(job);//new Job { StartAt = startDateTimeNext };
|
||||
jobToAdded.StartAt = startDateTimeNext;
|
||||
|
||||
jobs.Add(jobToAdded);
|
||||
}
|
||||
else
|
||||
{
|
||||
var startDateNext = lastJournalItem.DateOper.DateTime.AddMinutes(job.Frequency);
|
||||
if (startDateNext.Date == queryDate.DateTime.Date)
|
||||
{
|
||||
// если берем прошлую последнюю операцию из журнала, и к ней прибавить фрекунси, то время следующего старта сдвинется на время выполнения прошлого задания
|
||||
// чтобы это избежать, берем квери дэйт и ем задаем время из Джобс СтартЭт
|
||||
var startDateTimeNext = new DateTimeOffset(queryDate.Year, queryDate.Month, queryDate.Day, job.StartAt.Hour, job.StartAt.Minute, job.StartAt.Second, new TimeSpan(0));
|
||||
var jobToAdded = mapper.Map<V1_Job>(job);
|
||||
jobToAdded.StartAt = startDateTimeNext;
|
||||
jobs.Add(jobToAdded);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//меньше суток
|
||||
var startAtMinutes = (job.StartAt - job.StartAt.StartOfDay()).TotalMinutes;
|
||||
|
||||
// если дата старта != queryDate
|
||||
if (job.StartAt.DateTime.Date != queryDate.DateTime.Date)
|
||||
{
|
||||
// отнимаем пока не наступили прошлые стуки
|
||||
var min = startAtMinutes;
|
||||
while (min >= 0)
|
||||
{
|
||||
//var jobToAdded = new Job { StartAt = queryDate.StartOfDay().AddMinutes(min) };
|
||||
var jobToAdded = mapper.Map<V1_Job>(job);
|
||||
jobToAdded.StartAt = queryDate.StartOfDay().AddMinutes(min);
|
||||
jobs.Add(jobToAdded);
|
||||
min = min - job.Frequency;
|
||||
}
|
||||
|
||||
// прибавляем пока не наступят след сутки
|
||||
min = startAtMinutes + job.Frequency;
|
||||
while (min < allDayMinutes)
|
||||
{
|
||||
//var jobToAdded = new Job { StartAt = queryDate.StartOfDay().AddMinutes(min) };
|
||||
var jobToAdded = mapper.Map<V1_Job>(job);
|
||||
jobToAdded.StartAt = queryDate.StartOfDay().AddMinutes(min);
|
||||
jobs.Add(jobToAdded);
|
||||
min = min + job.Frequency;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// = queryDate
|
||||
// прибавляем пока не наступят след сутки
|
||||
var min = startAtMinutes;
|
||||
while (min < allDayMinutes)
|
||||
{
|
||||
//var jobToAdded = new Job { StartAt = queryDate.StartOfDay().AddMinutes(min) };
|
||||
var jobToAdded = mapper.Map<V1_Job>(job);
|
||||
jobToAdded.StartAt = queryDate.StartOfDay().AddMinutes(min);
|
||||
jobs.Add(jobToAdded);
|
||||
min = min + job.Frequency;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return jobs;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using AutoMapper;
|
||||
using PARR.DAL.Models.V1;
|
||||
|
||||
namespace PARR.API.MappingProfiles
|
||||
{
|
||||
@@ -7,7 +6,7 @@ namespace PARR.API.MappingProfiles
|
||||
{
|
||||
public DomainToDomainProfile()
|
||||
{
|
||||
CreateMap<V1_Job, V1_Job>();
|
||||
//CreateMap<V1_Job, V1_Job>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ using PARR.API.MappingProfiles.Resolvers;
|
||||
using PARR.BLL.Helpers;
|
||||
using PARR.DAL.DomainModels;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Models.V1;
|
||||
|
||||
namespace PARR.API.MappingProfiles
|
||||
{
|
||||
@@ -12,23 +11,6 @@ namespace PARR.API.MappingProfiles
|
||||
{
|
||||
public DomainToResponseProfile()
|
||||
{
|
||||
// --- Job ---
|
||||
CreateMap<V1_Job, JobBaseResponse>()
|
||||
.Include<V1_Job, JobGetAllResponse>()
|
||||
.ForMember(d => d.FrequencyMinute, o => o.MapFrom(s => s.Frequency))
|
||||
.ForMember(d => d.Script, o => o.MapFrom(s => s.ScriptName));
|
||||
|
||||
CreateMap<V1_Job, JobGetAllResponse>();
|
||||
|
||||
CreateMap<List<V1_Job>, JobMinResponse>()
|
||||
.ForMember(d => d.Scheduled, o => o.MapFrom(s => s));
|
||||
|
||||
CreateMap<V1_Job, JobMinScheduleResponse>()
|
||||
.ForMember(d => d.Script, o => o.MapFrom(s => s.ScriptName));
|
||||
// === Job ===
|
||||
|
||||
CreateMap<V1_JobMode, JobModeResponse>();
|
||||
|
||||
// --- Template ---
|
||||
CreateMap<Template, TemplateResponse>()
|
||||
.ForMember(d => d.Work, o => o.MapFrom(s => s.ApplicationsInWork!.Work))
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
using PARR.DAL.Contracts;
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Models.AIHIT;
|
||||
using PARR.DAL.Models.V1;
|
||||
using System;
|
||||
|
||||
namespace PARR.DAL.Context
|
||||
{
|
||||
@@ -11,19 +9,6 @@ namespace PARR.DAL.Context
|
||||
{
|
||||
public DataContext(DbContextOptions<DataContext> options) : base(options) { }
|
||||
|
||||
#region v1
|
||||
public DbSet<V1_JobType> JobTypes { get; set; }
|
||||
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> V1_Hosts { get; set; }
|
||||
public DbSet<V1_Job> Jobs { get; set; }
|
||||
public DbSet<V1_JobJournal> JobJournals { 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; }
|
||||
#endregion
|
||||
|
||||
public DbSet<Host> Hosts { get; set; }
|
||||
public DbSet<EkStatus> EkStatuses { get; set; }
|
||||
public DbSet<ResponseArea> ResponseAreas { get; set; }
|
||||
@@ -64,23 +49,6 @@ namespace PARR.DAL.Context
|
||||
|
||||
var dateCreated = new DateTimeOffset(2023, 05, 01, 0, 0, 0, new TimeSpan(0));
|
||||
|
||||
modelBuilder.Entity<V1_JobMode>(f =>
|
||||
{
|
||||
f.HasData(
|
||||
new() { Id = new Guid("FBA4202C-5BAD-49C4-B076-D1CA6E1FB158"), DateCreated = dateCreated, DateModified = null, Name = JobModeEnum.auto.ToString() },
|
||||
new() { Id = new Guid("7516B952-510D-4AAA-971C-A14B184FC1D5"), DateCreated = dateCreated, DateModified = null, Name = JobModeEnum.manual.ToString() }
|
||||
);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<V1_JobStatus>(f =>
|
||||
{
|
||||
f.HasData(
|
||||
new() { Id = new Guid("EDEF6DC3-ADAD-4C77-8AD1-63BB9052355A"), DateCreated = dateCreated, DateModified = null, Name = JobStatusEnum.started.ToString(), Description = "Задание запущено" },
|
||||
new() { Id = new Guid("7B945EB6-D885-4570-AFF5-8866F1F75FF2"), DateCreated = dateCreated, DateModified = null, Name = JobStatusEnum.finished.ToString(), Description = "Задание выполнено" }
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
modelBuilder.Entity<ApplicationType>(f =>
|
||||
{
|
||||
f.HasData(
|
||||
@@ -179,6 +147,7 @@ namespace PARR.DAL.Context
|
||||
);
|
||||
});
|
||||
|
||||
#region Robots
|
||||
|
||||
modelBuilder.Entity<RobotStatus>(f =>
|
||||
{
|
||||
@@ -208,6 +177,8 @@ namespace PARR.DAL.Context
|
||||
);
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
||||
#region EsppSchedules
|
||||
|
||||
modelBuilder.Entity<EsppSchType>(f =>
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace PARR.DAL.Contracts
|
||||
{
|
||||
public enum JobModeEnum
|
||||
{
|
||||
auto,
|
||||
manual
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace PARR.DAL.Contracts
|
||||
{
|
||||
public enum JobStatusEnum
|
||||
{
|
||||
started,
|
||||
finished
|
||||
}
|
||||
}
|
||||
2423
PARR.DAL/Migrations/20231017233652_RemoveTblsV1.Designer.cs
generated
Normal file
2423
PARR.DAL/Migrations/20231017233652_RemoveTblsV1.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
365
PARR.DAL/Migrations/20231017233652_RemoveTblsV1.cs
Normal file
365
PARR.DAL/Migrations/20231017233652_RemoveTblsV1.cs
Normal file
@@ -0,0 +1,365 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
||||
|
||||
namespace PARR.DAL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class RemoveTblsV1 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "V1_ApplicationsInHost");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "V1_JobJournals");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "V1_Applications");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "V1_Hosts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "V1_JobStatuses");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "V1_Jobs");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "V1_ApplicationTypes");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "V1_JobCategorys");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "V1_JobModes");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "V1_JobTypes");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "V1_ApplicationTypes",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
Description = table.Column<string>(type: "text", nullable: true),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
V1_ApplicationTypeId = table.Column<Guid>(type: "uuid", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_V1_ApplicationTypes", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_V1_ApplicationTypes_V1_ApplicationTypes_V1_ApplicationTypeId",
|
||||
column: x => x.V1_ApplicationTypeId,
|
||||
principalTable: "V1_ApplicationTypes",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "V1_Hosts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
HostName = table.Column<string>(type: "text", nullable: true),
|
||||
IP = table.Column<string>(type: "text", nullable: false),
|
||||
LinkEK = table.Column<string>(type: "text", nullable: true),
|
||||
RegionalEK = table.Column<string>(type: "text", nullable: true),
|
||||
Responsible = table.Column<string>(type: "text", nullable: true),
|
||||
Status = table.Column<string>(type: "text", nullable: true),
|
||||
WorkGroup = table.Column<string>(type: "text", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_V1_Hosts", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "V1_JobCategorys",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
Description = table.Column<string>(type: "text", nullable: true),
|
||||
Name = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_V1_JobCategorys", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "V1_JobModes",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
Name = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_V1_JobModes", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "V1_JobStatuses",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
Description = table.Column<string>(type: "text", nullable: true),
|
||||
Name = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_V1_JobStatuses", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "V1_JobTypes",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
Description = table.Column<string>(type: "text", nullable: true),
|
||||
Name = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_V1_JobTypes", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "V1_Applications",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
ApplicationTypeId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
Name = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_V1_Applications", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_V1_Applications_V1_ApplicationTypes_ApplicationTypeId",
|
||||
column: x => x.ApplicationTypeId,
|
||||
principalTable: "V1_ApplicationTypes",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "V1_Jobs",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
ApplicationId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
JobCategoryId = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
JobModeId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
JobTypeId = table.Column<Guid>(type: "uuid", nullable: true),
|
||||
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
Frequency = table.Column<int>(type: "integer", nullable: false),
|
||||
IsEnabled = table.Column<bool>(type: "boolean", nullable: false),
|
||||
Name = table.Column<string>(type: "text", nullable: false),
|
||||
ScriptName = table.Column<string>(type: "text", nullable: false),
|
||||
StartAt = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_V1_Jobs", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_V1_Jobs_Applications_ApplicationId",
|
||||
column: x => x.ApplicationId,
|
||||
principalTable: "Applications",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_V1_Jobs_V1_JobCategorys_JobCategoryId",
|
||||
column: x => x.JobCategoryId,
|
||||
principalTable: "V1_JobCategorys",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_V1_Jobs_V1_JobModes_JobModeId",
|
||||
column: x => x.JobModeId,
|
||||
principalTable: "V1_JobModes",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_V1_Jobs_V1_JobTypes_JobTypeId",
|
||||
column: x => x.JobTypeId,
|
||||
principalTable: "V1_JobTypes",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "V1_ApplicationsInHost",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
ApplicationId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
HostId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
V1_ApplicationId = table.Column<Guid>(type: "uuid", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_V1_ApplicationsInHost", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_V1_ApplicationsInHost_Applications_ApplicationId",
|
||||
column: x => x.ApplicationId,
|
||||
principalTable: "Applications",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_V1_ApplicationsInHost_V1_Applications_V1_ApplicationId",
|
||||
column: x => x.V1_ApplicationId,
|
||||
principalTable: "V1_Applications",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_V1_ApplicationsInHost_V1_Hosts_HostId",
|
||||
column: x => x.HostId,
|
||||
principalTable: "V1_Hosts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "V1_JobJournals",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
HostId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
JobId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
JobStatusId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
DateModified = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
||||
DateOper = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
||||
Info = table.Column<string>(type: "text", nullable: true),
|
||||
Other = table.Column<string>(type: "text", nullable: true),
|
||||
TimeOut = table.Column<int>(type: "integer", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_V1_JobJournals", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_V1_JobJournals_V1_Hosts_HostId",
|
||||
column: x => x.HostId,
|
||||
principalTable: "V1_Hosts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_V1_JobJournals_V1_JobStatuses_JobStatusId",
|
||||
column: x => x.JobStatusId,
|
||||
principalTable: "V1_JobStatuses",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_V1_JobJournals_V1_Jobs_JobId",
|
||||
column: x => x.JobId,
|
||||
principalTable: "V1_Jobs",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "V1_JobModes",
|
||||
columns: new[] { "Id", "DateCreated", "DateModified", "Name" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ new Guid("7516b952-510d-4aaa-971c-a14b184fc1d5"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "manual" },
|
||||
{ new Guid("fba4202c-5bad-49c4-b076-d1ca6e1fb158"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "auto" }
|
||||
});
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "V1_JobStatuses",
|
||||
columns: new[] { "Id", "DateCreated", "DateModified", "Description", "Name" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ new Guid("7b945eb6-d885-4570-aff5-8866f1f75ff2"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "Задание выполнено", "finished" },
|
||||
{ new Guid("edef6dc3-adad-4c77-8ad1-63bb9052355a"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "Задание запущено", "started" }
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_V1_Applications_ApplicationTypeId",
|
||||
table: "V1_Applications",
|
||||
column: "ApplicationTypeId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_V1_ApplicationsInHost_ApplicationId",
|
||||
table: "V1_ApplicationsInHost",
|
||||
column: "ApplicationId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_V1_ApplicationsInHost_HostId",
|
||||
table: "V1_ApplicationsInHost",
|
||||
column: "HostId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_V1_ApplicationsInHost_V1_ApplicationId",
|
||||
table: "V1_ApplicationsInHost",
|
||||
column: "V1_ApplicationId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_V1_ApplicationTypes_V1_ApplicationTypeId",
|
||||
table: "V1_ApplicationTypes",
|
||||
column: "V1_ApplicationTypeId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_V1_JobJournals_HostId",
|
||||
table: "V1_JobJournals",
|
||||
column: "HostId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_V1_JobJournals_JobId",
|
||||
table: "V1_JobJournals",
|
||||
column: "JobId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_V1_JobJournals_JobStatusId",
|
||||
table: "V1_JobJournals",
|
||||
column: "JobStatusId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_V1_Jobs_ApplicationId",
|
||||
table: "V1_Jobs",
|
||||
column: "ApplicationId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_V1_Jobs_JobCategoryId",
|
||||
table: "V1_Jobs",
|
||||
column: "JobCategoryId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_V1_Jobs_JobModeId",
|
||||
table: "V1_Jobs",
|
||||
column: "JobModeId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_V1_Jobs_JobTypeId",
|
||||
table: "V1_Jobs",
|
||||
column: "JobTypeId");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2037,353 +2037,6 @@ namespace PARR.DAL.Migrations
|
||||
b.ToTable("Tnks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_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("V1_Applications");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_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.Property<Guid?>("V1_ApplicationId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ApplicationId");
|
||||
|
||||
b.HasIndex("HostId");
|
||||
|
||||
b.HasIndex("V1_ApplicationId");
|
||||
|
||||
b.ToTable("V1_ApplicationsInHost");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_ApplicationType", 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>("Description")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid?>("V1_ApplicationTypeId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("V1_ApplicationTypeId");
|
||||
|
||||
b.ToTable("V1_ApplicationTypes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_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>("LinkEK")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("RegionalEK")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Responsible")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Status")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("WorkGroup")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("V1_Hosts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_Job", 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<int>("Frequency")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<Guid?>("JobCategoryId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("JobModeId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid?>("JobTypeId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("ScriptName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTimeOffset>("StartAt")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ApplicationId");
|
||||
|
||||
b.HasIndex("JobCategoryId");
|
||||
|
||||
b.HasIndex("JobModeId");
|
||||
|
||||
b.HasIndex("JobTypeId");
|
||||
|
||||
b.ToTable("V1_Jobs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_JobCategory", 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>("Description")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("V1_JobCategorys");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_JobJournal", 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<DateTimeOffset>("DateOper")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<Guid>("HostId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Info")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<Guid>("JobId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("JobStatusId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("Other")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int?>("TimeOut")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("HostId");
|
||||
|
||||
b.HasIndex("JobId");
|
||||
|
||||
b.HasIndex("JobStatusId");
|
||||
|
||||
b.ToTable("V1_JobJournals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_JobMode", 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>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("V1_JobModes");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = new Guid("fba4202c-5bad-49c4-b076-d1ca6e1fb158"),
|
||||
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
|
||||
Name = "auto"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = new Guid("7516b952-510d-4aaa-971c-a14b184fc1d5"),
|
||||
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
|
||||
Name = "manual"
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_JobStatus", 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>("Description")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("V1_JobStatuses");
|
||||
|
||||
b.HasData(
|
||||
new
|
||||
{
|
||||
Id = new Guid("edef6dc3-adad-4c77-8ad1-63bb9052355a"),
|
||||
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
|
||||
Description = "Задание запущено",
|
||||
Name = "started"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = new Guid("7b945eb6-d885-4570-aff5-8866f1f75ff2"),
|
||||
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
|
||||
Description = "Задание выполнено",
|
||||
Name = "finished"
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_JobType", 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>("Description")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("V1_JobTypes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Work", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -2641,105 +2294,6 @@ namespace PARR.DAL.Migrations
|
||||
b.Navigation("Subprocess");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_Application", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.V1.V1_ApplicationType", "ApplicationType")
|
||||
.WithMany()
|
||||
.HasForeignKey("ApplicationTypeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ApplicationType");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_ApplicationInHost", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.Application", "Application")
|
||||
.WithMany()
|
||||
.HasForeignKey("ApplicationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.V1.V1_Host", "Host")
|
||||
.WithMany("ApplicationsInHosts")
|
||||
.HasForeignKey("HostId")
|
||||
.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");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_ApplicationType", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.V1.V1_ApplicationType", null)
|
||||
.WithMany("V1_ApplicationTypes")
|
||||
.HasForeignKey("V1_ApplicationTypeId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_Job", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.Application", "Application")
|
||||
.WithMany()
|
||||
.HasForeignKey("ApplicationId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.V1.V1_JobCategory", "JobCategorye")
|
||||
.WithMany("Jobs")
|
||||
.HasForeignKey("JobCategoryId");
|
||||
|
||||
b.HasOne("PARR.DAL.Models.V1.V1_JobMode", "JobMode")
|
||||
.WithMany("Jobs")
|
||||
.HasForeignKey("JobModeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.V1.V1_JobType", "JobType")
|
||||
.WithMany("Jobs")
|
||||
.HasForeignKey("JobTypeId");
|
||||
|
||||
b.Navigation("Application");
|
||||
|
||||
b.Navigation("JobCategorye");
|
||||
|
||||
b.Navigation("JobMode");
|
||||
|
||||
b.Navigation("JobType");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_JobJournal", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.V1.V1_Host", "Host")
|
||||
.WithMany("JobJournals")
|
||||
.HasForeignKey("HostId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.V1.V1_Job", "Job")
|
||||
.WithMany("Journals")
|
||||
.HasForeignKey("JobId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.V1.V1_JobStatus", "Status")
|
||||
.WithMany("Journals")
|
||||
.HasForeignKey("JobStatusId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Host");
|
||||
|
||||
b.Navigation("Job");
|
||||
|
||||
b.Navigation("Status");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Work", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.Tnk", "Tnk")
|
||||
@@ -2856,48 +2410,6 @@ namespace PARR.DAL.Migrations
|
||||
b.Navigation("Works");
|
||||
});
|
||||
|
||||
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");
|
||||
|
||||
b.Navigation("JobJournals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_Job", b =>
|
||||
{
|
||||
b.Navigation("Journals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_JobCategory", b =>
|
||||
{
|
||||
b.Navigation("Jobs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_JobMode", b =>
|
||||
{
|
||||
b.Navigation("Jobs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_JobStatus", b =>
|
||||
{
|
||||
b.Navigation("Journals");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_JobType", b =>
|
||||
{
|
||||
b.Navigation("Jobs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Work", b =>
|
||||
{
|
||||
b.Navigation("ApplicationsInWorks");
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
using PARR.DAL.Models.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models.V1
|
||||
{
|
||||
[Table("V1_Applications")]
|
||||
public class V1_Application : IBase
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
public required string Name { get; set; }
|
||||
|
||||
public Guid ApplicationTypeId { get; set; }
|
||||
[ForeignKey(nameof(ApplicationTypeId))]
|
||||
public V1_ApplicationType? ApplicationType { get; set; }
|
||||
|
||||
|
||||
public ICollection<V1_ApplicationInHost> V1_ApplicationsInHosts { get; set; } = new HashSet<V1_ApplicationInHost>();
|
||||
//public ICollection<Application> Applications { get;set; } = new HashSet<Application>();
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using PARR.DAL.Models.Base;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models.V1
|
||||
{
|
||||
[Table("V1_ApplicationsInHost")]
|
||||
public class V1_ApplicationInHost : IBase
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
|
||||
public Guid ApplicationId { get; set; }
|
||||
|
||||
[ForeignKey(nameof(ApplicationId))]
|
||||
public Application? Application { get; set; }
|
||||
|
||||
public Guid HostId { get; set; }
|
||||
|
||||
[ForeignKey(nameof(HostId))]
|
||||
public V1_Host? Host { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
using PARR.DAL.Models.Base;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models.V1
|
||||
{
|
||||
[Table("V1_ApplicationTypes")]
|
||||
public class V1_ApplicationType : IBase
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
|
||||
|
||||
public ICollection<V1_ApplicationType> V1_ApplicationTypes { get; set; } = new HashSet<V1_ApplicationType>();
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
using PARR.DAL.Models.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models.V1
|
||||
{
|
||||
[Table("V1_Hosts")]
|
||||
public class V1_Host : IBase
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
public string? HostName { get; set; }
|
||||
public required string IP { get; set; }
|
||||
public string? RegionalEK { get; set; }
|
||||
public string? LinkEK { get; set; }
|
||||
public string? Status { get; set; }
|
||||
public string? WorkGroup { get; set; }
|
||||
public string? Responsible { get; set; }
|
||||
|
||||
|
||||
|
||||
public ICollection<V1_JobJournal> JobJournals { get; set; } = new HashSet<V1_JobJournal>();
|
||||
public ICollection<V1_ApplicationInHost> ApplicationsInHosts { get; set; } = new HashSet<V1_ApplicationInHost>();
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
using PARR.DAL.Models.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models.V1
|
||||
{
|
||||
[Table("V1_Jobs")]
|
||||
public class V1_Job : IBase
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
public required string Name { get; set; }
|
||||
public required string ScriptName { get; set; }
|
||||
|
||||
|
||||
public Guid JobModeId { get; set; }
|
||||
[ForeignKey(nameof(JobModeId))]
|
||||
public V1_JobMode? JobMode { get; set; }
|
||||
|
||||
public Guid? JobCategoryId { get; set; }
|
||||
[ForeignKey(nameof(JobCategoryId))]
|
||||
public V1_JobCategory? JobCategorye { get; set; }
|
||||
|
||||
public Guid? JobTypeId { get; set; }
|
||||
[ForeignKey(nameof(JobTypeId))]
|
||||
public V1_JobType? JobType { get; set; }
|
||||
|
||||
public Guid ApplicationId { get; set; }
|
||||
[ForeignKey(nameof(ApplicationId))]
|
||||
public Application? Application { get; set; }
|
||||
/// <summary>
|
||||
/// Частота запуска Job в минутах
|
||||
/// </summary>
|
||||
public int Frequency { get; set; }
|
||||
/// <summary>
|
||||
/// В режиме manual значит время регистрации регламентной работы АСУ ЕСПП, в auto - время старта Job.
|
||||
/// </summary>
|
||||
public DateTimeOffset StartAt { get; set; }
|
||||
/// <summary>
|
||||
/// Активация Job
|
||||
/// </summary>
|
||||
public bool IsEnabled { get; set; }
|
||||
|
||||
|
||||
public ICollection<V1_JobJournal> Journals { get; set; } = new HashSet<V1_JobJournal>();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using PARR.DAL.Models.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models.V1
|
||||
{
|
||||
[Table("V1_JobCategorys")]
|
||||
public class V1_JobCategory : IBase
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
/// <summary>
|
||||
/// app, db
|
||||
/// </summary>
|
||||
public required string Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
|
||||
|
||||
|
||||
public ICollection<V1_Job> Jobs { get; set; } = new HashSet<V1_Job>();
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
using PARR.DAL.Models.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models.V1
|
||||
{
|
||||
[Table("V1_JobJournals")]
|
||||
public class V1_JobJournal : IBase
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
public DateTimeOffset DateOper { get; set; }
|
||||
public string? Other { get; set; }
|
||||
//Возможно нужно перенести в Job
|
||||
public int? TimeOut { get; set; }
|
||||
//Возможно нужно перенести в Job
|
||||
public string? Info { get; set; }
|
||||
|
||||
|
||||
|
||||
public Guid JobStatusId { get; set; }
|
||||
|
||||
[ForeignKey(nameof(JobStatusId))]
|
||||
public V1_JobStatus? Status { get; set; }
|
||||
|
||||
|
||||
public Guid HostId { get; set; }
|
||||
|
||||
[ForeignKey(nameof(HostId))]
|
||||
public V1_Host? Host { get; set; }
|
||||
|
||||
|
||||
public Guid JobId { get; set; }
|
||||
[ForeignKey(nameof(JobId))]
|
||||
public V1_Job? Job { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using PARR.DAL.Models.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models.V1
|
||||
{
|
||||
[Table("V1_JobModes")]
|
||||
public class V1_JobMode : IBase
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
/// <summary>
|
||||
/// manual, auto
|
||||
/// </summary>
|
||||
public required string Name { get; set; }
|
||||
|
||||
|
||||
|
||||
public ICollection<V1_Job> Jobs { get; set; } = new HashSet<V1_Job>();
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
using PARR.DAL.Models.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models.V1
|
||||
{
|
||||
[Table("V1_JobStatuses")]
|
||||
public class V1_JobStatus : IBase
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
/// <summary>
|
||||
/// started, finished, timeout, error
|
||||
/// </summary>
|
||||
public required string Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
|
||||
|
||||
|
||||
public ICollection<V1_JobJournal> Journals { get; set; } = new HashSet<V1_JobJournal>();
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using PARR.DAL.Models.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models.V1
|
||||
{
|
||||
[Table("V1_JobTypes")]
|
||||
public class V1_JobType : IBase
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; }
|
||||
public DateTimeOffset DateCreated { get; set; }
|
||||
public DateTimeOffset? DateModified { get; set; }
|
||||
/// <summary>
|
||||
/// log-rotate, vacuum-psqld
|
||||
/// </summary>
|
||||
public required string Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
|
||||
|
||||
public ICollection<V1_Job> Jobs { get; set; } = new HashSet<V1_Job>();
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using PARR.DAL.Models.Base;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models.V1
|
||||
{
|
||||
//[Table("Schedulers")]
|
||||
//public class Scheduler : IBase
|
||||
//{
|
||||
// //[Key]
|
||||
// //public Guid Id { get; set; }
|
||||
// //public DateTimeOffset DateCreated { get; set; }
|
||||
// //public DateTimeOffset? DateModified { get; set; }
|
||||
// //public string? Name { get; set; }
|
||||
// //public int Frequency { get; set; }
|
||||
// //public required DateTimeOffset StartAt { get; set; }
|
||||
// //public bool IsEnabled { get; set; }
|
||||
//}
|
||||
}
|
||||
@@ -7,10 +7,8 @@ using PARR.DAL.Contracts;
|
||||
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;
|
||||
using PARR.DAL.TransformServices;
|
||||
|
||||
namespace PARR.DAL
|
||||
@@ -31,7 +29,7 @@ namespace PARR.DAL
|
||||
.UseNpgsql(configuration.GetConnectionString("DefaultConnection"))
|
||||
);
|
||||
|
||||
services.AddTransient<V1_IHostService, V1_HostService>();
|
||||
// Entity services
|
||||
services.AddTransient<IHostService, HostService>();
|
||||
services.AddTransient<IApplicationService, ApplicationService>();
|
||||
services.AddTransient<IApplicationTypeService, ApplicationTypeService>();
|
||||
@@ -42,11 +40,6 @@ namespace PARR.DAL
|
||||
services.AddTransient<IProcessService, ProcessService>();
|
||||
services.AddTransient<ISubprocessService, SubprocessService>();
|
||||
services.AddTransient<ITnkService, TnkService>();
|
||||
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<ITemplateService, TemplateService>();
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace PARR.DAL.Services.Implementations
|
||||
// return null;
|
||||
//}
|
||||
return await EntitySet
|
||||
.Include(t => t.ApplicationsInHosts).ThenInclude(a => a.Application).ThenInclude(t => t.ApplicationType)
|
||||
.Include(t => t.ApplicationsInHosts).ThenInclude(a => a.Application).ThenInclude(t => t!.ApplicationType)
|
||||
.AsSplitQuery()
|
||||
.FirstOrDefaultAsync(h => h.IP == IP);
|
||||
}
|
||||
|
||||
@@ -1,25 +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.V1;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations.V1
|
||||
{
|
||||
internal class V1_ApplicationInHostService : BaseService<V1_ApplicationInHost>, V1_IApplicationInHostService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<V1_ApplicationInHostService> logger;
|
||||
|
||||
public V1_ApplicationInHostService(DataContext dataContext, ILogger<V1_ApplicationInHostService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
protected override DbSet<V1_ApplicationInHost> EntitySet => dataContext.V1_ApplicationsInHosts;
|
||||
|
||||
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.V1;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations.V1
|
||||
{
|
||||
internal class V1_ApplicationService : BaseService<V1_Application>, V1_IApplicationService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<V1_ApplicationService> logger;
|
||||
|
||||
public V1_ApplicationService(DataContext dataContext, ILogger<V1_ApplicationService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
protected override DbSet<V1_Application> EntitySet => dataContext.V1_Applications;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
|
||||
public async Task<V1_Application?> GetByNameAsync(string appName)
|
||||
{
|
||||
return await EntitySet.FirstOrDefaultAsync(t => t.Name.ToLower() == appName.Trim().ToLower());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +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.V1;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations.V1
|
||||
{
|
||||
internal class V1_ApplicationTypeService : BaseService<V1_ApplicationType>, V1_IApplicationTypeService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<V1_ApplicationTypeService> logger;
|
||||
|
||||
public V1_ApplicationTypeService(DataContext dataContext, ILogger<V1_ApplicationTypeService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
protected override DbSet<V1_ApplicationType> EntitySet => dataContext.V1_ApplicationTypes;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
}
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.DomainModels;
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Abstracts;
|
||||
using PARR.DAL.Services.Interfaces.V1;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations.V1
|
||||
{
|
||||
internal class V1_HostService : BaseService<V1_Host>, V1_IHostService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<V1_HostService> logger;
|
||||
|
||||
protected override DbSet<V1_Host> EntitySet => dataContext.V1_Hosts;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
public V1_HostService(DataContext dataContext, ILogger<V1_HostService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
public async Task<V1_Host?> GetHostWithAppsAsync(string IP, string RegionalEK)
|
||||
{
|
||||
|
||||
//try
|
||||
//{
|
||||
// var host = await EntitySet.FirstAsync(h => h.IP == IP && h.RegionalEK == RegionalEK);
|
||||
// return host;
|
||||
//}
|
||||
//catch
|
||||
//{
|
||||
// logger.LogInformation($"Не найден узел с IP адресом {IP} и региональным ЭК {RegionalEK}");
|
||||
// return null;
|
||||
//}
|
||||
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);
|
||||
}
|
||||
|
||||
public Task<V1_Host?> GetAsync(Guid id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IQueryable<V1_Host> Get()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public IQueryable<V1_Host> GetPage(IQueryable<V1_Host> query, PaginationFilter paginationFilter)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<bool> CreateAsync(V1_Host obj)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<bool> AddRangeAsync(List<V1_Host> objs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<bool> DeleteAsync(Guid id)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool Delete(V1_Host obj)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<bool> CommitAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
//public async Task<Host?> GetHostByRegionalEKAsync(string RegionalEK)И
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// var host = await EntitySet.FirstAsync(h => h.RegionalEK == RegionalEK);
|
||||
// return host;
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// logger.LogInformation($"Не найден узел с региональным ЭК {RegionalEK}");
|
||||
// return null;
|
||||
// }
|
||||
//}
|
||||
|
||||
//public async Task<bool> UpdateAsync(Host host)
|
||||
//{
|
||||
// var orig = await EntitySet.FirstAsync(h => h.IP == host.IP);
|
||||
// if (orig == null)
|
||||
// return false;
|
||||
|
||||
// orig.DateModified = DateTimeOffset.UtcNow;
|
||||
// orig.HostName = host.HostName;
|
||||
// orig.RegionalEK = host.RegionalEK;
|
||||
// orig.LinkEK = host.LinkEK;
|
||||
// orig.Status = host.Status;
|
||||
// orig.WorkGroup = host.WorkGroup;
|
||||
// orig.Responsible = host.Responsible;
|
||||
// orig.OS = host.OS;
|
||||
// orig.DB = host.DB;
|
||||
// orig.APP = host.APP;
|
||||
|
||||
// if (!await CommitAsync())
|
||||
// {
|
||||
// logger.LogError($"Ошибка обновления узла {host.IP}");
|
||||
// return false;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// logger.LogInformation($"Обновлен узел {host.IP}");
|
||||
// return true;
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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.V1;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations.V1
|
||||
{
|
||||
internal class V1_JobCategoryService : BaseService<V1_JobCategory>, V1_IJobCategoryService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<V1_JobCategoryService> logger;
|
||||
|
||||
public V1_JobCategoryService(DataContext dataContext, ILogger<V1_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.V1;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations.V1
|
||||
{
|
||||
internal class V1_JobJournalService : BaseService<V1_JobJournal>, V1_IJobJournalService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<V1_JobJournalService> logger;
|
||||
|
||||
public V1_JobJournalService(DataContext dataContext, ILogger<V1_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.V1;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations.V1
|
||||
{
|
||||
internal class V1_JobModeService : BaseService<V1_JobMode>, V1_IJobModeService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<V1_JobModeService> logger;
|
||||
|
||||
public V1_JobModeService(DataContext dataContext, ILogger<V1_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.V1;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations.V1
|
||||
{
|
||||
internal class V1_JobService : BaseService<V1_Job>, V1_IJobService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<V1_JobService> logger;
|
||||
|
||||
public V1_JobService(DataContext dataContext, ILogger<V1_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.V1;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations.V1
|
||||
{
|
||||
internal class V1_JobStatusService : BaseService<V1_JobStatus>, V1_IJobStatusService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
private readonly ILogger<V1_JobStatusService> logger;
|
||||
|
||||
public V1_JobStatusService(DataContext dataContext, ILogger<V1_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.V1
|
||||
{
|
||||
//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,5 +1,4 @@
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces.V1
|
||||
{
|
||||
public interface V1_IApplicationInHostService : IBaseService<V1_ApplicationInHost>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces.V1
|
||||
{
|
||||
public interface V1_IApplicationService : IBaseService<V1_Application>
|
||||
{
|
||||
Task<V1_Application?> GetByNameAsync(string appName);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces.V1
|
||||
{
|
||||
public interface V1_IApplicationTypeService : IBaseService<V1_ApplicationType>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces.V1
|
||||
{
|
||||
public interface V1_IHostService : IBaseService<V1_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);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces.V1
|
||||
{
|
||||
internal interface V1_IJobCategoryService : IBaseService<V1_JobCategory>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using PARR.DAL.Models.V1;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces.V1
|
||||
{
|
||||
public interface V1_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.V1
|
||||
{
|
||||
internal interface V1_IJobModeService : IBaseService<V1_JobMode>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces.V1
|
||||
{
|
||||
public interface V1_IJobService : IBaseService<V1_Job>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using PARR.DAL.Models.V1;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces.V1
|
||||
{
|
||||
internal interface V1_IJobStatusService : IBaseService<V1_JobStatus>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using PARR.DAL.Models;
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces.V1
|
||||
{
|
||||
//public interface V1_ISchedulerService : IBaseService<V1_Scheduler>
|
||||
//{
|
||||
//}
|
||||
}
|
||||
Reference in New Issue
Block a user