feat(all): ! Критические изменения логики работы всех сервисорв, База Данных имееет неокончательную версию. Template, Scheduler переведены на работу с Unit+Job+JobGroup вместо Host+ApplicationsInWork
This commit is contained in:
@@ -91,7 +91,11 @@ namespace PARR.DAL.Context
|
||||
|
||||
public DbSet<Job> Jobs { get; set; }
|
||||
|
||||
public DbSet<JobUnitFilter> JobDetails { get; set; }
|
||||
public DbSet<JobUnitFilter> JobUnitFilters { get; set; }
|
||||
|
||||
public DbSet<JobGroup> JobGroups { get; set; }
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
3773
PARR.DAL/Migrations/20250625035851_tblTemplatesMigrationFormApplicationInWork.Designer.cs
generated
Normal file
3773
PARR.DAL/Migrations/20250625035851_tblTemplatesMigrationFormApplicationInWork.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,192 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace PARR.DAL.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class tblTemplatesMigrationFormApplicationInWork : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_EsppSchValues_ApplicationsInWorks_ApplicationsInWorkId",
|
||||
table: "EsppSchValues");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Templates_ApplicationsInWorks_ApplicationInWorkId",
|
||||
table: "Templates");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Templates_Hosts_HostId",
|
||||
table: "Templates");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Templates_ApplicationInWorkId",
|
||||
table: "Templates");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Templates_HostId",
|
||||
table: "Templates");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ApplicationInWorkId",
|
||||
table: "Templates");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "HostId",
|
||||
table: "Templates");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "Duration",
|
||||
schema: "job",
|
||||
table: "Groups",
|
||||
newName: "TemplateDuration");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "ApplicationsInWorkId",
|
||||
table: "EsppSchValues",
|
||||
newName: "JobGroupId");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "AgentName",
|
||||
schema: "job",
|
||||
table: "Groups",
|
||||
type: "text",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "AgentScript",
|
||||
schema: "job",
|
||||
table: "Groups",
|
||||
type: "text",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "AgentTimeOutSec",
|
||||
schema: "job",
|
||||
table: "Groups",
|
||||
type: "integer",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsAgent",
|
||||
schema: "job",
|
||||
table: "Groups",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsAutoDistributionEnabled",
|
||||
schema: "job",
|
||||
table: "Groups",
|
||||
type: "boolean",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_EsppSchValues_Groups_JobGroupId",
|
||||
table: "EsppSchValues",
|
||||
column: "JobGroupId",
|
||||
principalSchema: "job",
|
||||
principalTable: "Groups",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_EsppSchValues_Groups_JobGroupId",
|
||||
table: "EsppSchValues");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AgentName",
|
||||
schema: "job",
|
||||
table: "Groups");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AgentScript",
|
||||
schema: "job",
|
||||
table: "Groups");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "AgentTimeOutSec",
|
||||
schema: "job",
|
||||
table: "Groups");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsAgent",
|
||||
schema: "job",
|
||||
table: "Groups");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsAutoDistributionEnabled",
|
||||
schema: "job",
|
||||
table: "Groups");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "TemplateDuration",
|
||||
schema: "job",
|
||||
table: "Groups",
|
||||
newName: "Duration");
|
||||
|
||||
migrationBuilder.RenameColumn(
|
||||
name: "JobGroupId",
|
||||
table: "EsppSchValues",
|
||||
newName: "ApplicationsInWorkId");
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "ApplicationInWorkId",
|
||||
table: "Templates",
|
||||
type: "uuid",
|
||||
nullable: false,
|
||||
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "HostId",
|
||||
table: "Templates",
|
||||
type: "uuid",
|
||||
nullable: false,
|
||||
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Templates_ApplicationInWorkId",
|
||||
table: "Templates",
|
||||
column: "ApplicationInWorkId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Templates_HostId",
|
||||
table: "Templates",
|
||||
column: "HostId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_EsppSchValues_ApplicationsInWorks_ApplicationsInWorkId",
|
||||
table: "EsppSchValues",
|
||||
column: "ApplicationsInWorkId",
|
||||
principalTable: "ApplicationsInWorks",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Templates_ApplicationsInWorks_ApplicationInWorkId",
|
||||
table: "Templates",
|
||||
column: "ApplicationInWorkId",
|
||||
principalTable: "ApplicationsInWorks",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Templates_Hosts_HostId",
|
||||
table: "Templates",
|
||||
column: "HostId",
|
||||
principalTable: "Hosts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1477,7 +1477,7 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.EsppSchValue", b =>
|
||||
{
|
||||
b.Property<Guid>("ApplicationsInWorkId")
|
||||
b.Property<Guid>("JobGroupId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("TypeValueId")
|
||||
@@ -1486,7 +1486,7 @@ namespace PARR.DAL.Migrations
|
||||
b.Property<Guid>("TypeConfigId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.HasKey("ApplicationsInWorkId", "TypeValueId", "TypeConfigId");
|
||||
b.HasKey("JobGroupId", "TypeValueId", "TypeConfigId");
|
||||
|
||||
b.HasIndex("TypeConfigId");
|
||||
|
||||
@@ -1629,16 +1629,21 @@ namespace PARR.DAL.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<string>("AgentName")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("AgentScript")
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<int?>("AgentTimeOutSec")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTimeOffset>("DateCreated")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTimeOffset?>("DateModified")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("Duration")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("FullDescription")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
@@ -1647,6 +1652,12 @@ namespace PARR.DAL.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<bool>("IsAgent")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool>("IsAutoDistributionEnabled")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<bool?>("IsUmbrella")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
@@ -1661,6 +1672,10 @@ namespace PARR.DAL.Migrations
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<string>("TemplateDuration")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Groups", "job", t =>
|
||||
@@ -2559,18 +2574,12 @@ namespace PARR.DAL.Migrations
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<Guid>("ApplicationInWorkId")
|
||||
.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<string>("InitiatorComment")
|
||||
.HasColumnType("text");
|
||||
|
||||
@@ -2607,10 +2616,6 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ApplicationInWorkId");
|
||||
|
||||
b.HasIndex("HostId");
|
||||
|
||||
b.HasIndex("JobId");
|
||||
|
||||
b.HasIndex("Name")
|
||||
@@ -3143,9 +3148,9 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.EsppSchValue", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.ApplicationsInWork", "ApplicationsInWork")
|
||||
b.HasOne("PARR.DAL.Models.Job.JobGroup", "JobGroup")
|
||||
.WithMany("EsppSchValues")
|
||||
.HasForeignKey("ApplicationsInWorkId")
|
||||
.HasForeignKey("JobGroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
@@ -3161,11 +3166,11 @@ namespace PARR.DAL.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ApplicationsInWork");
|
||||
|
||||
b.Navigation("EsppSchTypeConfig");
|
||||
|
||||
b.Navigation("EsppSchTypeValue");
|
||||
|
||||
b.Navigation("JobGroup");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Host", b =>
|
||||
@@ -3215,7 +3220,7 @@ namespace PARR.DAL.Migrations
|
||||
modelBuilder.Entity("PARR.DAL.Models.Job.Job", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.Job.JobGroup", "Group")
|
||||
.WithMany("Job")
|
||||
.WithMany("Jobs")
|
||||
.HasForeignKey("GroupId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
@@ -3381,18 +3386,6 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Template", b =>
|
||||
{
|
||||
b.HasOne("PARR.DAL.Models.ApplicationsInWork", "ApplicationsInWork")
|
||||
.WithMany("Templates")
|
||||
.HasForeignKey("ApplicationInWorkId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.Host", "Host")
|
||||
.WithMany("Templates")
|
||||
.HasForeignKey("HostId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.Job.Job", "Job")
|
||||
.WithMany()
|
||||
.HasForeignKey("JobId")
|
||||
@@ -3400,15 +3393,11 @@ namespace PARR.DAL.Migrations
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("PARR.DAL.Models.Unit.Unit", "Unit")
|
||||
.WithMany()
|
||||
.WithMany("Templates")
|
||||
.HasForeignKey("UnitId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ApplicationsInWork");
|
||||
|
||||
b.Navigation("Host");
|
||||
|
||||
b.Navigation("Job");
|
||||
|
||||
b.Navigation("Unit");
|
||||
@@ -3580,12 +3569,8 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.ApplicationsInWork", b =>
|
||||
{
|
||||
b.Navigation("EsppSchValues");
|
||||
|
||||
b.Navigation("JobAutoControl");
|
||||
|
||||
b.Navigation("Templates");
|
||||
|
||||
b.Navigation("WorkGroups");
|
||||
});
|
||||
|
||||
@@ -3631,8 +3616,6 @@ namespace PARR.DAL.Migrations
|
||||
modelBuilder.Entity("PARR.DAL.Models.Host", b =>
|
||||
{
|
||||
b.Navigation("ApplicationsInHosts");
|
||||
|
||||
b.Navigation("Templates");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Job.Job", b =>
|
||||
@@ -3642,7 +3625,9 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Job.JobGroup", b =>
|
||||
{
|
||||
b.Navigation("Job");
|
||||
b.Navigation("EsppSchValues");
|
||||
|
||||
b.Navigation("Jobs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("PARR.DAL.Models.Job.JobUnitFilter", b =>
|
||||
@@ -3740,6 +3725,8 @@ namespace PARR.DAL.Migrations
|
||||
|
||||
b.Navigation("ParentUnits");
|
||||
|
||||
b.Navigation("Templates");
|
||||
|
||||
b.Navigation("UnitFields");
|
||||
|
||||
b.Navigation("UnitValues");
|
||||
|
||||
@@ -111,9 +111,9 @@ namespace PARR.DAL.Models
|
||||
[ForeignKey(nameof(ApplicationId))]
|
||||
public Application? Application { get; set; }
|
||||
|
||||
public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
|
||||
// public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
|
||||
|
||||
public ICollection<EsppSchValue> EsppSchValues { get; set; } = new HashSet<EsppSchValue>();
|
||||
//public ICollection<EsppSchValue> EsppSchValues { get; set; } = new HashSet<EsppSchValue>();
|
||||
|
||||
public ICollection<AppInWorkInWorkGroup> WorkGroups { get; set; } = new HashSet<AppInWorkInWorkGroup>();
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using PARR.DAL.Models.Job;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace PARR.DAL.Models
|
||||
@@ -8,22 +9,28 @@ namespace PARR.DAL.Models
|
||||
/// </summary>
|
||||
[Table("EsppSchValues")]
|
||||
//[Index(nameof(ApplicationsInWorkId), nameof(TypeValueId), nameof(TypeConfigId), IsUnique = true)]
|
||||
[PrimaryKey(nameof(ApplicationsInWorkId), nameof(TypeValueId), nameof(TypeConfigId))]
|
||||
//[PrimaryKey(nameof(ApplicationsInWorkId), nameof(TypeValueId), nameof(TypeConfigId))]
|
||||
[PrimaryKey(nameof(JobGroupId), nameof(TypeValueId), nameof(TypeConfigId))]
|
||||
public class EsppSchValue
|
||||
{
|
||||
public Guid ApplicationsInWorkId { get; set; }
|
||||
//public Guid ApplicationsInWorkId { get; set; }
|
||||
|
||||
public Guid TypeValueId { get; set; }
|
||||
|
||||
public Guid TypeConfigId { get; set; }
|
||||
|
||||
[ForeignKey(nameof(ApplicationsInWorkId))]
|
||||
public ApplicationsInWork? ApplicationsInWork { get; set; }
|
||||
public Guid JobGroupId { get; set; }
|
||||
|
||||
//[ForeignKey(nameof(ApplicationsInWorkId))]
|
||||
//public ApplicationsInWork? ApplicationsInWork { get; set; }
|
||||
|
||||
[ForeignKey(nameof(TypeValueId))]
|
||||
public EsppSchTypeValue? EsppSchTypeValue { get; set; }
|
||||
|
||||
[ForeignKey(nameof(TypeConfigId))]
|
||||
public EsppSchTypeConfig? EsppSchTypeConfig { get; set; }
|
||||
|
||||
[ForeignKey(nameof(JobGroupId))]
|
||||
public JobGroup? JobGroup { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace PARR.DAL.Models
|
||||
|
||||
public ICollection<ApplicationInHost> ApplicationsInHosts { get; set; } = new HashSet<ApplicationInHost>();
|
||||
|
||||
public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
|
||||
//public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
|
||||
|
||||
|
||||
[ForeignKey(nameof(EkStatusCode))]
|
||||
|
||||
@@ -45,14 +45,61 @@ namespace PARR.DAL.Models.Job
|
||||
/// <summary>
|
||||
/// Поле Длительность описания шаблона АСУ ЕСПП
|
||||
/// </summary>
|
||||
public required string Duration { get; set; }
|
||||
public required string TemplateDuration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TemplateDuration в формате TimeSpan
|
||||
/// </summary>
|
||||
public TimeSpan? TemplateDurationTimeSpan
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
//ЕСПП кривоногие, они почему-то таймспан пишут так "7 00:00:00", а правильно так: "7:00:00:00"
|
||||
var durationWithTimeSpanFormat = TemplateDuration.Replace(" ", ":");
|
||||
|
||||
return TimeSpan.Parse(durationWithTimeSpanFormat);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Дата начала работ или дата для отсчёта периода следующего выполнения
|
||||
/// </summary>
|
||||
public DateTimeOffset ReferenceDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Включить автораспределение
|
||||
/// </summary>
|
||||
public bool IsAutoDistributionEnabled { get; set; }
|
||||
|
||||
public ICollection<Job> Job { get; set; } = new HashSet<Job>();
|
||||
/// <summary>
|
||||
/// Выполняет агент
|
||||
/// </summary>
|
||||
public bool IsAgent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Какое-то имя которое мы передаем агенту, пока непонятно что это такое.
|
||||
/// </summary>
|
||||
public string? AgentName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Сколько времени ожидать выполнение скрипта агентом (секунд)
|
||||
/// </summary>
|
||||
public int? AgentTimeOutSec { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Скрипт для автоматического выполнения
|
||||
/// </summary>
|
||||
public string? AgentScript { get; set; }
|
||||
|
||||
public ICollection<Job> Jobs { get; set; } = new HashSet<Job>();
|
||||
|
||||
public ICollection<EsppSchValue> EsppSchValues { get; set; } = new HashSet<EsppSchValue>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,13 +48,13 @@ namespace PARR.DAL.Models
|
||||
|
||||
public DateTimeOffset NextRun { get; set; }
|
||||
|
||||
public Guid ApplicationInWorkId { get; set; }
|
||||
//public Guid ApplicationInWorkId { get; set; }
|
||||
|
||||
public Guid JobId { get; set; }//TODO Вернуть не NULL!!!
|
||||
|
||||
public Guid UnitId { get; set; }//TODO Вернуть не NULL!!!
|
||||
|
||||
public Guid HostId { get; set; }
|
||||
//public Guid HostId { get; set; }
|
||||
|
||||
#region Initiator
|
||||
public string? InitiatorIp { get; set; }
|
||||
@@ -64,11 +64,11 @@ namespace PARR.DAL.Models
|
||||
public string? InitiatorComment { get; set; }
|
||||
#endregion
|
||||
|
||||
[ForeignKey(nameof(ApplicationInWorkId))]
|
||||
public ApplicationsInWork? ApplicationsInWork { get; set; }
|
||||
//[ForeignKey(nameof(ApplicationInWorkId))]
|
||||
//public ApplicationsInWork? ApplicationsInWork { get; set; }
|
||||
|
||||
[ForeignKey(nameof(HostId))]
|
||||
public Host? Host { get; set; }
|
||||
//[ForeignKey(nameof(HostId))]
|
||||
//public Host? Host { get; set; }
|
||||
|
||||
[ForeignKey(nameof(JobId))]
|
||||
public Job.Job? Job { get; set; }
|
||||
|
||||
@@ -28,6 +28,28 @@ namespace PARR.DAL.Models.Unit
|
||||
// todo: добавить еще поля??? (которые есть у всех ЭК)
|
||||
|
||||
|
||||
[NotMapped]
|
||||
public BaseFields? BaseFields
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
if (UnitValues.Any())
|
||||
{
|
||||
var result = new BaseFields();
|
||||
|
||||
result.IP = UnitValues.FirstOrDefault(t => t.Field?.AihitName == "IP_АДРЕС")?.Value?.Value;
|
||||
result.ResponseArea = UnitValues.FirstOrDefault(t => t.Field?.AihitName == "ЗО_РГ")?.Value?.Value;
|
||||
result.WorkGroup = UnitValues.FirstOrDefault(t => t.Field?.AihitName == "РАБОЧАЯ_ГР_ОТВ_ЗА_ЭК")?.Value?.Value;
|
||||
result.Status = UnitValues.FirstOrDefault(t => t.Field?.AihitName == "СТАТУС")?.Value?.Value;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public ICollection<UnitInField> UnitFields { get; set; } = new HashSet<UnitInField>();
|
||||
|
||||
public ICollection<UnitInValue> UnitValues { get; set; } = new HashSet<UnitInValue>();
|
||||
@@ -44,5 +66,19 @@ namespace PARR.DAL.Models.Unit
|
||||
/// </summary>
|
||||
[InverseProperty(nameof(UnitInUnit.ParentUnit))]
|
||||
public ICollection<UnitInUnit> ChildUnits { get; set; } = new HashSet<UnitInUnit>();
|
||||
|
||||
public ICollection<Template> Templates { get; set; } = new HashSet<Template>();
|
||||
}
|
||||
|
||||
|
||||
public class BaseFields
|
||||
{
|
||||
public string? IP { get; set; }
|
||||
|
||||
public string? ResponseArea { get; set; }
|
||||
|
||||
public string? WorkGroup { get; set; }
|
||||
|
||||
public string? Status { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,8 +105,10 @@ namespace PARR.DAL
|
||||
#region Job
|
||||
|
||||
services.AddTransient<IJobService, JobService>();
|
||||
services.AddTransient<IJobDetailsService, JobDetailsService>();
|
||||
services.AddTransient<IJobGroupService, JobGroupService>();
|
||||
services.AddTransient<IJobUnitFilterService, JobUnitFilterService>();
|
||||
services.AddTransient<IFieldFilterService, FieldFilterService>();
|
||||
services.AddTransient<IJobUnitFilterService, JobUnitFilterService>();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -31,17 +31,27 @@ namespace PARR.DAL.Services.Implementations
|
||||
.ThenInclude(t => t!.EsppSchValues);
|
||||
}
|
||||
|
||||
public async Task<EsppScheduleDto?> GetEsppScheduleDtoAsync(Guid applicationInWorksId)
|
||||
public async Task<EsppScheduleDto?> GetEsppScheduleDtoAsync(Guid jobGroupId)
|
||||
{
|
||||
//Формирует расписание в нормальном понятном виде из БД
|
||||
|
||||
var test = await dataContext.EsppSchValues
|
||||
//.Include(t => t.JobGroup)
|
||||
//.Include(t => t.EsppSchTypeConfig)
|
||||
// .ThenInclude(t => t!.EsppSchTypeSchedule)
|
||||
//.Include(t => t.EsppSchTypeConfig)
|
||||
// .ThenInclude(t => t.EsppSchType)
|
||||
//.Include(t => t.EsppSchTypeValue)
|
||||
.ToListAsync();
|
||||
|
||||
var schValues = await dataContext.EsppSchValues
|
||||
.Include(t => t.EsppSchTypeConfig)
|
||||
.ThenInclude(t => t!.EsppSchTypeSchedule)
|
||||
.Include(t => t.EsppSchTypeConfig)
|
||||
.ThenInclude(t=>t.EsppSchType)
|
||||
.ThenInclude(t => t.EsppSchType)
|
||||
.Include(t => t.EsppSchTypeValue)
|
||||
.Where(t => t.ApplicationsInWorkId == applicationInWorksId)
|
||||
.Include(t => t.JobGroup)
|
||||
.Where(t => t.JobGroup!.Id == jobGroupId)//TODO Migration to job
|
||||
.OrderBy(t => t.EsppSchTypeConfig!.Order)
|
||||
.ToListAsync();
|
||||
|
||||
@@ -94,11 +104,11 @@ namespace PARR.DAL.Services.Implementations
|
||||
return dto;
|
||||
}
|
||||
|
||||
public EsppScheduleDto? GetEsppScheduleDto(Guid applicationInWorksId)
|
||||
public EsppScheduleDto? GetEsppScheduleDto(Guid jobGroupId)
|
||||
{
|
||||
var result = Task.Run(async () =>
|
||||
{
|
||||
return await GetEsppScheduleDtoAsync(applicationInWorksId);
|
||||
return await GetEsppScheduleDtoAsync(jobGroupId);
|
||||
}).Result;
|
||||
|
||||
return result;
|
||||
|
||||
@@ -7,15 +7,15 @@ using PARR.DAL.Services.Interfaces.Job;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations.Job
|
||||
{
|
||||
internal class JobDetailsService : BaseService<Models.Job.JobUnitFilter>, IJobDetailsService
|
||||
internal class JobUnitFilterService : BaseService<JobUnitFilter>, IJobUnitFilterService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
|
||||
protected override DbSet<JobUnitFilter> EntitySet => dataContext.JobDetails;
|
||||
protected override DbSet<JobUnitFilter> EntitySet => dataContext.JobUnitFilters;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
|
||||
public JobDetailsService(DataContext dataContext, ILogger<JobDetailsService> logger) : base(logger)
|
||||
public JobUnitFilterService(DataContext dataContext, ILogger<JobUnitFilterService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
}
|
||||
|
||||
22
PARR.DAL/Services/Implementations/Job/JobGroupService.cs
Normal file
22
PARR.DAL/Services/Implementations/Job/JobGroupService.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using PARR.DAL.Context;
|
||||
using PARR.DAL.Models.Job;
|
||||
using PARR.DAL.Services.Abstracts;
|
||||
using PARR.DAL.Services.Interfaces.Job;
|
||||
|
||||
namespace PARR.DAL.Services.Implementations.Job
|
||||
{
|
||||
internal class JobGroupService : BaseService<Models.Job.JobGroup>, IJobGroupService
|
||||
{
|
||||
private readonly DataContext dataContext;
|
||||
|
||||
public JobGroupService(DataContext dataContext, ILogger<JobGroupService> logger) : base(logger)
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
}
|
||||
protected override DbSet<JobGroup> EntitySet => dataContext.JobGroups;
|
||||
|
||||
protected override DataContext EntitiContext => dataContext;
|
||||
}
|
||||
}
|
||||
@@ -34,18 +34,24 @@ namespace PARR.DAL.Services.Implementations
|
||||
public IQueryable<Template> GetWithIncludes()
|
||||
{
|
||||
return Get()
|
||||
.Include(h => h.Host)
|
||||
.ThenInclude(t => t!.ResponseArea)
|
||||
.Include(h => h.Host)
|
||||
.ThenInclude(t => t!.WorkGroup)
|
||||
.ThenInclude(t => t!.ResponseArea)
|
||||
.Include(h => h.Host)
|
||||
.ThenInclude(t => t!.EkStatus)
|
||||
.Include(a => a.ApplicationsInWork)
|
||||
.ThenInclude(w => w!.Work)
|
||||
.Include(h => h.Unit)
|
||||
.Include(a => a.Job)
|
||||
.ThenInclude(t => t!.Tnk)
|
||||
.ThenInclude(s => s!.Subprocess)
|
||||
.ThenInclude(p => p!.Process);
|
||||
//return Get()
|
||||
// .Include(h => h.Host)
|
||||
// .ThenInclude(t => t!.ResponseArea)
|
||||
// .Include(h => h.Host)
|
||||
// .ThenInclude(t => t!.WorkGroup)
|
||||
// .ThenInclude(t => t!.ResponseArea)
|
||||
// .Include(h => h.Host)
|
||||
// .ThenInclude(t => t!.EkStatus)
|
||||
// .Include(a => a.ApplicationsInWork)
|
||||
// .ThenInclude(w => w!.Work)
|
||||
// .ThenInclude(t => t!.Tnk)
|
||||
// .ThenInclude(s => s!.Subprocess)
|
||||
// .ThenInclude(p => p!.Process);
|
||||
}
|
||||
|
||||
public override Task<bool> CreateAsync(Template obj)
|
||||
|
||||
@@ -18,5 +18,15 @@ namespace PARR.DAL.Services.Implementations.Unit
|
||||
{
|
||||
this.dataContext = dataContext;
|
||||
}
|
||||
|
||||
|
||||
public IQueryable<Models.Unit.Unit> GetWithIncludes()
|
||||
{
|
||||
return Get()
|
||||
.Include(t => t.UnitValues)
|
||||
.ThenInclude(t => t.Field)
|
||||
.Include(t => t.UnitValues)
|
||||
.ThenInclude(t => t.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,16 +9,16 @@ namespace PARR.DAL.Services.Interfaces
|
||||
/// <summary>
|
||||
/// Формирует расписание в нормальном понятном виде из БД синхронно
|
||||
/// </summary>
|
||||
/// <param name="applicationInWorksId"></param>
|
||||
/// <param name="jobGroupId"></param>
|
||||
/// <returns></returns>
|
||||
EsppScheduleDto? GetEsppScheduleDto(Guid applicationInWorksId);
|
||||
EsppScheduleDto? GetEsppScheduleDto(Guid jobGroupId);
|
||||
|
||||
/// <summary>
|
||||
/// Формирует расписание в нормальном понятном виде из БД асинхронно
|
||||
/// </summary>
|
||||
/// <param name="applicationInWorksId"></param>
|
||||
/// <param name="jobGroupId"></param>
|
||||
/// <returns></returns>
|
||||
Task<EsppScheduleDto?> GetEsppScheduleDtoAsync(Guid applicationInWorksId);
|
||||
Task<EsppScheduleDto?> GetEsppScheduleDtoAsync(Guid jobGroupId);
|
||||
|
||||
IQueryable<EsppSchTypeConfig> GetWithSchIncludes();
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces.Job
|
||||
{
|
||||
public interface IJobDetailsService : IBaseService<Models.Job.JobUnitFilter>
|
||||
public interface IJobUnitFilterService : IBaseService<Models.Job.JobUnitFilter>
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
8
PARR.DAL/Services/Interfaces/Job/IJobGroupService.cs
Normal file
8
PARR.DAL/Services/Interfaces/Job/IJobGroupService.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using PARR.DAL.Services.Interfaces.Base;
|
||||
|
||||
namespace PARR.DAL.Services.Interfaces.Job
|
||||
{
|
||||
public interface IJobGroupService : IBaseService<Models.Job.JobGroup>
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -4,5 +4,6 @@ namespace PARR.DAL.Services.Interfaces.Unit
|
||||
{
|
||||
public interface IUnitService : IBaseService<Models.Unit.Unit>
|
||||
{
|
||||
IQueryable<Models.Unit.Unit> GetWithIncludes();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using PARR.DAL.Contracts;
|
||||
using PARR.DAL.DomainModels;
|
||||
using PARR.DAL.Extensions;
|
||||
using PARR.DAL.Services.Interfaces;
|
||||
using PARR.DAL.Services.Interfaces.Job;
|
||||
|
||||
namespace PARR.DAL.TransformServices
|
||||
{
|
||||
@@ -15,6 +16,7 @@ namespace PARR.DAL.TransformServices
|
||||
private readonly IApplicationsInWorkService applicationsInWorkService;
|
||||
private readonly IWeekendDayService weekendDayService;
|
||||
private readonly INextRunModifierService nextRunModifierService;
|
||||
private readonly IJobGroupService jobGroupService;
|
||||
private readonly ILogger<EsppScheduleTransformService> logger;
|
||||
|
||||
private readonly Dictionary<string, int> monthDict = new Dictionary<string, int>()
|
||||
@@ -59,13 +61,15 @@ namespace PARR.DAL.TransformServices
|
||||
IEsppSchTypeConfigService esppSchTypeConfigService,
|
||||
IApplicationsInWorkService applicationsInWorkService,
|
||||
IWeekendDayService weekendDayService,
|
||||
INextRunModifierService nextRunModifierService
|
||||
INextRunModifierService nextRunModifierService,
|
||||
IJobGroupService jobGroupService
|
||||
)
|
||||
{
|
||||
this.esppSchTypeConfigService = esppSchTypeConfigService;
|
||||
this.applicationsInWorkService = applicationsInWorkService;
|
||||
this.weekendDayService = weekendDayService;
|
||||
this.nextRunModifierService = nextRunModifierService;
|
||||
this.jobGroupService = jobGroupService;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@@ -157,23 +161,28 @@ namespace PARR.DAL.TransformServices
|
||||
}
|
||||
|
||||
|
||||
public async Task<DateTimeOffset> GetNextDateAsync(Guid applicationInWorkId, DateTimeOffset lastRun)
|
||||
public async Task<DateTimeOffset> GetNextDateAsync(Guid jobGroupId, DateTimeOffset lastRun)
|
||||
{
|
||||
//если больше текущего вернуть lastRun. Это и есть следующая дата
|
||||
if (lastRun > DateTimeOffset.UtcNow)
|
||||
return await nextRunModifierService.GetWorkDayAsync(lastRun);
|
||||
|
||||
var appInWork = await applicationsInWorkService.Get()
|
||||
.Include(aiw => aiw.EsppSchValues)
|
||||
.ThenInclude(esv => esv.EsppSchTypeValue)
|
||||
.ThenInclude(etv => etv!.DistributionPeriod)
|
||||
.FirstOrDefaultAsync(t => t.Id == applicationInWorkId);
|
||||
//var appInWork = await applicationsInWorkService.Get()
|
||||
// .Include(aiw => aiw.EsppSchValues)
|
||||
// .ThenInclude(esv => esv.EsppSchTypeValue)
|
||||
// .ThenInclude(etv => etv!.DistributionPeriod)
|
||||
// .FirstOrDefaultAsync(t => t.Id == applicationInWorkId);
|
||||
var jobGroup = await jobGroupService.Get()
|
||||
.Include(t=>t.EsppSchValues)
|
||||
.ThenInclude(esv => esv.EsppSchTypeValue)
|
||||
.ThenInclude(etv => etv!.DistributionPeriod)
|
||||
.FirstOrDefaultAsync(t => t.Id == jobGroupId);
|
||||
|
||||
var esppSchedule = await GetEsppScheduleAsync(applicationInWorkId);
|
||||
var esppSchedule = await GetEsppScheduleAsync(jobGroupId);
|
||||
|
||||
if (appInWork!.IsAutoDistributionEnabled)
|
||||
if (jobGroup!.IsAutoDistributionEnabled)
|
||||
{
|
||||
var period = appInWork.EsppSchValues.FirstOrDefault()?.EsppSchTypeValue?.DistributionPeriod;
|
||||
var period = jobGroup.EsppSchValues.FirstOrDefault()?.EsppSchTypeValue?.DistributionPeriod;
|
||||
var periodType = ParseDistributionPeriodType(period!.Type);
|
||||
|
||||
return GetNextDateForDistributionRun(lastRun, periodType, period.Duration);
|
||||
@@ -183,24 +192,24 @@ namespace PARR.DAL.TransformServices
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<DateTimeOffset>> GetNextScheduleAsync(Guid applicationInWorkId, DateTimeOffset lastRun)
|
||||
public async Task<List<DateTimeOffset>> GetNextScheduleAsync(Guid jobGroupId, DateTimeOffset lastRun)
|
||||
{
|
||||
//TODO: тут не проверен переход через выходные дни!!! Переход не используется, так как тут не рассчитываем NextRun.
|
||||
//В общем проверить, когда будем тестировать агента, что с датами все ок
|
||||
var esppSchedule = await GetEsppScheduleAsync(applicationInWorkId);
|
||||
var esppSchedule = await GetEsppScheduleAsync(jobGroupId);
|
||||
var nextSchedule = GetNextSchedule(esppSchedule, lastRun);
|
||||
|
||||
return nextSchedule;
|
||||
}
|
||||
|
||||
|
||||
private async Task<EsppScheduleDto> GetEsppScheduleAsync(Guid applicationInWorkId)
|
||||
private async Task<EsppScheduleDto> GetEsppScheduleAsync(Guid jobGroupId)
|
||||
{
|
||||
var esppSchedule = await esppSchTypeConfigService.GetEsppScheduleDtoAsync(applicationInWorkId);
|
||||
var esppSchedule = await esppSchTypeConfigService.GetEsppScheduleDtoAsync(jobGroupId);
|
||||
if (esppSchedule == null)
|
||||
{
|
||||
logger.LogError($"Не найдено расписание в БД, applicationInWorkId: {applicationInWorkId}");
|
||||
throw new Exception($"Не найдено расписание в БД, applicationInWorkId: {applicationInWorkId}");
|
||||
logger.LogError($"Не найдено расписание в БД, jobId: {jobGroupId}");
|
||||
throw new Exception($"Не найдено расписание в БД, jobId: {jobGroupId}");
|
||||
}
|
||||
|
||||
return esppSchedule;
|
||||
@@ -427,9 +436,9 @@ namespace PARR.DAL.TransformServices
|
||||
}
|
||||
|
||||
|
||||
public async Task<DateOnly> GetStartPeriodForDateAsync(Guid applicationInWorkId, DateTimeOffset date, DateTimeOffset referenceDate, DistributionPeriodTypeEnum periodType, string distributionPeriod)
|
||||
public async Task<DateOnly> GetStartPeriodForDateAsync(Guid jobGroupId, DateTimeOffset date, DateTimeOffset referenceDate, DistributionPeriodTypeEnum periodType, string distributionPeriod)
|
||||
{
|
||||
var esppSchedule = await GetEsppScheduleAsync(applicationInWorkId);
|
||||
var esppSchedule = await GetEsppScheduleAsync(jobGroupId);
|
||||
|
||||
var currentStartPeriod = referenceDate;
|
||||
var currentEndPeriod = GetNextDateForDistributionRun(currentStartPeriod, periodType, distributionPeriod);
|
||||
|
||||
@@ -25,20 +25,20 @@ namespace PARR.DAL.TransformServices
|
||||
//List<DateTimeOffset> GetNextSchedule(EsppScheduleDto esppSchedule, DateTimeOffset lastRun);
|
||||
|
||||
/// <summary>
|
||||
/// Получить следующую дату по applicationInWorkId
|
||||
/// Получить следующую дату по jobGroupId
|
||||
/// </summary>
|
||||
/// <param name="applicationInWorkId"></param>
|
||||
/// <param name="jobGroupId"></param>
|
||||
/// <param name="lastRun"></param>
|
||||
/// <returns></returns>
|
||||
Task<DateTimeOffset> GetNextDateAsync(Guid applicationInWorkId, DateTimeOffset lastRun);
|
||||
Task<DateTimeOffset> GetNextDateAsync(Guid jobGroupId, DateTimeOffset lastRun);
|
||||
|
||||
/// <summary>
|
||||
/// Получить расписание по applicationInWorkId
|
||||
/// Получить расписание по jobGroupId
|
||||
/// </summary>
|
||||
/// <param name="applicationInWorkId"></param>
|
||||
/// <param name="jobGroupId"></param>
|
||||
/// <param name="lastRun"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<DateTimeOffset>> GetNextScheduleAsync(Guid applicationInWorkId, DateTimeOffset lastRun);
|
||||
Task<List<DateTimeOffset>> GetNextScheduleAsync(Guid jobGroupId, DateTimeOffset lastRun);
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -49,14 +49,14 @@ namespace PARR.DAL.TransformServices
|
||||
/// <param name="distributionPeriod"></param>
|
||||
/// <returns></returns>
|
||||
DateTimeOffset GetNextDateForDistributionRun(DateTimeOffset lastRun, DistributionPeriodTypeEnum periodType, string distributionPeriod);
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Получить дату начала периода распределения относительно опорной даты (Reference Date)
|
||||
/// </summary>
|
||||
/// <param name="applicationInWorkId"></param>
|
||||
/// <param name="jobGroupId"></param>
|
||||
/// <param name="date"></param>
|
||||
/// <returns></returns>
|
||||
Task<DateOnly> GetStartPeriodForDateAsync(Guid applicationInWorkId, DateTimeOffset date, DateTimeOffset refrenceDate, DistributionPeriodTypeEnum periodType, string distributionPeriod);
|
||||
Task<DateOnly> GetStartPeriodForDateAsync(Guid jobGroupId, DateTimeOffset date, DateTimeOffset refrenceDate, DistributionPeriodTypeEnum periodType, string distributionPeriod);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user