Добавлен справочник ResponseArea
This commit is contained in:
@@ -11,9 +11,5 @@ namespace PARR.AIHIT.Context
|
|||||||
|
|
||||||
public DbSet<EK> EKs { get; set; }
|
public DbSet<EK> EKs { get; set; }
|
||||||
|
|
||||||
//protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
||||||
//{
|
|
||||||
// optionsBuilder.UseSqlServer(@"Data Source=10.248.19.97; Initial Catalog=mao2;User ID=awhit-ipp-parr;pwd=ET3h$9y1LH#D;TrustServerCertificate=true;");
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using AutoMapper;
|
using AutoMapper;
|
||||||
|
using PARR.AIHIT.MappingProfiles.Resolvers;
|
||||||
using PARR.AIHIT.Models;
|
using PARR.AIHIT.Models;
|
||||||
using PARR.DAL.Models;
|
using PARR.DAL.Models;
|
||||||
using PARR.DAL.Models.AIHIT;
|
using PARR.DAL.Models.AIHIT;
|
||||||
@@ -23,9 +24,12 @@ namespace PARR.AIHIT.MappingProfiles
|
|||||||
CreateMap<RawDataEK, Host>()
|
CreateMap<RawDataEK, Host>()
|
||||||
.ForMember(d => d.Ek, o => o.MapFrom(s => s.EKFindCode))//TODO Определить имя хоста по
|
.ForMember(d => d.Ek, o => o.MapFrom(s => s.EKFindCode))//TODO Определить имя хоста по
|
||||||
.ForMember(d => d.IP, o => o.MapFrom(s => s.IP))
|
.ForMember(d => d.IP, o => o.MapFrom(s => s.IP))
|
||||||
.ForMember(d => d.Status, o => o.MapFrom(s => s.Status))
|
.ForMember(d => d.EkStatusCode, o => o.MapFrom<EkStatusCodeResolver>())
|
||||||
|
//.ForMember(d => d.StatusStr, o => o.MapFrom(s => s.Status))
|
||||||
.ForMember(d => d.WorkGroup, o => o.MapFrom(s => s.WorkGroup))
|
.ForMember(d => d.WorkGroup, o => o.MapFrom(s => s.WorkGroup))
|
||||||
.ForMember(d => d.ResponseArea, o => o.MapFrom(s => s.ResponseArea));
|
.ForMember(d => d.ResponseAreaCode, o => o.MapFrom<ResponseAreaCodeResolver>())
|
||||||
|
.ForMember(d => d.ResponseArea, o => o.Ignore());
|
||||||
|
//.ForMember(d => d.ResponseAreaStr, o => o.MapFrom(s => s.ResponseArea));
|
||||||
//CreateMap<PARR.DAL.Models.Host, PARR.DAL.Models.Host>()
|
//CreateMap<PARR.DAL.Models.Host, PARR.DAL.Models.Host>()
|
||||||
// .ForMember(d => d.HostName, o => o.MapFrom(s => s.HostName))
|
// .ForMember(d => d.HostName, o => o.MapFrom(s => s.HostName))
|
||||||
// .ForMember(d => d.IP, o => o.MapFrom(s => s.IP))
|
// .ForMember(d => d.IP, o => o.MapFrom(s => s.IP))
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using PARR.DAL.Contracts;
|
||||||
|
using PARR.DAL.Models;
|
||||||
|
using PARR.DAL.Models.AIHIT;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace PARR.AIHIT.MappingProfiles.Resolvers
|
||||||
|
{
|
||||||
|
internal class EkStatusCodeResolver : IValueResolver<RawDataEK, Host, int>
|
||||||
|
{
|
||||||
|
public int Resolve(RawDataEK source, Host destination, int destMember, ResolutionContext context)
|
||||||
|
{
|
||||||
|
var pattern = "\\d+";
|
||||||
|
var regex = new Regex(pattern);
|
||||||
|
|
||||||
|
int.TryParse(regex.Match(source.Status!).Value, out int result);
|
||||||
|
|
||||||
|
if (!Enum.IsDefined(typeof(EkStatusEnum), result))
|
||||||
|
throw new Exception($"Неверный статус ЭК {source.Status}");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using AutoMapper;
|
||||||
|
using PARR.DAL.Contracts;
|
||||||
|
using PARR.DAL.Models;
|
||||||
|
using PARR.DAL.Models.AIHIT;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace PARR.AIHIT.MappingProfiles.Resolvers
|
||||||
|
{
|
||||||
|
internal class ResponseAreaCodeResolver : IValueResolver<RawDataEK, Host, int>
|
||||||
|
{
|
||||||
|
public int Resolve(RawDataEK source, Host destination, int destMember, ResolutionContext context)
|
||||||
|
{
|
||||||
|
var pattern = "\\d+";
|
||||||
|
var regex = new Regex(pattern);
|
||||||
|
|
||||||
|
int.TryParse(regex.Match(source.ResponseArea!).Value, out int result);
|
||||||
|
|
||||||
|
if (result == 0)
|
||||||
|
return (int)ResponseAreaEnum.gvc;
|
||||||
|
|
||||||
|
if (!Enum.IsDefined(typeof(ResponseAreaEnum), result))
|
||||||
|
throw new Exception($"Неверный код дороги {source.ResponseArea}");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -217,37 +217,45 @@ namespace PARR.AIHIT
|
|||||||
var respAreas = await settingService.Get()
|
var respAreas = await settingService.Get()
|
||||||
.Where(ra => ra.Group == AIHTITSettings.RespAreaGroupName)
|
.Where(ra => ra.Group == AIHTITSettings.RespAreaGroupName)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
#if !DEBUG
|
||||||
//Запускаем хранимую процедуру в АИХ ИТ и складываем в таблицу RawDataEKs, предварительно почистив старые данные
|
//Запускаем хранимую процедуру в АИХ ИТ и складываем в таблицу RawDataEKs, предварительно почистив старые данные
|
||||||
//foreach (var respArea in respAreas)
|
foreach (var respArea in respAreas)
|
||||||
//{
|
{
|
||||||
// var eksFromAIHIT = aihitService.GetEKList(respArea.Value)?.ToList();
|
var eksFromAIHIT = aihitService.GetEKList(respArea.Value)?.ToList();
|
||||||
|
|
||||||
// if (eksFromAIHIT == null)
|
if (eksFromAIHIT == null)
|
||||||
// continue;
|
continue;
|
||||||
|
|
||||||
// //Удаляем текущие данные по зоне ответственности respArea
|
//Удаляем текущие данные по зоне ответственности respArea
|
||||||
// var toDelete = rawDataEKService.Get().Where(rd => rd.ResponseArea == respArea.Value).ToList();
|
var toDelete = rawDataEKService.Get().Where(rd => rd.ResponseArea == respArea.Value).ToList();
|
||||||
// toDelete.ForEach(d => rawDataEKService.Delete(d));
|
toDelete.ForEach(d => rawDataEKService.Delete(d));
|
||||||
|
if(!await rawDataEKService.CommitAsync())
|
||||||
|
{
|
||||||
|
logger.LogError($"Не удалось создать удалить записи в rawDataEK зоны ответственности {respArea.Name}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// foreach (var ek in eksFromAIHIT)
|
foreach (var ek in eksFromAIHIT)
|
||||||
// {
|
{
|
||||||
// // создаем
|
// создаем
|
||||||
// var mappedEK = mapper.Map<RawDataEK>(ek);
|
var mappedEK = mapper.Map<RawDataEK>(ek);
|
||||||
|
|
||||||
// mappedEK.Id = Guid.NewGuid();
|
mappedEK.Id = Guid.NewGuid();
|
||||||
// mappedEK.DateCreated = DateTimeOffset.UtcNow;
|
mappedEK.DateCreated = DateTimeOffset.UtcNow;
|
||||||
|
|
||||||
// if (!await rawDataEKService.CreateAsync(mappedEK) || !await rawDataEKService.CommitAsync())
|
|
||||||
// {
|
|
||||||
// logger.LogError($"Не удалось создать запись rawDataEK {mappedEK.ShortName}({mappedEK.IP})");
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// logger.LogInformation($"----- Создана запись rawDataEK {mappedEK.ShortName}({mappedEK.IP}) -----");
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
//if (!await rawDataEKService.CreateAsync(mappedEK) || !await rawDataEKService.CommitAsync())
|
||||||
|
if (!await rawDataEKService.CreateAsync(mappedEK))
|
||||||
|
{
|
||||||
|
logger.LogError($"Не удалось создать запись rawDataEK {mappedEK.ShortName}({mappedEK.IP})");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
logger.LogInformation($"----- Создана запись rawDataEK {mappedEK.ShortName}({mappedEK.IP}), зона ответственности {respArea.Name} -----");
|
||||||
|
}
|
||||||
|
if (await rawDataEKService.CommitAsync())
|
||||||
|
logger.LogError($"Информация о хостах зоны ответственности {respArea.Name} не записана ");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
//Разбираем сырые данные
|
//Разбираем сырые данные
|
||||||
|
|
||||||
//Получаем интересующие статусы ЭК
|
//Получаем интересующие статусы ЭК
|
||||||
@@ -293,9 +301,9 @@ namespace PARR.AIHIT
|
|||||||
{
|
{
|
||||||
// обновляем
|
// обновляем
|
||||||
var isChanged = false;
|
var isChanged = false;
|
||||||
if (!foundHost.Status!.Equals(mappedHost.Status))
|
if (!foundHost.EkStatusCode!.Equals(mappedHost.EkStatusCode))
|
||||||
{
|
{
|
||||||
foundHost.Status = mappedHost.Status;
|
foundHost.EkStatusCode = mappedHost.EkStatusCode;
|
||||||
isChanged = true;
|
isChanged = true;
|
||||||
}
|
}
|
||||||
else if (mappedHost.WorkGroup != null && !foundHost.WorkGroup!.Equals(mappedHost.WorkGroup))
|
else if (mappedHost.WorkGroup != null && !foundHost.WorkGroup!.Equals(mappedHost.WorkGroup))
|
||||||
|
|||||||
@@ -35,7 +35,10 @@ namespace PARR.API.Controllers.V1
|
|||||||
{
|
{
|
||||||
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
var paginationFilter = mapper.Map<PaginationFilter>(paginationQuery);
|
||||||
|
|
||||||
IQueryable<DAL.Models.Host> query = hostService.Get().Include(s => s.EkStatus).OrderBy(t => t.Ek);
|
IQueryable<DAL.Models.Host> query = hostService.Get()
|
||||||
|
.Include(s => s.EkStatus)
|
||||||
|
.Include(s => s.ResponseArea)
|
||||||
|
.OrderBy(t => t.Ek);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(request.Mask))
|
if (!string.IsNullOrEmpty(request.Mask))
|
||||||
query = query.Where(t => EF.Functions.Like(t.Ek.ToLower(), SqlHelpers.RegexToLike(request.Mask)));
|
query = query.Where(t => EF.Functions.Like(t.Ek.ToLower(), SqlHelpers.RegexToLike(request.Mask)));
|
||||||
|
|||||||
@@ -75,7 +75,8 @@ namespace PARR.API.MappingProfiles
|
|||||||
CreateMap<Application, ApplicationResponse>();
|
CreateMap<Application, ApplicationResponse>();
|
||||||
|
|
||||||
CreateMap<DAL.Models.Host, HostResponse>()
|
CreateMap<DAL.Models.Host, HostResponse>()
|
||||||
.ForMember(d => d.Status, o => o.MapFrom(s => s.EkStatus!.Name));
|
.ForMember(d => d.Status, o => o.MapFrom(s => s.EkStatus!.Name))
|
||||||
|
.ForMember(d => d.ResponseArea, o => o.MapFrom(s => s.ResponseArea!.Name));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ namespace PARR.DAL.Context
|
|||||||
|
|
||||||
public DbSet<Host> Hosts { get; set; }
|
public DbSet<Host> Hosts { get; set; }
|
||||||
public DbSet<EkStatus> EkStatuses { get; set; }
|
public DbSet<EkStatus> EkStatuses { get; set; }
|
||||||
|
public DbSet<ResponseArea> ResponseAreas { get; set; }
|
||||||
public DbSet<Application> Applications { get; set; }
|
public DbSet<Application> Applications { get; set; }
|
||||||
public DbSet<ApplicationType> ApplicationTypes { get; set; }
|
public DbSet<ApplicationType> ApplicationTypes { get; set; }
|
||||||
public DbSet<ApplicationInHost> ApplicationsInHosts { get; set; }
|
public DbSet<ApplicationInHost> ApplicationsInHosts { get; set; }
|
||||||
@@ -137,6 +138,28 @@ namespace PARR.DAL.Context
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity<ResponseArea>(f =>
|
||||||
|
{
|
||||||
|
f.HasData(
|
||||||
|
new { Code = (int)ResponseAreaEnum.dvgd, Name = "96-ДВС" },
|
||||||
|
new { Code = (int)ResponseAreaEnum.zrw, Name = "92-ВСИБ" },
|
||||||
|
new { Code = (int)ResponseAreaEnum.krw, Name = "88-КРАСН" },
|
||||||
|
new { Code = (int)ResponseAreaEnum.wsr, Name = "83-ЗСИБ" },
|
||||||
|
new { Code = (int)ResponseAreaEnum.surw, Name = "80-ЮУР" },
|
||||||
|
new { Code = (int)ResponseAreaEnum.svrw, Name = "76-СВРД" },
|
||||||
|
new { Code = (int)ResponseAreaEnum.kbsh, Name = "63-КБШ" },
|
||||||
|
new { Code = (int)ResponseAreaEnum.pvrr, Name = "61-ПРИВ" },
|
||||||
|
new { Code = (int)ResponseAreaEnum.serw, Name = "58-ЮВСТ" },
|
||||||
|
new { Code = (int)ResponseAreaEnum.skzd, Name = "51-СКВ" },
|
||||||
|
new { Code = (int)ResponseAreaEnum.nrr, Name = "28-СЕВ" },
|
||||||
|
new { Code = (int)ResponseAreaEnum.grw, Name = "24-ГОР" },
|
||||||
|
new { Code = (int)ResponseAreaEnum.msk, Name = "17-МСК" },
|
||||||
|
new { Code = (int)ResponseAreaEnum.klgd, Name = "10-КЛГ" },
|
||||||
|
new { Code = (int)ResponseAreaEnum.orw, Name = "01-ОКТ" },
|
||||||
|
new { Code = (int)ResponseAreaEnum.gvc, Name = "00-ГВЦ" }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
94
PARR.DAL/Contracts/ResponseAreaEnum.cs
Normal file
94
PARR.DAL/Contracts/ResponseAreaEnum.cs
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
namespace PARR.DAL.Contracts
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Коды дорог
|
||||||
|
/// </summary>
|
||||||
|
public enum ResponseAreaEnum
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ДВЖД
|
||||||
|
/// </summary>
|
||||||
|
dvgd = 96,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ЗАБ
|
||||||
|
/// </summary>
|
||||||
|
zrw = 94,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ВСИБ
|
||||||
|
/// </summary>
|
||||||
|
esrr = 92,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// КРАСН
|
||||||
|
/// </summary>
|
||||||
|
krw = 88,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ЗСИБ
|
||||||
|
/// </summary>
|
||||||
|
wsr = 83,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ЮУР
|
||||||
|
/// </summary>
|
||||||
|
surw = 80,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// СВРД
|
||||||
|
/// </summary>
|
||||||
|
svrw = 76,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// КБШ
|
||||||
|
/// </summary>
|
||||||
|
kbsh = 63,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ПРИВ
|
||||||
|
/// </summary>
|
||||||
|
pvrr = 61,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ЮВСТ
|
||||||
|
/// </summary>
|
||||||
|
serw = 58,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// СКВ
|
||||||
|
/// </summary>
|
||||||
|
skzd = 51,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// СЕВ
|
||||||
|
/// </summary>
|
||||||
|
nrr = 28,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ГОР
|
||||||
|
/// </summary>
|
||||||
|
grw = 24,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// МСК
|
||||||
|
/// </summary>
|
||||||
|
msk = 17,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// КЛГ
|
||||||
|
/// </summary>
|
||||||
|
klgd = 10,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ОКТ
|
||||||
|
/// </summary>
|
||||||
|
orw = 01,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ГВЦ
|
||||||
|
/// </summary>
|
||||||
|
gvc = 99,
|
||||||
|
}
|
||||||
|
}
|
||||||
1636
PARR.DAL/Migrations/20230928015451_AddResponseAreaEnum.Designer.cs
generated
Normal file
1636
PARR.DAL/Migrations/20230928015451_AddResponseAreaEnum.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
112
PARR.DAL/Migrations/20230928015451_AddResponseAreaEnum.cs
Normal file
112
PARR.DAL/Migrations/20230928015451_AddResponseAreaEnum.cs
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
||||||
|
|
||||||
|
namespace PARR.DAL.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddResponseAreaEnum : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "Status",
|
||||||
|
table: "Hosts",
|
||||||
|
newName: "StatusStr");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "ResponseArea",
|
||||||
|
table: "Hosts",
|
||||||
|
newName: "ResponseAreaStr");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "ResponseAreaCode",
|
||||||
|
table: "Hosts",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ResponseAreas",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Code = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
Name = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ResponseAreas", x => x.Code);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.InsertData(
|
||||||
|
table: "ResponseAreas",
|
||||||
|
columns: new[] { "Code", "Name" },
|
||||||
|
values: new object[,]
|
||||||
|
{
|
||||||
|
{ 1, "01-ОКТ" },
|
||||||
|
{ 10, "10-КЛГ" },
|
||||||
|
{ 17, "17-МСК" },
|
||||||
|
{ 24, "24-ГОР" },
|
||||||
|
{ 28, "28-СЕВ" },
|
||||||
|
{ 51, "51-СКВ" },
|
||||||
|
{ 58, "58-ЮВСТ" },
|
||||||
|
{ 61, "61-ПРИВ" },
|
||||||
|
{ 63, "63-КБШ" },
|
||||||
|
{ 76, "76-СВРД" },
|
||||||
|
{ 80, "80-ЮУР" },
|
||||||
|
{ 83, "83-ЗСИБ" },
|
||||||
|
{ 88, "88-КРАСН" },
|
||||||
|
{ 94, "92-ВСИБ" },
|
||||||
|
{ 96, "96-ДВС" },
|
||||||
|
{ 99, "00-ГВЦ" }
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Hosts_ResponseAreaCode",
|
||||||
|
table: "Hosts",
|
||||||
|
column: "ResponseAreaCode");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Hosts_ResponseAreas_ResponseAreaCode",
|
||||||
|
table: "Hosts",
|
||||||
|
column: "ResponseAreaCode",
|
||||||
|
principalTable: "ResponseAreas",
|
||||||
|
principalColumn: "Code",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Hosts_ResponseAreas_ResponseAreaCode",
|
||||||
|
table: "Hosts");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ResponseAreas");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Hosts_ResponseAreaCode",
|
||||||
|
table: "Hosts");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "ResponseAreaCode",
|
||||||
|
table: "Hosts");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "StatusStr",
|
||||||
|
table: "Hosts",
|
||||||
|
newName: "Status");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "ResponseAreaStr",
|
||||||
|
table: "Hosts",
|
||||||
|
newName: "ResponseArea");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1630
PARR.DAL/Migrations/20230928042307_TblHostsRemoveResponseAreaColumns.Designer.cs
generated
Normal file
1630
PARR.DAL/Migrations/20230928042307_TblHostsRemoveResponseAreaColumns.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,38 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace PARR.DAL.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class TblHostsRemoveResponseAreaColumns : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "ResponseAreaStr",
|
||||||
|
table: "Hosts");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "StatusStr",
|
||||||
|
table: "Hosts");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "ResponseAreaStr",
|
||||||
|
table: "Hosts",
|
||||||
|
type: "text",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "StatusStr",
|
||||||
|
table: "Hosts",
|
||||||
|
type: "text",
|
||||||
|
nullable: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -595,11 +595,8 @@ namespace PARR.DAL.Migrations
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<string>("ResponseArea")
|
b.Property<int>("ResponseAreaCode")
|
||||||
.HasColumnType("text");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<string>("Status")
|
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("WorkGroup")
|
b.Property<string>("WorkGroup")
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@@ -608,6 +605,8 @@ namespace PARR.DAL.Migrations
|
|||||||
|
|
||||||
b.HasIndex("EkStatusCode");
|
b.HasIndex("EkStatusCode");
|
||||||
|
|
||||||
|
b.HasIndex("ResponseAreaCode");
|
||||||
|
|
||||||
b.ToTable("Hosts");
|
b.ToTable("Hosts");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -635,6 +634,105 @@ namespace PARR.DAL.Migrations
|
|||||||
b.ToTable("Processes");
|
b.ToTable("Processes");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PARR.DAL.Models.ResponseArea", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Code")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Code"));
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Code");
|
||||||
|
|
||||||
|
b.ToTable("ResponseAreas");
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 96,
|
||||||
|
Name = "96-ДВС"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 94,
|
||||||
|
Name = "92-ВСИБ"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 88,
|
||||||
|
Name = "88-КРАСН"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 83,
|
||||||
|
Name = "83-ЗСИБ"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 80,
|
||||||
|
Name = "80-ЮУР"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 76,
|
||||||
|
Name = "76-СВРД"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 63,
|
||||||
|
Name = "63-КБШ"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 61,
|
||||||
|
Name = "61-ПРИВ"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 58,
|
||||||
|
Name = "58-ЮВСТ"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 51,
|
||||||
|
Name = "51-СКВ"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 28,
|
||||||
|
Name = "28-СЕВ"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 24,
|
||||||
|
Name = "24-ГОР"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 17,
|
||||||
|
Name = "17-МСК"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 10,
|
||||||
|
Name = "10-КЛГ"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 1,
|
||||||
|
Name = "01-ОКТ"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 99,
|
||||||
|
Name = "00-ГВЦ"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PARR.DAL.Models.Setting", b =>
|
modelBuilder.Entity("PARR.DAL.Models.Setting", b =>
|
||||||
{
|
{
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
@@ -1253,7 +1351,15 @@ namespace PARR.DAL.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("PARR.DAL.Models.ResponseArea", "ResponseArea")
|
||||||
|
.WithMany("Hosts")
|
||||||
|
.HasForeignKey("ResponseAreaCode")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
b.Navigation("EkStatus");
|
b.Navigation("EkStatus");
|
||||||
|
|
||||||
|
b.Navigation("ResponseArea");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PARR.DAL.Models.Subprocess", b =>
|
modelBuilder.Entity("PARR.DAL.Models.Subprocess", b =>
|
||||||
@@ -1449,6 +1555,11 @@ namespace PARR.DAL.Migrations
|
|||||||
b.Navigation("Subprocesses");
|
b.Navigation("Subprocesses");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PARR.DAL.Models.ResponseArea", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Hosts");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PARR.DAL.Models.StatusTemplate", b =>
|
modelBuilder.Entity("PARR.DAL.Models.StatusTemplate", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("Templates");
|
b.Navigation("Templates");
|
||||||
|
|||||||
@@ -24,11 +24,14 @@ namespace PARR.DAL.Models
|
|||||||
//public string? LinkEK { get; set; }
|
//public string? LinkEK { get; set; }
|
||||||
|
|
||||||
//TODO: удалить поле Status, вместо него использовать EkStatusCode
|
//TODO: удалить поле Status, вместо него использовать EkStatusCode
|
||||||
public string? Status { get; set; }
|
//public string? StatusStr { get; set; }
|
||||||
|
|
||||||
public string? WorkGroup { get; set; }
|
public string? WorkGroup { get; set; }
|
||||||
|
|
||||||
public string? ResponseArea { get; set; }
|
//TODO: удалить поле ResponseAreaStr
|
||||||
|
//public string? ResponseAreaStr { get; set; }
|
||||||
|
|
||||||
|
public int ResponseAreaCode { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public ICollection<ApplicationInHost> ApplicationsInHosts { get; set; } = new HashSet<ApplicationInHost>();
|
public ICollection<ApplicationInHost> ApplicationsInHosts { get; set; } = new HashSet<ApplicationInHost>();
|
||||||
@@ -38,5 +41,8 @@ namespace PARR.DAL.Models
|
|||||||
|
|
||||||
[ForeignKey(nameof(EkStatusCode))]
|
[ForeignKey(nameof(EkStatusCode))]
|
||||||
public EkStatus? EkStatus { get; set; }
|
public EkStatus? EkStatus { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(ResponseAreaCode))]
|
||||||
|
public ResponseArea? ResponseArea { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
17
PARR.DAL/Models/ResponseArea.cs
Normal file
17
PARR.DAL/Models/ResponseArea.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace PARR.DAL.Models
|
||||||
|
{
|
||||||
|
[Table("ResponseAreas")]
|
||||||
|
public class ResponseArea
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Code { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public ICollection<Host> Hosts { get; set; } = new HashSet<Host>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -31,6 +31,9 @@ namespace PARR.DAL.Services.Implementations
|
|||||||
{
|
{
|
||||||
return Get()
|
return Get()
|
||||||
.Include(h => h.Host)
|
.Include(h => h.Host)
|
||||||
|
.ThenInclude(t => t!.ResponseArea)
|
||||||
|
.Include(h => h.Host)
|
||||||
|
.ThenInclude(t => t!.EkStatus)
|
||||||
.Include(a => a.ApplicationsInWork)
|
.Include(a => a.ApplicationsInWork)
|
||||||
.ThenInclude(w => w!.Work)
|
.ThenInclude(w => w!.Work)
|
||||||
.ThenInclude(t => t!.Tnk)
|
.ThenInclude(t => t!.Tnk)
|
||||||
|
|||||||
Reference in New Issue
Block a user