feat(dal,aihitLoader,aihitSyncer): добавлены новые типы программного обеспечения. При синхронизации хосты находятся по имени ЭК вместо IP-адерса

This commit is contained in:
Mikhail Kuznetsov
2024-04-18 10:18:14 +10:00
parent f6342719b6
commit 3d89e5956c
11 changed files with 2877 additions and 85 deletions

View File

@@ -62,9 +62,13 @@ namespace PARR.DAL.Context
modelBuilder.Entity<ApplicationType>(f =>
{
f.HasData(
new() { Id = new Guid("32c28386-6f13-4f7b-8508-be165b7fabdb"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.APP.ToString(), Description = "Поле СП xml АИХ ИТ" },
new() { Id = new Guid("7848a96c-cdee-48c1-a786-de9cb889723a"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.OS.ToString(), Description = "Поле ОС xml АИХ ИТ" },
new() { Id = new Guid("aae2636f-b93a-42dc-873e-0764a90a0a40"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.DB.ToString(), Description = "Поле СУБД xml АИХ ИТ" }
new() { Id = new Guid("32c28386-6f13-4f7b-8508-be165b7fabdb"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.APP.ToString(), Description = "Сервер приложений" },
new() { Id = new Guid("7848a96c-cdee-48c1-a786-de9cb889723a"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.OS.ToString(), Description = "ОС" },
new() { Id = new Guid("aae2636f-b93a-42dc-873e-0764a90a0a40"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.DB.ToString(), Description = "СУБД" },
new() { Id = new Guid("749f4c34-b883-4f28-90dd-c161dd3c4270"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.CKBS.ToString(), Description = "ЦК БС" },
new() { Id = new Guid("0bd96f9b-d36b-4dfb-bd8a-9c356bc6912b"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.IB.ToString(), Description = "ИБ" },
new() { Id = new Guid("4466148b-510d-4423-a58f-ce878152ff01"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.SI.ToString(), Description = "Инфраструктура" },
new() { Id = new Guid("725a96db-358e-489b-a7c9-a84b06ec15df"), DateCreated = dateCreated, DateModified = null, Name = ApplicationTypesEnum.SM.ToString(), Description = "Мониторинг" }
);
});
#endregion

View File

@@ -4,6 +4,10 @@
{
APP,
OS,
DB
DB,
CKBS,
IB,
SI,
SM
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,94 @@
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 TblApplicationTypeAddValues : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.UpdateData(
table: "ApplicationTypes",
keyColumn: "Id",
keyValue: new Guid("32c28386-6f13-4f7b-8508-be165b7fabdb"),
column: "Description",
value: "Сервер приложений");
migrationBuilder.UpdateData(
table: "ApplicationTypes",
keyColumn: "Id",
keyValue: new Guid("7848a96c-cdee-48c1-a786-de9cb889723a"),
column: "Description",
value: "ОС");
migrationBuilder.UpdateData(
table: "ApplicationTypes",
keyColumn: "Id",
keyValue: new Guid("aae2636f-b93a-42dc-873e-0764a90a0a40"),
column: "Description",
value: "СУБД");
migrationBuilder.InsertData(
table: "ApplicationTypes",
columns: new[] { "Id", "DateCreated", "DateModified", "Description", "Name" },
values: new object[,]
{
{ new Guid("0bd96f9b-d36b-4dfb-bd8a-9c356bc6912b"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "ИБ", "IB" },
{ new Guid("4466148b-510d-4423-a58f-ce878152ff01"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "Инфраструктура", "SI" },
{ new Guid("725a96db-358e-489b-a7c9-a84b06ec15df"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "Мониторинг", "SM" },
{ new Guid("749f4c34-b883-4f28-90dd-c161dd3c4270"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "ЦК БС", "CKBS" }
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DeleteData(
table: "ApplicationTypes",
keyColumn: "Id",
keyValue: new Guid("0bd96f9b-d36b-4dfb-bd8a-9c356bc6912b"));
migrationBuilder.DeleteData(
table: "ApplicationTypes",
keyColumn: "Id",
keyValue: new Guid("4466148b-510d-4423-a58f-ce878152ff01"));
migrationBuilder.DeleteData(
table: "ApplicationTypes",
keyColumn: "Id",
keyValue: new Guid("725a96db-358e-489b-a7c9-a84b06ec15df"));
migrationBuilder.DeleteData(
table: "ApplicationTypes",
keyColumn: "Id",
keyValue: new Guid("749f4c34-b883-4f28-90dd-c161dd3c4270"));
migrationBuilder.UpdateData(
table: "ApplicationTypes",
keyColumn: "Id",
keyValue: new Guid("32c28386-6f13-4f7b-8508-be165b7fabdb"),
column: "Description",
value: "Поле СП xml АИХ ИТ");
migrationBuilder.UpdateData(
table: "ApplicationTypes",
keyColumn: "Id",
keyValue: new Guid("7848a96c-cdee-48c1-a786-de9cb889723a"),
column: "Description",
value: "Поле ОС xml АИХ ИТ");
migrationBuilder.UpdateData(
table: "ApplicationTypes",
keyColumn: "Id",
keyValue: new Guid("aae2636f-b93a-42dc-873e-0764a90a0a40"),
column: "Description",
value: "Поле СУБД xml АИХ ИТ");
}
}
}

View File

@@ -173,22 +173,50 @@ namespace PARR.DAL.Migrations
{
Id = new Guid("32c28386-6f13-4f7b-8508-be165b7fabdb"),
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
Description = "Поле СП xml АИХ ИТ",
Description = "Сервер приложений",
Name = "APP"
},
new
{
Id = new Guid("7848a96c-cdee-48c1-a786-de9cb889723a"),
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
Description = "Поле ОС xml АИХ ИТ",
Description = "ОС",
Name = "OS"
},
new
{
Id = new Guid("aae2636f-b93a-42dc-873e-0764a90a0a40"),
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
Description = "Поле СУБД xml АИХ ИТ",
Description = "СУБД",
Name = "DB"
},
new
{
Id = new Guid("749f4c34-b883-4f28-90dd-c161dd3c4270"),
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
Description = "ЦК БС",
Name = "CKBS"
},
new
{
Id = new Guid("0bd96f9b-d36b-4dfb-bd8a-9c356bc6912b"),
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
Description = "ИБ",
Name = "IB"
},
new
{
Id = new Guid("4466148b-510d-4423-a58f-ce878152ff01"),
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
Description = "Инфраструктура",
Name = "SI"
},
new
{
Id = new Guid("725a96db-358e-489b-a7c9-a84b06ec15df"),
DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)),
Description = "Мониторинг",
Name = "SM"
});
});

View File

@@ -21,73 +21,40 @@ namespace PARR.DAL.Services.Implementations
this.logger = logger;
}
public async Task<Host?> GetHostWithAppsAsync(string IP)
{
//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)
public async Task<Host?> GetHostWithAppsByIpAsync(string ip)
{
return await GetHostWithIncludeApps()
.AsSplitQuery()
.FirstOrDefaultAsync(h => h.IP == IP);
.FirstOrDefaultAsync(h => h.IP == ip);
}
public async Task<Host?> GetHostWithAppsByEkAsync(string ek)
{
return await GetHostWithIncludeApps()
.AsSplitQuery()
.FirstOrDefaultAsync(h => h.Ek.ToLower() == ek.ToLower());
}
private IQueryable<Host> GetHostWithIncludeApps()
{
return EntitySet.Include(t => t.ApplicationsInHosts).ThenInclude(a => a.Application).ThenInclude(t => t!.ApplicationType);
}
public async Task<Host?> GetByIpAsync(string ip)
{
return await EntitySet.FirstOrDefaultAsync(t => t.IP == ip);
}
//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;
public async Task<Host?> GetByEkAsync(string ek)
{
return await EntitySet.FirstOrDefaultAsync(t => t.Ek.ToLower() == ek.ToLower());
}
// 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;
// }
//}
}
}

View File

@@ -5,10 +5,10 @@ namespace PARR.DAL.Services.Interfaces
{
public interface IHostService : IBaseService<Host>
{
Task<Host?> GetHostWithAppsAsync(string ip);
Task<Host?> GetHostWithAppsByIpAsync(string ip);
Task<Host?> GetByIpAsync(string ip);
Task<Host?> GetHostWithAppsByEkAsync(string ek);
Task<Host?> GetByEkAsync(string ek);
}
}