Создана таблица StatusTemplates
This commit is contained in:
@@ -3,6 +3,7 @@ using PARR.DAL.Contracts;
|
|||||||
using PARR.DAL.Models;
|
using PARR.DAL.Models;
|
||||||
using PARR.DAL.Models.AIHIT;
|
using PARR.DAL.Models.AIHIT;
|
||||||
using PARR.DAL.Models.V1;
|
using PARR.DAL.Models.V1;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace PARR.DAL.Context
|
namespace PARR.DAL.Context
|
||||||
{
|
{
|
||||||
@@ -27,6 +28,7 @@ namespace PARR.DAL.Context
|
|||||||
public DbSet<Setting> Settings { get; set; }
|
public DbSet<Setting> Settings { get; set; }
|
||||||
public DbSet<RawDataEK> RawDataEKs { get; set; }
|
public DbSet<RawDataEK> RawDataEKs { get; set; }
|
||||||
public DbSet<Template> Templates { get; set; }
|
public DbSet<Template> Templates { get; set; }
|
||||||
|
public DbSet<StatusTemplate> StatusTemplates { get; set; }
|
||||||
//public DbSet<Scheduler> Schedulers { get; set; }
|
//public DbSet<Scheduler> Schedulers { get; set; }
|
||||||
|
|
||||||
//todo init application type+check migrations
|
//todo init application type+check migrations
|
||||||
@@ -72,6 +74,18 @@ namespace PARR.DAL.Context
|
|||||||
new() { Id = new Guid("77C73C0A-8E4D-4676-B6E2-6A112F20E346"), DateCreated = dateCreated, DateModified = null, Group = AIHTITSettings.StatusGroupName, Name = "Exploitation", Value = "3-В эксплуатации", Description = "Статус актуальных ЭК" }
|
new() { Id = new Guid("77C73C0A-8E4D-4676-B6E2-6A112F20E346"), DateCreated = dateCreated, DateModified = null, Group = AIHTITSettings.StatusGroupName, Name = "Exploitation", Value = "3-В эксплуатации", Description = "Статус актуальных ЭК" }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
modelBuilder.Entity<StatusTemplate>(f =>
|
||||||
|
{
|
||||||
|
f.HasData(
|
||||||
|
|
||||||
|
new() { Code = (int)StatusTemplateEnum.Creating, Name = StatusTemplateEnum.Creating.ToString(), Description = "Создали шаблон в ПАРР" },
|
||||||
|
new() { Code = (int)StatusTemplateEnum.Updating, Name = StatusTemplateEnum.Updating.ToString(), Description = "Выявлено несоответствие. Требуется привлечение робота" },
|
||||||
|
new() { Code = (int)StatusTemplateEnum.Ok, Name = StatusTemplateEnum.Ok.ToString(), Description = "Нормальное состояние шаблона в ЕСПП и ПАРР. Шаблон в ПАРР соответствует шаблону в ЕСПП" }
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
9
PARR.DAL/Contracts/StatusTemplateEnum.cs
Normal file
9
PARR.DAL/Contracts/StatusTemplateEnum.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace PARR.DAL.Contracts
|
||||||
|
{
|
||||||
|
public enum StatusTemplateEnum
|
||||||
|
{
|
||||||
|
Creating = 10,
|
||||||
|
Updating = 20,
|
||||||
|
Ok = 30
|
||||||
|
}
|
||||||
|
}
|
||||||
1071
PARR.DAL/Migrations/20230914064130_TblStatusTemplate.Designer.cs
generated
Normal file
1071
PARR.DAL/Migrations/20230914064130_TblStatusTemplate.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
101
PARR.DAL/Migrations/20230914064130_TblStatusTemplate.cs
Normal file
101
PARR.DAL/Migrations/20230914064130_TblStatusTemplate.cs
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
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 TblStatusTemplate : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Status",
|
||||||
|
table: "Templates");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "isActive",
|
||||||
|
table: "Templates",
|
||||||
|
newName: "IsActive");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "StatusCode",
|
||||||
|
table: "Templates",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "StatusTemplates",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Code = table.Column<int>(type: "integer", nullable: false)
|
||||||
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||||
|
Name = table.Column<string>(type: "text", nullable: false),
|
||||||
|
Description = table.Column<string>(type: "text", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_StatusTemplates", x => x.Code);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.InsertData(
|
||||||
|
table: "StatusTemplates",
|
||||||
|
columns: new[] { "Code", "Description", "Name" },
|
||||||
|
values: new object[,]
|
||||||
|
{
|
||||||
|
{ 10, "Создали шаблон в ПАРР", "Creating" },
|
||||||
|
{ 20, "Выявлено несоответствие. Требуется привлечение робота", "Updating" },
|
||||||
|
{ 30, "Нормальное состояние шаблона в ЕСПП и ПАРР. Шаблон в ПАРР соответствует шаблону в ЕСПП", "Ok" }
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Templates_StatusCode",
|
||||||
|
table: "Templates",
|
||||||
|
column: "StatusCode");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Templates_StatusTemplates_StatusCode",
|
||||||
|
table: "Templates",
|
||||||
|
column: "StatusCode",
|
||||||
|
principalTable: "StatusTemplates",
|
||||||
|
principalColumn: "Code",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Templates_StatusTemplates_StatusCode",
|
||||||
|
table: "Templates");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "StatusTemplates");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Templates_StatusCode",
|
||||||
|
table: "Templates");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "StatusCode",
|
||||||
|
table: "Templates");
|
||||||
|
|
||||||
|
migrationBuilder.RenameColumn(
|
||||||
|
name: "IsActive",
|
||||||
|
table: "Templates",
|
||||||
|
newName: "isActive");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Status",
|
||||||
|
table: "Templates",
|
||||||
|
type: "text",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -377,6 +377,47 @@ namespace PARR.DAL.Migrations
|
|||||||
b.ToTable("Hosts");
|
b.ToTable("Hosts");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PARR.DAL.Models.StatusTemplate", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Code")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Code"));
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Code");
|
||||||
|
|
||||||
|
b.ToTable("StatusTemplates");
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 10,
|
||||||
|
Description = "Создали шаблон в ПАРР",
|
||||||
|
Name = "Creating"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 20,
|
||||||
|
Description = "Выявлено несоответствие. Требуется привлечение робота",
|
||||||
|
Name = "Updating"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Code = 30,
|
||||||
|
Description = "Нормальное состояние шаблона в ЕСПП и ПАРР. Шаблон в ПАРР соответствует шаблону в ЕСПП",
|
||||||
|
Name = "Ok"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PARR.DAL.Models.Template", b =>
|
modelBuilder.Entity("PARR.DAL.Models.Template", b =>
|
||||||
{
|
{
|
||||||
b.Property<Guid>("Id")
|
b.Property<Guid>("Id")
|
||||||
@@ -413,6 +454,9 @@ namespace PARR.DAL.Migrations
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<bool>("IsActive")
|
||||||
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
@@ -433,9 +477,8 @@ namespace PARR.DAL.Migrations
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<string>("Status")
|
b.Property<int>("StatusCode")
|
||||||
.IsRequired()
|
.HasColumnType("integer");
|
||||||
.HasColumnType("text");
|
|
||||||
|
|
||||||
b.Property<string>("SubProcess")
|
b.Property<string>("SubProcess")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
@@ -457,11 +500,10 @@ namespace PARR.DAL.Migrations
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("text");
|
.HasColumnType("text");
|
||||||
|
|
||||||
b.Property<bool>("isActive")
|
|
||||||
.HasColumnType("boolean");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("StatusCode");
|
||||||
|
|
||||||
b.ToTable("Templates");
|
b.ToTable("Templates");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -849,6 +891,17 @@ namespace PARR.DAL.Migrations
|
|||||||
.HasForeignKey("ApplicationTypeId");
|
.HasForeignKey("ApplicationTypeId");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PARR.DAL.Models.Template", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("PARR.DAL.Models.StatusTemplate", "StatusTemplate")
|
||||||
|
.WithMany("Templates")
|
||||||
|
.HasForeignKey("StatusCode")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("StatusTemplate");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_Application", b =>
|
modelBuilder.Entity("PARR.DAL.Models.V1.V1_Application", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("PARR.DAL.Models.V1.V1_ApplicationType", "ApplicationType")
|
b.HasOne("PARR.DAL.Models.V1.V1_ApplicationType", "ApplicationType")
|
||||||
@@ -963,6 +1016,11 @@ namespace PARR.DAL.Migrations
|
|||||||
b.Navigation("ApplicationsInHosts");
|
b.Navigation("ApplicationsInHosts");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PARR.DAL.Models.StatusTemplate", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Templates");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PARR.DAL.Models.V1.V1_Application", b =>
|
modelBuilder.Entity("PARR.DAL.Models.V1.V1_Application", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("V1_ApplicationsInHosts");
|
b.Navigation("V1_ApplicationsInHosts");
|
||||||
|
|||||||
20
PARR.DAL/Models/StatusTemplate.cs
Normal file
20
PARR.DAL/Models/StatusTemplate.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace PARR.DAL.Models
|
||||||
|
{
|
||||||
|
[Table("StatusTemplates")]
|
||||||
|
public class StatusTemplate
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Code { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Description { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ namespace PARR.DAL.Models
|
|||||||
public DateTimeOffset DateCreated { get; set; }
|
public DateTimeOffset DateCreated { get; set; }
|
||||||
public DateTimeOffset? DateModified { get; set; }
|
public DateTimeOffset? DateModified { get; set; }
|
||||||
public required string Name { get; set; }
|
public required string Name { get; set; }
|
||||||
public bool isActive { get; set; }
|
public bool IsActive { get; set; }
|
||||||
public required string WorkGroup { get; set; }
|
public required string WorkGroup { get; set; }
|
||||||
public required string ShortDescription { get; set; }
|
public required string ShortDescription { get; set; }
|
||||||
public required string Category { get; set; }
|
public required string Category { get; set; }
|
||||||
@@ -28,6 +28,13 @@ namespace PARR.DAL.Models
|
|||||||
public required string TNK { get; set; }
|
public required string TNK { get; set; }
|
||||||
public required string Work { get; set; }
|
public required string Work { get; set; }
|
||||||
public required string Worker { get; set; }
|
public required string Worker { get; set; }
|
||||||
public required string Status { get; set; }
|
|
||||||
|
public int StatusCode { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(StatusCode))]
|
||||||
|
public StatusTemplate StatusTemplate { get; set; } = new StatusTemplate();
|
||||||
|
|
||||||
|
//public required string Status { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PARR.DAL.Contracts;
|
||||||
using PARR.DAL.Models;
|
using PARR.DAL.Models;
|
||||||
using PARR.DAL.Services.Interfaces;
|
using PARR.DAL.Services.Interfaces;
|
||||||
|
|
||||||
@@ -37,16 +38,21 @@ namespace PARR.EsppTemplateSync.Services
|
|||||||
|
|
||||||
var template = parserService.ParseString(str);
|
var template = parserService.ParseString(str);
|
||||||
|
|
||||||
if (template == null) {
|
if (template == null)
|
||||||
|
{
|
||||||
isSuccess = false;
|
isSuccess = false;
|
||||||
logger.LogError($"Не удалось распознать строку({str}) в Template");
|
logger.LogError($"Не удалось распознать строку({str}) в Template");
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
//если шаблон не аквтивен, пропускаем
|
//если шаблон не аквтивен, пропускаем
|
||||||
if (!template.isActive)
|
if (!template.IsActive)
|
||||||
{
|
{
|
||||||
return isSuccess;
|
return isSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: !!! тут метод называет чек, но он же исохраняет. По идее надо чтобы чек че то вернул, а исходя из этого дургой метод сохранит или ченить изменит
|
||||||
|
// и опять же, saccess всегда true получается??? или это норм.
|
||||||
await CheckChangesAsync(template);
|
await CheckChangesAsync(template);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +103,7 @@ namespace PARR.EsppTemplateSync.Services
|
|||||||
prop.Name == "Status" ||
|
prop.Name == "Status" ||
|
||||||
prop.Name == "DateCreated" ||
|
prop.Name == "DateCreated" ||
|
||||||
prop.Name == "DateModified" ||
|
prop.Name == "DateModified" ||
|
||||||
prop.Name == "Status"
|
prop.Name == "StatusCode"
|
||||||
) continue;
|
) continue;
|
||||||
|
|
||||||
var parrValue = template.GetType().GetProperty(prop.Name)?.GetValue(template, null);
|
var parrValue = template.GetType().GetProperty(prop.Name)?.GetValue(template, null);
|
||||||
@@ -117,7 +123,10 @@ namespace PARR.EsppTemplateSync.Services
|
|||||||
if (isChanged)
|
if (isChanged)
|
||||||
{
|
{
|
||||||
logger.LogInformation($"----- Запись в ЕСПП отличается от Template {esppTemplate.Name}({esppTemplate.ShortDescription}) -----");
|
logger.LogInformation($"----- Запись в ЕСПП отличается от Template {esppTemplate.Name}({esppTemplate.ShortDescription}) -----");
|
||||||
template.Status = "Updating";
|
|
||||||
|
//template.Status = "Updating";
|
||||||
|
template.StatusCode = (int)StatusTemplateEnum.Updating;
|
||||||
|
|
||||||
if (!await templateService.CommitAsync())
|
if (!await templateService.CommitAsync())
|
||||||
logger.LogError($"Не удалось обновить запись Template {esppTemplate.Name}({esppTemplate.ShortDescription})");
|
logger.LogError($"Не удалось обновить запись Template {esppTemplate.Name}({esppTemplate.ShortDescription})");
|
||||||
else
|
else
|
||||||
@@ -125,12 +134,13 @@ namespace PARR.EsppTemplateSync.Services
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (template.Status != "Ok")
|
//if (template.Status != "Ok")
|
||||||
|
if (template.StatusCode != (int)StatusTemplateEnum.Ok)
|
||||||
{
|
{
|
||||||
template.DateModified = DateTimeOffset.UtcNow;
|
template.DateModified = DateTimeOffset.UtcNow;
|
||||||
template.Status = "Ok";
|
template.StatusCode = (int)StatusTemplateEnum.Ok;
|
||||||
if (!await templateService.CommitAsync())
|
if (!await templateService.CommitAsync())
|
||||||
logger.LogInformation($"Шаблон в ЕСПП соответствует шаблону в ПАРР {esppTemplate.Name}({esppTemplate.ShortDescription}). Установлен статус Ok");
|
logger.LogInformation($"Шаблон в ЕСПП соответствует шаблону в ПАРР {esppTemplate.Name}({esppTemplate.ShortDescription}). Установлен статус {StatusTemplateEnum.Ok}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace PARR.EsppTemplateSync.Services
|
|||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
DateCreated = DateTime.UtcNow,
|
DateCreated = DateTime.UtcNow,
|
||||||
Name = name,
|
Name = name,
|
||||||
isActive = bool.Parse(isActive),
|
IsActive = bool.Parse(isActive),
|
||||||
WorkGroup = workGroup,
|
WorkGroup = workGroup,
|
||||||
ShortDescription = shortDescription,
|
ShortDescription = shortDescription,
|
||||||
Category = category,
|
Category = category,
|
||||||
@@ -75,7 +75,8 @@ namespace PARR.EsppTemplateSync.Services
|
|||||||
TNK = tnk,
|
TNK = tnk,
|
||||||
Work = work,
|
Work = work,
|
||||||
Worker = worker,
|
Worker = worker,
|
||||||
Status = "Checking"
|
//Status = "Checking"
|
||||||
|
StatusCode = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
//bool isSuccess = true;
|
//bool isSuccess = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user