feat(api): AgentTask, AgentHistory

This commit is contained in:
Mikhail Trubnikov
2023-10-19 11:22:35 +10:00
parent 5a40e5c1c1
commit b3b3cc8e0d
21 changed files with 3031 additions and 3 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,88 @@
using System;
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 TblAgentHistory : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AgentHistoryLevels",
columns: table => new
{
Id = 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_AgentHistoryLevels", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AgentHistories",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
DateCreated = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
Message = table.Column<string>(type: "text", nullable: true),
HistoryLevelId = table.Column<int>(type: "integer", nullable: false),
TemplateId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AgentHistories", x => x.Id);
table.ForeignKey(
name: "FK_AgentHistories_AgentHistoryLevels_HistoryLevelId",
column: x => x.HistoryLevelId,
principalTable: "AgentHistoryLevels",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AgentHistories_Templates_TemplateId",
column: x => x.TemplateId,
principalTable: "Templates",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "AgentHistoryLevels",
columns: new[] { "Id", "Description", "Name" },
values: new object[,]
{
{ 1, "Агент начал выполнять задание", "Start" },
{ 5, "Агент завершил выполнение задания", "End" }
});
migrationBuilder.CreateIndex(
name: "IX_AgentHistories_HistoryLevelId",
table: "AgentHistories",
column: "HistoryLevelId");
migrationBuilder.CreateIndex(
name: "IX_AgentHistories_TemplateId",
table: "AgentHistories",
column: "TemplateId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AgentHistories");
migrationBuilder.DropTable(
name: "AgentHistoryLevels");
}
}
}

View File

@@ -369,6 +369,68 @@ namespace PARR.DAL.Migrations
});
});
modelBuilder.Entity("PARR.DAL.Models.AgentHistory", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property<DateTimeOffset>("DateCreated")
.HasColumnType("timestamp with time zone");
b.Property<int>("HistoryLevelId")
.HasColumnType("integer");
b.Property<string>("Message")
.HasColumnType("text");
b.Property<Guid>("TemplateId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("HistoryLevelId");
b.HasIndex("TemplateId");
b.ToTable("AgentHistories");
});
modelBuilder.Entity("PARR.DAL.Models.AgentHistoryLevel", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("AgentHistoryLevels");
b.HasData(
new
{
Id = 1,
Description = "Агент начал выполнять задание",
Name = "Start"
},
new
{
Id = 5,
Description = "Агент завершил выполнение задания",
Name = "End"
});
});
modelBuilder.Entity("PARR.DAL.Models.Application", b =>
{
b.Property<Guid>("Id")
@@ -2066,6 +2128,25 @@ namespace PARR.DAL.Migrations
b.ToTable("Works");
});
modelBuilder.Entity("PARR.DAL.Models.AgentHistory", b =>
{
b.HasOne("PARR.DAL.Models.AgentHistoryLevel", "AgentHistoryLevel")
.WithMany("AgentHistories")
.HasForeignKey("HistoryLevelId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PARR.DAL.Models.Template", "Template")
.WithMany("AgentHistories")
.HasForeignKey("TemplateId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("AgentHistoryLevel");
b.Navigation("Template");
});
modelBuilder.Entity("PARR.DAL.Models.Application", b =>
{
b.HasOne("PARR.DAL.Models.ApplicationType", "ApplicationType")
@@ -2305,6 +2386,11 @@ namespace PARR.DAL.Migrations
b.Navigation("Tnk");
});
modelBuilder.Entity("PARR.DAL.Models.AgentHistoryLevel", b =>
{
b.Navigation("AgentHistories");
});
modelBuilder.Entity("PARR.DAL.Models.Application", b =>
{
b.Navigation("ApplicationsInHosts");
@@ -2402,6 +2488,8 @@ namespace PARR.DAL.Migrations
modelBuilder.Entity("PARR.DAL.Models.Template", b =>
{
b.Navigation("AgentHistories");
b.Navigation("RobotConfigurations");
});