diff --git a/PARR.API/Contracts/V1/ApiRoutes.cs b/PARR.API/Contracts/V1/ApiRoutes.cs index 40280dbe..eed30a21 100644 --- a/PARR.API/Contracts/V1/ApiRoutes.cs +++ b/PARR.API/Contracts/V1/ApiRoutes.cs @@ -27,11 +27,11 @@ public const string Metrics = Base + "/metrics"; } - public static class Scheduler + public static class Jobs { - public const string GetAll = Base + "/schedulers/"; + public const string GetAll = Base + "/jobs/"; - public const string GetByIp = Base + "/schedulers/ip/"; + public const string GetByIp = Base + "/jobs/ip/"; //public const string Get = Base + "/schedulers/" + getParam; //public const string GetAreas = Base + "/schedulers/" + getParam + "/areas"; diff --git a/PARR.API/Contracts/V1/Requests/Queries/SchedulerGetAllQuery.cs b/PARR.API/Contracts/V1/Requests/Queries/JobGetAllQuery.cs similarity index 92% rename from PARR.API/Contracts/V1/Requests/Queries/SchedulerGetAllQuery.cs rename to PARR.API/Contracts/V1/Requests/Queries/JobGetAllQuery.cs index 0b021ad6..a908f2e3 100644 --- a/PARR.API/Contracts/V1/Requests/Queries/SchedulerGetAllQuery.cs +++ b/PARR.API/Contracts/V1/Requests/Queries/JobGetAllQuery.cs @@ -1,6 +1,6 @@ namespace PARR.API.Contracts.V1.Requests.Queries { - public class SchedulerGetAllQuery + public class JobGetAllQuery { /// /// true - вкл задания, false - выкл задания, null - все задания diff --git a/PARR.API/Contracts/V1/Requests/Queries/SchedulerGetByIpQuery.cs b/PARR.API/Contracts/V1/Requests/Queries/JobGetByIpQuery.cs similarity index 56% rename from PARR.API/Contracts/V1/Requests/Queries/SchedulerGetByIpQuery.cs rename to PARR.API/Contracts/V1/Requests/Queries/JobGetByIpQuery.cs index fea5392d..9e110976 100644 --- a/PARR.API/Contracts/V1/Requests/Queries/SchedulerGetByIpQuery.cs +++ b/PARR.API/Contracts/V1/Requests/Queries/JobGetByIpQuery.cs @@ -1,7 +1,8 @@ namespace PARR.API.Contracts.V1.Requests.Queries { - public class SchedulerGetByIpQuery + public class JobGetByIpQuery { public string? Ip { get; set; } + public DateTimeOffset? Date { get; set; } } } diff --git a/PARR.API/Contracts/V1/Responses/JobModeResponse.cs b/PARR.API/Contracts/V1/Responses/JobModeResponse.cs new file mode 100644 index 00000000..7c2737ee --- /dev/null +++ b/PARR.API/Contracts/V1/Responses/JobModeResponse.cs @@ -0,0 +1,8 @@ +namespace PARR.API.Contracts.V1.Responses +{ + public class JobModeResponse + { + public Guid Id { get; set; } + public required string Name { get; set; } + } +} diff --git a/PARR.API/Contracts/V1/Responses/SchedulerResponse.cs b/PARR.API/Contracts/V1/Responses/JobResponse.cs similarity index 64% rename from PARR.API/Contracts/V1/Responses/SchedulerResponse.cs rename to PARR.API/Contracts/V1/Responses/JobResponse.cs index 9444e815..508a7336 100644 --- a/PARR.API/Contracts/V1/Responses/SchedulerResponse.cs +++ b/PARR.API/Contracts/V1/Responses/JobResponse.cs @@ -1,20 +1,20 @@ namespace PARR.API.Contracts.V1.Responses { - public class SchedulerBaseResponse + public class JobBaseResponse { public required string Name { get; set; } public DateTimeOffset StartAt { get; set; } public int FrequencyMinute { get; set; } - + public required JobModeResponse JobMode { get; set; } } - public class SchedulerGetAllResponse: SchedulerBaseResponse + public class JobGetAllResponse : JobBaseResponse { public Guid Id { get; set; } public bool IsEnabled { get; set; } } - public class SchedulerResponse + public class JobResponse { } diff --git a/PARR.API/Controllers/V1/JobController.cs b/PARR.API/Controllers/V1/JobController.cs new file mode 100644 index 00000000..9e5b1610 --- /dev/null +++ b/PARR.API/Controllers/V1/JobController.cs @@ -0,0 +1,116 @@ +using AutoMapper; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using PARR.API.Contracts.V1; +using PARR.API.Contracts.V1.Requests.Queries; +using PARR.API.Contracts.V1.Responses; +using PARR.API.Contracts.V1.Responses.Base; +using PARR.API.Controllers.V1.Base; +using PARR.API.Extensions; +using PARR.API.Services.Interfaces; +using PARR.DAL.DomainModels; +using PARR.DAL.Models; +using PARR.DAL.Services.Interfaces; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory; +using static PARR.API.Contracts.V1.ApiRoutes; + +namespace PARR.API.Controllers.V1 +{ + public class JobController : BaseApiController + { + private readonly IMapper mapper; + private readonly IJobService jobService; + //private readonly ISchedulerService schedulerService; + private readonly IClientService clientService; + private readonly IHostService hostService; + + public JobController( + IMapper mapper, + IJobService jobService, + IClientService clientService, + IHostService hostService + ) + { + this.mapper = mapper; + this.jobService = jobService; + //this.schedulerService = schedulerService; + this.clientService = clientService; + this.hostService = hostService; + } + + + /// + /// Список всех jobов постранично в соотвествии с фильтрами + /// + /// + /// + [HttpGet(ApiRoutes.Jobs.GetAll)] + public async Task GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] JobGetAllQuery filter) + { + var paginationFilter = mapper.Map(paginationQuery); + IQueryable query = jobService.Get().Include(t => t.JobMode).OrderBy(s => s.StartAt); + + if (filter.IsEnabled.HasValue) + query = query.Where(t => t.IsEnabled == filter.IsEnabled); + + if (filter.StartDatePlanned.HasValue) + query = query.Where(t => t.StartAt.DateTime.Date <= filter.StartDatePlanned.Value.DateTime.Date); ; + + var jobs = await jobService.GetPage(query, paginationFilter).ToListAsync(); + + if (!jobs.Any()) + return NoContent(); + + var jobResponse = mapper.Map>(jobs); + var paginationResponse = new PagedResponse(jobResponse, true).GetPaginatedProps(paginationFilter, query); + + return Ok(paginationResponse); + } + + + [HttpGet(ApiRoutes.Jobs.GetByIp)] + public async Task GetByClientIP([FromQuery] JobGetByIpQuery requestQuery) + { + var ip = requestQuery.Ip ?? clientService.GetClientIp()?.ToString(); + if (string.IsNullOrEmpty(ip)) + return BadRequest(new Response(false, new List { new ErrorModel { Message = "Client IP address is null." } })); + + var date = requestQuery.Date ?? DateTimeOffset.Now; + + // С одним IP может быть несколько информационных систем, соответственного а таблице храниться несколько записей хостов с одинаковым IP + var hosts = await hostService.Get().Where(h => h.IP == ip).ToListAsync(); + var hostJobsDict = new Dictionary>(); + foreach (var host in hosts) + { + var jobsHost = await jobService.Get() + .Include(a => a.Application).ThenInclude(ah => ah.ApplicationsInHosts)/*.ThenInclude(h => h.Host)*/ + .Include(jm=>jm.JobMode) + .AsSplitQuery() + .Where(j => j.Application != null && j.Application.ApplicationsInHosts.Any(ah => ah.HostId == host.Id)) + .ToListAsync(); + if (jobsHost.Any()) + hostJobsDict.Add(host, jobsHost); + } + //hostJobsDict.Values.Distinct(); + + var jobsJoined = new List(); + foreach(var job in hostJobsDict.Values) + { + job.ForEach(item => + { + jobsJoined.Add(item); + }); + } + jobsJoined.Distinct(); + + + if (!jobsJoined.Any()) + return NoContent(); + + var jobResponse = mapper.Map>(jobsJoined); + + return Ok(new Response>(jobResponse, true, new List(), $"{ip},{date}")); + } + + } +} diff --git a/PARR.API/Controllers/V1/ShchedullerController.cs b/PARR.API/Controllers/V1/ShchedullerController.cs deleted file mode 100644 index be8945f8..00000000 --- a/PARR.API/Controllers/V1/ShchedullerController.cs +++ /dev/null @@ -1,78 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using PARR.API.Contracts.V1.Requests.Queries; -using PARR.API.Contracts.V1; -using PARR.API.Controllers.V1.Base; -using AutoMapper; -using PARR.DAL.DomainModels; -using PARR.DAL.Models; -using PARR.DAL.Services.Interfaces; -using Microsoft.EntityFrameworkCore; -using PARR.API.Contracts.V1.Responses; -using PARR.API.Contracts.V1.Responses.Base; -using PARR.API.Extensions; -using System.Runtime.CompilerServices; -using PARR.API.Services.Interfaces; - -namespace PARR.API.Controllers.V1 -{ - public class ShchedullerController : BaseApiController - { - private readonly IMapper mapper; - private readonly ISchedulerService schedulerService; - private readonly IClientService clientService; - - public ShchedullerController( - IMapper mapper, - ISchedulerService schedulerService, - IClientService clientService - ) - { - this.mapper = mapper; - this.schedulerService = schedulerService; - this.clientService = clientService; - } - - - /// - /// Список всех планировщиков постранично в соотвествии с фильтрами - /// - /// - /// - [HttpGet(ApiRoutes.Scheduler.GetAll)] - public async Task GetAll([FromQuery] PaginationQuery paginationQuery, [FromQuery] SchedulerGetAllQuery filter) - { - var paginationFilter = mapper.Map(paginationQuery); - IQueryable query = schedulerService.Get().OrderBy(s => s.StartAt); - - if (filter.IsEnabled.HasValue) - query = query.Where(t => t.IsEnabled == filter.IsEnabled); - - if (filter.StartDatePlanned.HasValue) - query = query.Where(t => t.StartAt.DateTime.Date <= filter.StartDatePlanned.Value.DateTime.Date); ; - - var schedulers = await schedulerService.GetPage(query, paginationFilter).ToListAsync(); - - if (!schedulers.Any()) - return NoContent(); - - var schedulerResponse = mapper.Map>(schedulers); - var paginationResponse = new PagedResponse(schedulerResponse, true).GetPaginatedProps(paginationFilter, query); - - return Ok(paginationResponse); - } - - - [HttpGet(ApiRoutes.Scheduler.GetByIp)] - public async Task GetByClientIP([FromQuery] SchedulerGetByIpQuery requestQuery) - { - var ip = requestQuery.Ip ?? clientService.GetClientIp()?.ToString(); - if (string.IsNullOrEmpty(ip)) - return BadRequest(new Response(false, new List { new ErrorModel { Message = "Client IP address is null." } })); - - // TODO; - - return Ok(); - } - - } -} diff --git a/PARR.API/MappingProfiles/DomainToResponseProfile.cs b/PARR.API/MappingProfiles/DomainToResponseProfile.cs index 270d6dcc..998cb073 100644 --- a/PARR.API/MappingProfiles/DomainToResponseProfile.cs +++ b/PARR.API/MappingProfiles/DomainToResponseProfile.cs @@ -8,11 +8,14 @@ namespace PARR.API.MappingProfiles { public DomainToResponseProfile() { - // --- Scheduler --- - CreateMap() - .Include() + // --- Job --- + CreateMap() + .Include() .ForMember(d => d.FrequencyMinute, o => o.MapFrom(s => s.Frequency)); - CreateMap(); + CreateMap(); + + + CreateMap(); } } } diff --git a/PARR.DAL/Context/DataContext.cs b/PARR.DAL/Context/DataContext.cs index bd5cd88c..704c0357 100644 --- a/PARR.DAL/Context/DataContext.cs +++ b/PARR.DAL/Context/DataContext.cs @@ -18,7 +18,7 @@ namespace PARR.DAL.Context public DbSet Applications { get; set; } public DbSet ApplicationTypes { get; set; } public DbSet ApplicationsInHosts { get; set; } - public DbSet Schedulers { get; set; } + //public DbSet Schedulers { get; set; } //todo init application type+check migrations @@ -36,6 +36,14 @@ namespace PARR.DAL.Context ); }); + modelBuilder.Entity(f => + { + f.HasData( + new() { Id = new Guid("EDEF6DC3-ADAD-4C77-8AD1-63BB9052355A"), DateCreated = dateCreated, DateModified = null, Name = "started", Description = "Задание запущено" }, + new() { Id = new Guid("7B945EB6-D885-4570-AFF5-8866F1F75FF2"), DateCreated = dateCreated, DateModified = null, Name = "finished", Description = "Задание выполнено" } + ); + }); + modelBuilder.Entity(f => { diff --git a/PARR.DAL/Migrations/20230619021829_SchedulerClmnsToJob.Designer.cs b/PARR.DAL/Migrations/20230619021829_SchedulerClmnsToJob.Designer.cs new file mode 100644 index 00000000..92412ac6 --- /dev/null +++ b/PARR.DAL/Migrations/20230619021829_SchedulerClmnsToJob.Designer.cs @@ -0,0 +1,512 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using PARR.DAL.Context; + +#nullable disable + +namespace PARR.DAL.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20230619021829_SchedulerClmnsToJob")] + partial class SchedulerClmnsToJob + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("PARR.DAL.Models.Application", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ApplicationId") + .HasColumnType("uuid"); + + b.Property("ApplicationTypeId") + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationId"); + + b.HasIndex("ApplicationTypeId"); + + b.ToTable("Applications"); + }); + + modelBuilder.Entity("PARR.DAL.Models.ApplicationInHost", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ApplicationId") + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("HostId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationId"); + + b.HasIndex("HostId"); + + b.ToTable("ApplicationsInHosts"); + }); + + modelBuilder.Entity("PARR.DAL.Models.ApplicationType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("ApplicationTypes"); + + b.HasData( + new + { + 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 АИХ ИТ", + 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 АИХ ИТ", + 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 АИХ ИТ", + Name = "DB" + }); + }); + + modelBuilder.Entity("PARR.DAL.Models.Host", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("HostName") + .HasColumnType("text"); + + b.Property("IP") + .IsRequired() + .HasColumnType("text"); + + b.Property("LinkEK") + .HasColumnType("text"); + + b.Property("RegionalEK") + .HasColumnType("text"); + + b.Property("Responsible") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("text"); + + b.Property("WorkGroup") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Hosts"); + }); + + modelBuilder.Entity("PARR.DAL.Models.Job", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ApplicationId") + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Frequency") + .HasColumnType("integer"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("JobCategoryId") + .HasColumnType("uuid"); + + b.Property("JobModeId") + .HasColumnType("uuid"); + + b.Property("JobTypeId") + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ScriptName") + .IsRequired() + .HasColumnType("text"); + + b.Property("StartAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationId"); + + b.HasIndex("JobCategoryId"); + + b.HasIndex("JobModeId"); + + b.HasIndex("JobTypeId"); + + b.ToTable("Jobs"); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("JobCategories"); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobJournal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("DateOper") + .HasColumnType("text"); + + b.Property("HostId") + .HasColumnType("uuid"); + + b.Property("Info") + .HasColumnType("text"); + + b.Property("JobId") + .HasColumnType("uuid"); + + b.Property("JobStatusId") + .HasColumnType("uuid"); + + b.Property("Other") + .HasColumnType("text"); + + b.Property("TimeOut") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("HostId"); + + b.HasIndex("JobId"); + + b.HasIndex("JobStatusId"); + + b.ToTable("JobJournals"); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobMode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("JobModes"); + + b.HasData( + new + { + Id = new Guid("fba4202c-5bad-49c4-b076-d1ca6e1fb158"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Name = "auto" + }, + new + { + Id = new Guid("7516b952-510d-4aaa-971c-a14b184fc1d5"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Name = "manual" + }); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("JobStatuses"); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("JobTypes"); + }); + + modelBuilder.Entity("PARR.DAL.Models.Application", b => + { + b.HasOne("PARR.DAL.Models.Application", null) + .WithMany("Applications") + .HasForeignKey("ApplicationId"); + + b.HasOne("PARR.DAL.Models.ApplicationType", "ApplicationType") + .WithMany() + .HasForeignKey("ApplicationTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ApplicationType"); + }); + + modelBuilder.Entity("PARR.DAL.Models.ApplicationInHost", b => + { + b.HasOne("PARR.DAL.Models.Application", "Application") + .WithMany("ApplicationsInHosts") + .HasForeignKey("ApplicationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PARR.DAL.Models.Host", "Host") + .WithMany("ApplicationsInHosts") + .HasForeignKey("HostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Application"); + + b.Navigation("Host"); + }); + + modelBuilder.Entity("PARR.DAL.Models.Job", b => + { + b.HasOne("PARR.DAL.Models.Application", "Application") + .WithMany() + .HasForeignKey("ApplicationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PARR.DAL.Models.JobCategory", "JobCategorye") + .WithMany("Jobs") + .HasForeignKey("JobCategoryId"); + + b.HasOne("PARR.DAL.Models.JobMode", "JobMode") + .WithMany("Jobs") + .HasForeignKey("JobModeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PARR.DAL.Models.JobType", "JobType") + .WithMany("Jobs") + .HasForeignKey("JobTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Application"); + + b.Navigation("JobCategorye"); + + b.Navigation("JobMode"); + + b.Navigation("JobType"); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobJournal", b => + { + b.HasOne("PARR.DAL.Models.Host", "Host") + .WithMany("JobJournals") + .HasForeignKey("HostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PARR.DAL.Models.Job", "Job") + .WithMany("Journals") + .HasForeignKey("JobId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PARR.DAL.Models.JobStatus", "Status") + .WithMany("Journals") + .HasForeignKey("JobStatusId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Host"); + + b.Navigation("Job"); + + b.Navigation("Status"); + }); + + modelBuilder.Entity("PARR.DAL.Models.Application", b => + { + b.Navigation("Applications"); + + b.Navigation("ApplicationsInHosts"); + }); + + modelBuilder.Entity("PARR.DAL.Models.Host", b => + { + b.Navigation("ApplicationsInHosts"); + + b.Navigation("JobJournals"); + }); + + modelBuilder.Entity("PARR.DAL.Models.Job", b => + { + b.Navigation("Journals"); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobCategory", b => + { + b.Navigation("Jobs"); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobMode", b => + { + b.Navigation("Jobs"); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobStatus", b => + { + b.Navigation("Journals"); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobType", b => + { + b.Navigation("Jobs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/PARR.DAL/Migrations/20230619021829_SchedulerClmnsToJob.cs b/PARR.DAL/Migrations/20230619021829_SchedulerClmnsToJob.cs new file mode 100644 index 00000000..95456021 --- /dev/null +++ b/PARR.DAL/Migrations/20230619021829_SchedulerClmnsToJob.cs @@ -0,0 +1,72 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace PARR.DAL.Migrations +{ + /// + public partial class SchedulerClmnsToJob : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Schedulers"); + + migrationBuilder.AddColumn( + name: "Frequency", + table: "Jobs", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "IsEnabled", + table: "Jobs", + type: "boolean", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "StartAt", + table: "Jobs", + type: "timestamp with time zone", + nullable: false, + defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0))); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Frequency", + table: "Jobs"); + + migrationBuilder.DropColumn( + name: "IsEnabled", + table: "Jobs"); + + migrationBuilder.DropColumn( + name: "StartAt", + table: "Jobs"); + + migrationBuilder.CreateTable( + name: "Schedulers", + columns: table => new + { + Id = table.Column(type: "uuid", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateModified = table.Column(type: "timestamp with time zone", nullable: true), + Frequency = table.Column(type: "integer", nullable: false), + IsEnabled = table.Column(type: "boolean", nullable: false), + Name = table.Column(type: "text", nullable: true), + StartAt = table.Column(type: "timestamp with time zone", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Schedulers", x => x.Id); + }); + } + } +} diff --git a/PARR.DAL/Migrations/20230620022903_TblStatus.Designer.cs b/PARR.DAL/Migrations/20230620022903_TblStatus.Designer.cs new file mode 100644 index 00000000..109a8f3e --- /dev/null +++ b/PARR.DAL/Migrations/20230620022903_TblStatus.Designer.cs @@ -0,0 +1,528 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using PARR.DAL.Context; + +#nullable disable + +namespace PARR.DAL.Migrations +{ + [DbContext(typeof(DataContext))] + [Migration("20230620022903_TblStatus")] + partial class TblStatus + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("PARR.DAL.Models.Application", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ApplicationId") + .HasColumnType("uuid"); + + b.Property("ApplicationTypeId") + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationId"); + + b.HasIndex("ApplicationTypeId"); + + b.ToTable("Applications"); + }); + + modelBuilder.Entity("PARR.DAL.Models.ApplicationInHost", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ApplicationId") + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("HostId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationId"); + + b.HasIndex("HostId"); + + b.ToTable("ApplicationsInHosts"); + }); + + modelBuilder.Entity("PARR.DAL.Models.ApplicationType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("ApplicationTypes"); + + b.HasData( + new + { + 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 АИХ ИТ", + 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 АИХ ИТ", + 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 АИХ ИТ", + Name = "DB" + }); + }); + + modelBuilder.Entity("PARR.DAL.Models.Host", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("HostName") + .HasColumnType("text"); + + b.Property("IP") + .IsRequired() + .HasColumnType("text"); + + b.Property("LinkEK") + .HasColumnType("text"); + + b.Property("RegionalEK") + .HasColumnType("text"); + + b.Property("Responsible") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("text"); + + b.Property("WorkGroup") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Hosts"); + }); + + modelBuilder.Entity("PARR.DAL.Models.Job", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ApplicationId") + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Frequency") + .HasColumnType("integer"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("JobCategoryId") + .HasColumnType("uuid"); + + b.Property("JobModeId") + .HasColumnType("uuid"); + + b.Property("JobTypeId") + .HasColumnType("uuid"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ScriptName") + .IsRequired() + .HasColumnType("text"); + + b.Property("StartAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ApplicationId"); + + b.HasIndex("JobCategoryId"); + + b.HasIndex("JobModeId"); + + b.HasIndex("JobTypeId"); + + b.ToTable("Jobs"); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobCategory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("JobCategories"); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobJournal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("DateOper") + .HasColumnType("text"); + + b.Property("HostId") + .HasColumnType("uuid"); + + b.Property("Info") + .HasColumnType("text"); + + b.Property("JobId") + .HasColumnType("uuid"); + + b.Property("JobStatusId") + .HasColumnType("uuid"); + + b.Property("Other") + .HasColumnType("text"); + + b.Property("TimeOut") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("HostId"); + + b.HasIndex("JobId"); + + b.HasIndex("JobStatusId"); + + b.ToTable("JobJournals"); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobMode", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("JobModes"); + + b.HasData( + new + { + Id = new Guid("fba4202c-5bad-49c4-b076-d1ca6e1fb158"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Name = "auto" + }, + new + { + Id = new Guid("7516b952-510d-4aaa-971c-a14b184fc1d5"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Name = "manual" + }); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobStatus", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("JobStatuses"); + + b.HasData( + new + { + Id = new Guid("edef6dc3-adad-4c77-8ad1-63bb9052355a"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Description = "Задание запущено", + Name = "started" + }, + new + { + Id = new Guid("7b945eb6-d885-4570-aff5-8866f1f75ff2"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Description = "Задание выполнено", + Name = "finished" + }); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DateCreated") + .HasColumnType("timestamp with time zone"); + + b.Property("DateModified") + .HasColumnType("timestamp with time zone"); + + b.Property("Description") + .HasColumnType("text"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("JobTypes"); + }); + + modelBuilder.Entity("PARR.DAL.Models.Application", b => + { + b.HasOne("PARR.DAL.Models.Application", null) + .WithMany("Applications") + .HasForeignKey("ApplicationId"); + + b.HasOne("PARR.DAL.Models.ApplicationType", "ApplicationType") + .WithMany() + .HasForeignKey("ApplicationTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ApplicationType"); + }); + + modelBuilder.Entity("PARR.DAL.Models.ApplicationInHost", b => + { + b.HasOne("PARR.DAL.Models.Application", "Application") + .WithMany("ApplicationsInHosts") + .HasForeignKey("ApplicationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PARR.DAL.Models.Host", "Host") + .WithMany("ApplicationsInHosts") + .HasForeignKey("HostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Application"); + + b.Navigation("Host"); + }); + + modelBuilder.Entity("PARR.DAL.Models.Job", b => + { + b.HasOne("PARR.DAL.Models.Application", "Application") + .WithMany() + .HasForeignKey("ApplicationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PARR.DAL.Models.JobCategory", "JobCategorye") + .WithMany("Jobs") + .HasForeignKey("JobCategoryId"); + + b.HasOne("PARR.DAL.Models.JobMode", "JobMode") + .WithMany("Jobs") + .HasForeignKey("JobModeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PARR.DAL.Models.JobType", "JobType") + .WithMany("Jobs") + .HasForeignKey("JobTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Application"); + + b.Navigation("JobCategorye"); + + b.Navigation("JobMode"); + + b.Navigation("JobType"); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobJournal", b => + { + b.HasOne("PARR.DAL.Models.Host", "Host") + .WithMany("JobJournals") + .HasForeignKey("HostId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PARR.DAL.Models.Job", "Job") + .WithMany("Journals") + .HasForeignKey("JobId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("PARR.DAL.Models.JobStatus", "Status") + .WithMany("Journals") + .HasForeignKey("JobStatusId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Host"); + + b.Navigation("Job"); + + b.Navigation("Status"); + }); + + modelBuilder.Entity("PARR.DAL.Models.Application", b => + { + b.Navigation("Applications"); + + b.Navigation("ApplicationsInHosts"); + }); + + modelBuilder.Entity("PARR.DAL.Models.Host", b => + { + b.Navigation("ApplicationsInHosts"); + + b.Navigation("JobJournals"); + }); + + modelBuilder.Entity("PARR.DAL.Models.Job", b => + { + b.Navigation("Journals"); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobCategory", b => + { + b.Navigation("Jobs"); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobMode", b => + { + b.Navigation("Jobs"); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobStatus", b => + { + b.Navigation("Journals"); + }); + + modelBuilder.Entity("PARR.DAL.Models.JobType", b => + { + b.Navigation("Jobs"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/PARR.DAL/Migrations/20230620022903_TblStatus.cs b/PARR.DAL/Migrations/20230620022903_TblStatus.cs new file mode 100644 index 00000000..fcdfce3d --- /dev/null +++ b/PARR.DAL/Migrations/20230620022903_TblStatus.cs @@ -0,0 +1,40 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional + +namespace PARR.DAL.Migrations +{ + /// + public partial class TblStatus : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.InsertData( + table: "JobStatuses", + columns: new[] { "Id", "DateCreated", "DateModified", "Description", "Name" }, + values: new object[,] + { + { new Guid("7b945eb6-d885-4570-aff5-8866f1f75ff2"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "Задание выполнено", "finished" }, + { new Guid("edef6dc3-adad-4c77-8ad1-63bb9052355a"), new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), null, "Задание запущено", "started" } + }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DeleteData( + table: "JobStatuses", + keyColumn: "Id", + keyValue: new Guid("7b945eb6-d885-4570-aff5-8866f1f75ff2")); + + migrationBuilder.DeleteData( + table: "JobStatuses", + keyColumn: "Id", + keyValue: new Guid("edef6dc3-adad-4c77-8ad1-63bb9052355a")); + } + } +} diff --git a/PARR.DAL/Migrations/DataContextModelSnapshot.cs b/PARR.DAL/Migrations/DataContextModelSnapshot.cs index 2d76a45b..d7d3894b 100644 --- a/PARR.DAL/Migrations/DataContextModelSnapshot.cs +++ b/PARR.DAL/Migrations/DataContextModelSnapshot.cs @@ -181,6 +181,12 @@ namespace PARR.DAL.Migrations b.Property("DateModified") .HasColumnType("timestamp with time zone"); + b.Property("Frequency") + .HasColumnType("integer"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + b.Property("JobCategoryId") .HasColumnType("uuid"); @@ -198,6 +204,9 @@ namespace PARR.DAL.Migrations .IsRequired() .HasColumnType("text"); + b.Property("StartAt") + .HasColumnType("timestamp with time zone"); + b.HasKey("Id"); b.HasIndex("ApplicationId"); @@ -336,6 +345,22 @@ namespace PARR.DAL.Migrations b.HasKey("Id"); b.ToTable("JobStatuses"); + + b.HasData( + new + { + Id = new Guid("edef6dc3-adad-4c77-8ad1-63bb9052355a"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Description = "Задание запущено", + Name = "started" + }, + new + { + Id = new Guid("7b945eb6-d885-4570-aff5-8866f1f75ff2"), + DateCreated = new DateTimeOffset(new DateTime(2023, 5, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0)), + Description = "Задание выполнено", + Name = "finished" + }); }); modelBuilder.Entity("PARR.DAL.Models.JobType", b => @@ -362,35 +387,6 @@ namespace PARR.DAL.Migrations b.ToTable("JobTypes"); }); - modelBuilder.Entity("PARR.DAL.Models.Scheduler", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uuid"); - - b.Property("DateCreated") - .HasColumnType("timestamp with time zone"); - - b.Property("DateModified") - .HasColumnType("timestamp with time zone"); - - b.Property("Frequency") - .HasColumnType("integer"); - - b.Property("IsEnabled") - .HasColumnType("boolean"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("StartAt") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.ToTable("Schedulers"); - }); - modelBuilder.Entity("PARR.DAL.Models.Application", b => { b.HasOne("PARR.DAL.Models.Application", null) diff --git a/PARR.DAL/Models/Job.cs b/PARR.DAL/Models/Job.cs index 63b453ff..0b10d90c 100644 --- a/PARR.DAL/Models/Job.cs +++ b/PARR.DAL/Models/Job.cs @@ -30,8 +30,21 @@ namespace PARR.DAL.Models public Guid ApplicationId { get; set; } [ForeignKey(nameof(ApplicationId))] public Application? Application { get; set; } + /// + /// Частота запуска Job в минутах + /// + public int Frequency { get; set; } + /// + /// В режиме manual значит время регистрации регламентной работы АСУ ЕСПП, в auto - время старта Job. + /// + public DateTimeOffset StartAt { get; set; } + /// + /// Активация Job + /// + public bool IsEnabled { get; set; } + public ICollection Journals { get; set; } = new HashSet(); - + } } diff --git a/PARR.DAL/Models/Scheduler.cs b/PARR.DAL/Models/Scheduler.cs index a52f305d..9fa7ef66 100644 --- a/PARR.DAL/Models/Scheduler.cs +++ b/PARR.DAL/Models/Scheduler.cs @@ -4,16 +4,16 @@ using System.ComponentModel.DataAnnotations.Schema; namespace PARR.DAL.Models { - [Table("Schedulers")] - public class Scheduler : IBase - { - [Key] - public Guid Id { get; set; } - public DateTimeOffset DateCreated { get; set; } - public DateTimeOffset? DateModified { get; set; } - public string? Name { get; set; } - public int Frequency { get; set; } - public required DateTimeOffset StartAt { get; set; } - public bool IsEnabled { get; set; } - } + //[Table("Schedulers")] + //public class Scheduler : IBase + //{ + // //[Key] + // //public Guid Id { get; set; } + // //public DateTimeOffset DateCreated { get; set; } + // //public DateTimeOffset? DateModified { get; set; } + // //public string? Name { get; set; } + // //public int Frequency { get; set; } + // //public required DateTimeOffset StartAt { get; set; } + // //public bool IsEnabled { get; set; } + //} } diff --git a/PARR.DAL/ParrDalInstaller.cs b/PARR.DAL/ParrDalInstaller.cs index f6abe67b..949db860 100644 --- a/PARR.DAL/ParrDalInstaller.cs +++ b/PARR.DAL/ParrDalInstaller.cs @@ -19,7 +19,8 @@ namespace PARR.DAL services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); + services.AddTransient(); + //services.AddTransient(); //services.AddTransient(); } diff --git a/PARR.DAL/Services/Implementations/HostService.cs b/PARR.DAL/Services/Implementations/HostService.cs index 2d18e53d..5c50fb55 100644 --- a/PARR.DAL/Services/Implementations/HostService.cs +++ b/PARR.DAL/Services/Implementations/HostService.cs @@ -36,6 +36,7 @@ namespace PARR.DAL.Services.Implementations //} return await EntitySet .Include(t => t.ApplicationsInHosts).ThenInclude(a => a.Application).ThenInclude(t => t.ApplicationType) + .AsSplitQuery() .FirstOrDefaultAsync(h => h.IP == IP && h.RegionalEK == RegionalEK); } @@ -43,6 +44,7 @@ namespace PARR.DAL.Services.Implementations { return await EntitySet .Include(t => t.ApplicationsInHosts).ThenInclude(a => a.Application).ThenInclude(t => t.ApplicationType) + .AsSplitQuery() .FirstOrDefaultAsync(h => h.IP == IP && h.LinkEK == linkEK && h.RegionalEK == regionalEK); } diff --git a/PARR.DAL/Services/Implementations/SchedulerService.cs b/PARR.DAL/Services/Implementations/SchedulerService.cs index 69436876..1bbf1b18 100644 --- a/PARR.DAL/Services/Implementations/SchedulerService.cs +++ b/PARR.DAL/Services/Implementations/SchedulerService.cs @@ -7,16 +7,16 @@ using PARR.DAL.Services.Interfaces; namespace PARR.DAL.Services.Implementations { - internal class SchedulerService : BaseService, ISchedulerService - { - private readonly DataContext dataContext; + //internal class SchedulerService : BaseService, ISchedulerService + //{ + // private readonly DataContext dataContext; - public SchedulerService(DataContext dataContext, ILogger logger) : base(logger) - { - this.dataContext = dataContext; - } - protected override DbSet EntitySet => dataContext.Schedulers; + // public SchedulerService(DataContext dataContext, ILogger logger) : base(logger) + // { + // this.dataContext = dataContext; + // } + // protected override DbSet EntitySet => dataContext.Schedulers; - protected override DataContext EntitiContext => dataContext; - } + // protected override DataContext EntitiContext => dataContext; + //} } diff --git a/PARR.DAL/Services/Interfaces/ISchedulerService.cs b/PARR.DAL/Services/Interfaces/ISchedulerService.cs index 744f1fec..b8fcfb83 100644 --- a/PARR.DAL/Services/Interfaces/ISchedulerService.cs +++ b/PARR.DAL/Services/Interfaces/ISchedulerService.cs @@ -3,7 +3,7 @@ using PARR.DAL.Services.Interfaces.Base; namespace PARR.DAL.Services.Interfaces { - public interface ISchedulerService : IBaseService - { - } + //public interface ISchedulerService : IBaseService + //{ + //} }