diff --git a/PARR.API/Controllers/V1/RobotTaskController.cs b/PARR.API/Controllers/V1/RobotTaskController.cs index be5ce041..1e783fed 100644 --- a/PARR.API/Controllers/V1/RobotTaskController.cs +++ b/PARR.API/Controllers/V1/RobotTaskController.cs @@ -116,9 +116,17 @@ namespace PARR.API.Controllers.V1 .Include(t => t.Template) .ThenInclude(a => a!.Job) .ThenInclude(t => t!.Group) - .ThenInclude(t => t!.EsppSchValues) - .ThenInclude(t => t!.EsppSchTypeConfig) - .ThenInclude(t => t!.EsppSchTypeSchedule) + .ThenInclude(t => t!.EsppSchValues) + .ThenInclude(t => t!.EsppSchTypeConfig) + .ThenInclude(t => t!.EsppSchTypeSchedule) + .Include(t => t.Template) + .ThenInclude(t => t!.Job) + .ThenInclude(t => t!.Group) + .ThenInclude(t => t!.ScheduleExcludeType) + .Include(t => t.Template) + .ThenInclude(t => t!.Job) + .ThenInclude(t => t!.Group) + .ThenInclude(t => t.ScheduleExcludeTypeCalendar) .Include(t => t.Template) .ThenInclude(t => t.UnitsInTemplate); diff --git a/PARR.API/MappingProfiles/DomainToResponseProfile.cs b/PARR.API/MappingProfiles/DomainToResponseProfile.cs index 04bfdfb8..a7064703 100644 --- a/PARR.API/MappingProfiles/DomainToResponseProfile.cs +++ b/PARR.API/MappingProfiles/DomainToResponseProfile.cs @@ -227,8 +227,10 @@ namespace PARR.API.MappingProfiles .ForMember(d => d.TemplateName, o => o.MapFrom(s => s.Template!.Name)) .ForMember(d => d.TemplateId, o => o.MapFrom(s => s.Template!.Id)) .ForMember(d => d.WorkGroup, o => o.MapFrom(s => s.Template!.Job!.WorkGroupMask)) - .ForMember(d => d.Exclude, o => o.MapFrom()) - .ForMember(d => d.ExcludeCalendar, o => o.MapFrom()) + //.ForMember(d => d.Exclude, o => o.MapFrom()) + .ForMember(d => d.Exclude, o => o.MapFrom(s => s.Template!.Job!.Group!.ScheduleExcludeType!.EsppName)) + //.ForMember(d => d.ExcludeCalendar, o => o.MapFrom()) + .ForMember(d => d.ExcludeCalendar, o => o.MapFrom(s => s.Template!.Job!.Group!.ScheduleExcludeTypeCalendar != null ? s.Template!.Job!.Group!.ScheduleExcludeTypeCalendar.EsppName : null)) .ForMember(d => d.Timezone, o => o.MapFrom()) .ForMember(d => d.RepeatRange, o => o.MapFrom()) //todo: GenerationTime diff --git a/PARR.API/MappingProfiles/Resolvers/RobotTaskScheduleExcludeCalendarResolver.cs b/PARR.API/MappingProfiles/Resolvers/RobotTaskScheduleExcludeCalendarResolver.cs index 4813fd9b..37c9ca28 100644 --- a/PARR.API/MappingProfiles/Resolvers/RobotTaskScheduleExcludeCalendarResolver.cs +++ b/PARR.API/MappingProfiles/Resolvers/RobotTaskScheduleExcludeCalendarResolver.cs @@ -5,18 +5,18 @@ using PARR.DAL.Models; namespace PARR.API.MappingProfiles.Resolvers { - public class RobotTaskScheduleExcludeCalendarResolver : IValueResolver - { - private readonly SettingsFromDb settingsFromDb; + //public class RobotTaskScheduleExcludeCalendarResolver : IValueResolver + //{ + // private readonly SettingsFromDb settingsFromDb; - public RobotTaskScheduleExcludeCalendarResolver(SettingsFromDb settingsFromDb) - { - this.settingsFromDb = settingsFromDb; - } + // public RobotTaskScheduleExcludeCalendarResolver(SettingsFromDb settingsFromDb) + // { + // this.settingsFromDb = settingsFromDb; + // } - public string? Resolve(RobotConfiguration source, RobotTaskScheduleResponse destination, string? destMember, ResolutionContext context) - { - return settingsFromDb.ScheduleExcludeCalendar; - } - } + // public string? Resolve(RobotConfiguration source, RobotTaskScheduleResponse destination, string? destMember, ResolutionContext context) + // { + // return settingsFromDb.ScheduleExcludeCalendar; + // } + //} } diff --git a/PARR.API/MappingProfiles/Resolvers/RobotTaskScheduleExcludeResolver.cs b/PARR.API/MappingProfiles/Resolvers/RobotTaskScheduleExcludeResolver.cs index 5d6b8387..5ac8cc0f 100644 --- a/PARR.API/MappingProfiles/Resolvers/RobotTaskScheduleExcludeResolver.cs +++ b/PARR.API/MappingProfiles/Resolvers/RobotTaskScheduleExcludeResolver.cs @@ -5,18 +5,18 @@ using PARR.DAL.Models; namespace PARR.API.MappingProfiles.Resolvers { - public class RobotTaskScheduleExcludeResolver : IValueResolver - { - private readonly SettingsFromDb settingsFromDb; + //public class RobotTaskScheduleExcludeResolver : IValueResolver + //{ + // private readonly SettingsFromDb settingsFromDb; - public RobotTaskScheduleExcludeResolver(SettingsFromDb settingsFromDb) - { - this.settingsFromDb = settingsFromDb; - } + // public RobotTaskScheduleExcludeResolver(SettingsFromDb settingsFromDb) + // { + // this.settingsFromDb = settingsFromDb; + // } - public string Resolve(RobotConfiguration source, RobotTaskScheduleResponse destination, string destMember, ResolutionContext context) - { - return settingsFromDb.ScheduleExcludeType; - } - } + // public string Resolve(RobotConfiguration source, RobotTaskScheduleResponse destination, string destMember, ResolutionContext context) + // { + // return settingsFromDb.ScheduleExcludeType; + // } + //} } diff --git a/PARR.DAL/Context/DataContext.cs b/PARR.DAL/Context/DataContext.cs index 8a59cd19..6c1c3ec1 100644 --- a/PARR.DAL/Context/DataContext.cs +++ b/PARR.DAL/Context/DataContext.cs @@ -5,6 +5,7 @@ using PARR.DAL.Contracts; using PARR.DAL.Extensions; using PARR.DAL.Models; using PARR.DAL.Models.Job; +using PARR.DAL.Models.Schedule; using PARR.DAL.Models.Unit; namespace PARR.DAL.Context @@ -42,12 +43,19 @@ namespace PARR.DAL.Context public DbSet RobotConfigurations { get; set; } public DbSet RobotHistories { get; set; } + #region Schedule + public DbSet EsppSchTypes { get; set; } public DbSet EsppSchTypeValues { get; set; } public DbSet EsppSchTypeConfigs { get; set; } public DbSet EsppSchTypeSchedules { get; set; } public DbSet EsppSchValues { get; set; } + public DbSet ScheduleExcludeTypeCalendars { get; set; } + public DbSet ScheduleExcludeTypes { get; set; } + + #endregion + public DbSet AgentHistories { get; set; } public DbSet AgentHistoryLevels { get; set; } @@ -179,8 +187,8 @@ namespace PARR.DAL.Context new { Name = nameof(SettingsFromDb.RobotAttemptsNumber), Description = "Количество попыток выполнения задания роботом", Value = "3" }, new { Name = nameof(SettingsFromDb.RobotWaitTime), Description = "Время ожидания выполнения роботом задания", Value = "00:15:00" }, new { Name = nameof(SettingsFromDb.ScheduleTimezone), Description = "Расписание регламентной работы - В каком часовом поясе", Value = "MSK" }, - new { Name = nameof(SettingsFromDb.ScheduleExcludeType), Description = "Расписание регламентной работы - Тип исключения", Value = "Выполнить ТОЛЬКО В указанном календаре" }, - new { Name = nameof(SettingsFromDb.ScheduleExcludeCalendar), Description = "Расписание регламентной работы - Календарь", Value = "8x5 (8.00-17.00)" }, + //new { Name = nameof(SettingsFromDb.ScheduleExcludeType), Description = "Расписание регламентной работы - Тип исключения", Value = "Выполнить ТОЛЬКО В указанном календаре" }, + //new { Name = nameof(SettingsFromDb.ScheduleExcludeCalendar), Description = "Расписание регламентной работы - Календарь", Value = "8x5 (8.00-17.00)" }, new { Name = nameof(SettingsFromDb.ScheduleRepeatRange), Description = "Расписание регламентной работы - Диапазн повторов", Value = "Отсутствует дата завершения" }, new { Name = nameof(SettingsFromDb.OrderSearchDeltaDate), Description = "Промежуток времени для поиска нарядов в ЕСПП", Value = new TimeSpan(1, 30, 0).ToString() }, new { Name = nameof(SettingsFromDb.EsppRobotAccountTimeZoneHour), Description = "Таймзона УЗ роботов в ЕСПП, в часах (может быть положительная и отрицательная)", Value = "3" }, @@ -195,7 +203,7 @@ namespace PARR.DAL.Context new TemplateNameConstantPart { Name = "П-2", Value = "ПАРР" } }.ToJson() }, - new { Name = nameof(SettingsFromDb.EsppUnitTag), Description = "Префикс тега в поле ЭК \"Дополнительная информация\"", Value = "ПАРР-" } + new { Name = nameof(SettingsFromDb.EsppUnitTag), Description = "Префикс тега в поле ЭК \"Дополнительная информация\"", Value = "ПАРР_" } ); }); #endregion @@ -514,6 +522,31 @@ namespace PARR.DAL.Context #endregion + #region ScheduleExcludeType + + modelBuilder.Entity(f => + { + f.HasData( + new() { Id = new Guid("0595B8E0-F322-4661-B5E3-064AF8FBE7CD"), DateCreated = dateCreated, Title = "Нет исключений", EsppName = "Нет исключений", EsppValue = "NONE", Code = ScheduleExcludeTypeEnum.None.ToString() }, + new() { Id = new Guid("2B7A4356-9AAF-4E00-B444-42F0B5010E25"), DateCreated = dateCreated, Title = "Выполнить ТОЛЬКО В указанном календаре", EsppName = "Выполнить ТОЛЬКО В указанном календаре", EsppValue = "ONLY", Code = ScheduleExcludeTypeEnum.Only.ToString() }, + new() { Id = new Guid("38CD9E64-27C1-4672-A805-2211952A48BD"), DateCreated = dateCreated, Title = "Выполнить везде, КРОМЕ указанного календаря", EsppName = "Выполнить везде, КРОМЕ указанного календаря", EsppValue = "EXCEPT", Code = ScheduleExcludeTypeEnum.Except.ToString() } + ); + }); + + #endregion + + #region ScheduleExcludeTypeCalendar + + modelBuilder.Entity(f => + { + f.HasData( + new() { Id = new Guid("A26EDB88-0267-4FBF-B7EC-D172B0A86C9C"), DateCreated = dateCreated, Title = "24x5", EsppName = "24x5", EsppValue = "24x5", Code = "24x5" }, + new() { Id = new Guid("6834F1D5-AC51-43D5-974E-4C759D7BBF9F"), DateCreated = dateCreated, Title = "24x7", EsppName = "24x7", EsppValue = "24x7", Code = "24x7" } + ); + }); + + #endregion + } //protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) diff --git a/PARR.DAL/Context/DataContextSettings.cs b/PARR.DAL/Context/DataContextSettings.cs index 665924f5..e0539407 100644 --- a/PARR.DAL/Context/DataContextSettings.cs +++ b/PARR.DAL/Context/DataContextSettings.cs @@ -13,5 +13,10 @@ /// public const string Job = "job"; + + /// + /// Расписание регламентных работ + /// + public const string Schedule = "schedule"; } } diff --git a/PARR.DAL/Contracts/ScheduleExcludeTypeEnum.cs b/PARR.DAL/Contracts/ScheduleExcludeTypeEnum.cs new file mode 100644 index 00000000..64cde643 --- /dev/null +++ b/PARR.DAL/Contracts/ScheduleExcludeTypeEnum.cs @@ -0,0 +1,23 @@ +namespace PARR.DAL.Contracts +{ + /// + /// Расписание регламентной работы - Тип исключения + /// + public enum ScheduleExcludeTypeEnum + { + /// + /// Нет исключений + /// + None = 0, + + /// + /// Выполнить ТОЛЬКО В указанном календаре + /// + Only = 1, + + /// + /// Выполнить везде, КРОМЕ указанного календаря + /// + Except = 2 + } +} diff --git a/PARR.DAL/Contracts/SettingsFromDb.cs b/PARR.DAL/Contracts/SettingsFromDb.cs index 6f0191eb..dff990eb 100644 --- a/PARR.DAL/Contracts/SettingsFromDb.cs +++ b/PARR.DAL/Contracts/SettingsFromDb.cs @@ -82,15 +82,15 @@ namespace PARR.DAL.Contracts /// public string ScheduleTimezone { get; set; } = string.Empty; - /// - /// Расписание регламентной работы - Тип исключения - /// - public string ScheduleExcludeType { get; set; } = string.Empty; + ///// + ///// Расписание регламентной работы - Тип исключения + ///// + //public string ScheduleExcludeType { get; set; } = string.Empty; - /// - /// Расписание регламентной работы - Календарь - /// - public string ScheduleExcludeCalendar { get; set; } = string.Empty; + ///// + ///// Расписание регламентной работы - Календарь + ///// + //public string ScheduleExcludeCalendar { get; set; } = string.Empty; /// /// Расписание регламентной работы - Диапазн повторов diff --git a/PARR.DAL/Models/EsppSchValue.cs b/PARR.DAL/Models/EsppSchValue.cs index 7ec00f6c..81bca7a4 100644 --- a/PARR.DAL/Models/EsppSchValue.cs +++ b/PARR.DAL/Models/EsppSchValue.cs @@ -1,5 +1,6 @@ using Microsoft.EntityFrameworkCore; using PARR.DAL.Models.Job; +using PARR.DAL.Models.Schedule; using System.ComponentModel.DataAnnotations.Schema; namespace PARR.DAL.Models @@ -21,6 +22,7 @@ namespace PARR.DAL.Models public Guid JobGroupId { get; set; } + //[ForeignKey(nameof(ApplicationsInWorkId))] //public ApplicationsInWork? ApplicationsInWork { get; set; } diff --git a/PARR.DAL/Models/Job/JobFieldFilter.cs b/PARR.DAL/Models/Job/JobFieldFilter.cs index 30e8faa2..c1ebc9e7 100644 --- a/PARR.DAL/Models/Job/JobFieldFilter.cs +++ b/PARR.DAL/Models/Job/JobFieldFilter.cs @@ -24,6 +24,11 @@ namespace PARR.DAL.Models.Job public required string ValueMask { get; set; } + /// + /// Отсутствует + /// + public bool IsInverse { get; set; } = false; + [ForeignKey(nameof(FieldId))] public UnitField? UnitField { get; set; } diff --git a/PARR.DAL/Models/Job/JobGroup.cs b/PARR.DAL/Models/Job/JobGroup.cs index b6c6d670..ac21f379 100644 --- a/PARR.DAL/Models/Job/JobGroup.cs +++ b/PARR.DAL/Models/Job/JobGroup.cs @@ -1,6 +1,7 @@ using Microsoft.EntityFrameworkCore; using PARR.DAL.Context; using PARR.DAL.Models.Base; +using PARR.DAL.Models.Schedule; using PARR.DAL.Models.Unit; using PARR.DAL.Settings; using System.ComponentModel.DataAnnotations; @@ -128,6 +129,19 @@ namespace PARR.DAL.Models.Job /// public Guid? GroupingUnitFieldId { get; set; } + + /// + /// Расписание регламентной работы - Тип исключения + /// + public Guid ScheduleExcludeTypeId { get; set; } + + /// + /// Расписание регламентной работы, исключение - Календарь + /// + public Guid? ScheduleExcludeTypeCalendarId { get; set; } + + + /// /// Поле по которому группируется (!!!отключено каскадное удаление!!!) /// @@ -140,5 +154,11 @@ namespace PARR.DAL.Models.Job public ICollection Jobs { get; set; } = new HashSet(); public ICollection EsppSchValues { get; set; } = new HashSet(); + + [ForeignKey(nameof(ScheduleExcludeTypeId))] + public ScheduleExcludeType? ScheduleExcludeType { get; set; } + + [ForeignKey(nameof(ScheduleExcludeTypeCalendarId))] + public ScheduleExcludeTypeCalendar? ScheduleExcludeTypeCalendar { get; set; } } } diff --git a/PARR.DAL/Models/Schedule/ScheduleExcludeType.cs b/PARR.DAL/Models/Schedule/ScheduleExcludeType.cs new file mode 100644 index 00000000..790af38a --- /dev/null +++ b/PARR.DAL/Models/Schedule/ScheduleExcludeType.cs @@ -0,0 +1,38 @@ +using Microsoft.EntityFrameworkCore; +using PARR.DAL.Context; +using PARR.DAL.Models.Base; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace PARR.DAL.Models.Schedule +{ + /// + /// Расписание регламентной работы - Тип исключения + /// + [Table("ExcludeTypes", Schema = DataContextSettings.Schedule)] + [Comment("Расписание регламентной работы - Тип исключения")] + public class ScheduleExcludeType : IBase + { + [Key] + public Guid Id { get; set; } + + public DateTimeOffset DateCreated { get; set; } + + [NotMapped] + public DateTimeOffset? DateModified { get; set; } + + /// + /// Название в ПАРР + /// + public required string Title { get; set; } + + public required string EsppName { get; set; } + + public required string EsppValue { get; set; } + + public required string Code { get; set; } + + + + } +} diff --git a/PARR.DAL/Models/Schedule/ScheduleExcludeTypeCalendar.cs b/PARR.DAL/Models/Schedule/ScheduleExcludeTypeCalendar.cs new file mode 100644 index 00000000..56d552db --- /dev/null +++ b/PARR.DAL/Models/Schedule/ScheduleExcludeTypeCalendar.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore; +using PARR.DAL.Context; +using PARR.DAL.Models.Base; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace PARR.DAL.Models.Schedule +{ + /// + /// Расписание регламентной работы, исключение - Календарь + /// + [Table("ExcludeTypeCalendars", Schema = DataContextSettings.Schedule)] + [Comment("Расписание регламентной работы, исключение - Календарь")] + public class ScheduleExcludeTypeCalendar : IBase + { + [Key] + public Guid Id { get; set; } + + public DateTimeOffset DateCreated { get; set; } + + [NotMapped] + public DateTimeOffset? DateModified { get; set; } + + /// + /// Название в ПАРР + /// + public required string Title { get; set; } + + public required string EsppName { get; set; } + + public required string EsppValue { get; set; } + + public required string Code { get; set; } + + } +} diff --git a/PARR.DAL/ParrDalInstaller.cs b/PARR.DAL/ParrDalInstaller.cs index b9d59163..7e297de7 100644 --- a/PARR.DAL/ParrDalInstaller.cs +++ b/PARR.DAL/ParrDalInstaller.cs @@ -12,9 +12,11 @@ using PARR.DAL.InfluxDbServices; using PARR.DAL.Services.Implementation; using PARR.DAL.Services.Implementations; using PARR.DAL.Services.Implementations.Job; +using PARR.DAL.Services.Implementations.Schedule; using PARR.DAL.Services.Implementations.Unit; using PARR.DAL.Services.Interfaces; using PARR.DAL.Services.Interfaces.Job; +using PARR.DAL.Services.Interfaces.Schedule; using PARR.DAL.Services.Interfaces.Unit; using PARR.DAL.Settings; using PARR.DAL.TransformServices; @@ -99,6 +101,13 @@ namespace PARR.DAL services.AddTransient(); services.AddTransient(); + #region Schedule + + services.AddTransient(); + services.AddTransient(); + + #endregion + #region Unit services.AddTransient(); diff --git a/PARR.DAL/Services/Implementations/EsppSchTypeConfigService.cs b/PARR.DAL/Services/Implementations/EsppSchTypeConfigService.cs index 628eabc0..0716c4c9 100644 --- a/PARR.DAL/Services/Implementations/EsppSchTypeConfigService.cs +++ b/PARR.DAL/Services/Implementations/EsppSchTypeConfigService.cs @@ -60,7 +60,8 @@ namespace PARR.DAL.Services.Implementations Order = t.Order, Type = t.Type, Value = t.Value - }).ToList() + } + ).ToList() }; return dto; diff --git a/PARR.DAL/Services/Implementations/Schedule/ScheduleExcludeTypeCalendarService.cs b/PARR.DAL/Services/Implementations/Schedule/ScheduleExcludeTypeCalendarService.cs new file mode 100644 index 00000000..2c0f1fe5 --- /dev/null +++ b/PARR.DAL/Services/Implementations/Schedule/ScheduleExcludeTypeCalendarService.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using PARR.DAL.Context; +using PARR.DAL.Models.Schedule; +using PARR.DAL.Services.Abstracts; +using PARR.DAL.Services.Interfaces.Schedule; + +namespace PARR.DAL.Services.Implementations.Schedule +{ + internal class ScheduleExcludeTypeCalendarService : BaseService, IScheduleExcludeTypeCalendarService + { + private readonly DataContext dataContext; + + protected override DbSet EntitySet => dataContext.ScheduleExcludeTypeCalendars; + + protected override DataContext EntitiContext => dataContext; + + public ScheduleExcludeTypeCalendarService(DataContext dataContext, ILogger logger) : base(logger) + { + this.dataContext = dataContext; + } + } +} diff --git a/PARR.DAL/Services/Implementations/Schedule/ScheduleExcludeTypeService.cs b/PARR.DAL/Services/Implementations/Schedule/ScheduleExcludeTypeService.cs new file mode 100644 index 00000000..5272305d --- /dev/null +++ b/PARR.DAL/Services/Implementations/Schedule/ScheduleExcludeTypeService.cs @@ -0,0 +1,23 @@ +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using PARR.DAL.Context; +using PARR.DAL.Models.Schedule; +using PARR.DAL.Services.Abstracts; +using PARR.DAL.Services.Interfaces.Schedule; + +namespace PARR.DAL.Services.Implementations.Schedule +{ + internal class ScheduleExcludeTypeService : BaseService, IScheduleExcludeTypeService + { + private readonly DataContext dataContext; + + protected override DbSet EntitySet => dataContext.ScheduleExcludeTypes; + + protected override DataContext EntitiContext => dataContext; + + public ScheduleExcludeTypeService(DataContext dataContext, ILogger logger) : base(logger) + { + this.dataContext = dataContext; + } + } +} diff --git a/PARR.DAL/Services/Interfaces/Schedule/IScheduleExcludeTypeCalendar.cs b/PARR.DAL/Services/Interfaces/Schedule/IScheduleExcludeTypeCalendar.cs new file mode 100644 index 00000000..121641f1 --- /dev/null +++ b/PARR.DAL/Services/Interfaces/Schedule/IScheduleExcludeTypeCalendar.cs @@ -0,0 +1,9 @@ +using PARR.DAL.Models.Schedule; +using PARR.DAL.Services.Interfaces.Base; + +namespace PARR.DAL.Services.Interfaces.Schedule +{ + public interface IScheduleExcludeTypeCalendarService: IBaseService + { + } +} diff --git a/PARR.DAL/Services/Interfaces/Schedule/IScheduleExcludeTypeService.cs b/PARR.DAL/Services/Interfaces/Schedule/IScheduleExcludeTypeService.cs new file mode 100644 index 00000000..8c2c7c02 --- /dev/null +++ b/PARR.DAL/Services/Interfaces/Schedule/IScheduleExcludeTypeService.cs @@ -0,0 +1,9 @@ +using PARR.DAL.Models.Schedule; +using PARR.DAL.Services.Interfaces.Base; + +namespace PARR.DAL.Services.Interfaces.Schedule +{ + public interface IScheduleExcludeTypeService : IBaseService + { + } +} diff --git a/PARR.EsppScheduleSync/ScheduleSyncher.cs b/PARR.EsppScheduleSync/ScheduleSyncher.cs index 08b44314..0bf4b19b 100644 --- a/PARR.EsppScheduleSync/ScheduleSyncher.cs +++ b/PARR.EsppScheduleSync/ScheduleSyncher.cs @@ -104,8 +104,8 @@ namespace PARR.EsppScheduleSync //WorkGroup = template.Host!.WorkGroup!.Name,//TODO Migration to job //Мы решили, что для всех расписаний "Нет исключений", если что-то поменяется, тут нужно переделать //TypeV60calendar = settingsFromDb.ScheduleExcludeType == "Нет исключений" ? "NONE" : "", - TypeV60calendar = GetTypeV60calendar(), - V60calendar = settingsFromDb.ScheduleExcludeCalendar, + TypeV60calendar = GetTypeV60calendar(template), + V60calendar = GetV60calendar(template), //Scheduled = EsppScheduleHelpers.GetNextRun(template.NextRun), //Scheduled = EsppScheduleHelpers.GetNextRun(nextRunModifierService.GetNextRunByAccountRobotTimeZone(template.NextRun)), //BasisTime = EsppScheduleHelpers.GetGenerationTime(nextRunModifierService.GetNextRunByAccountRobotTimeZone(template.NextRun)), @@ -122,22 +122,61 @@ namespace PARR.EsppScheduleSync } + /// + /// Получить исключение - Календарь + /// + /// + /// + private string GetV60calendar(Template template) + { + // мы знаем, что у нас точно в шаблоне есть инклуды до ScheduleExcludeType и ScheduleExcludeTypeCalendar + if (template.Job?.Group?.ScheduleExcludeTypeCalendar == null) + { + logger.LogDebug("Для шаблона шаблона {templte}, {templateId} нет исключений календаря", template.Name, template.Id); + + //TODO:!!!!!!!!!!! Вот тут null или string.Empty??? Спросить у Андрея что он нам вернет! + + return string.Empty; + } + + logger.LogDebug("Для шаблона шаблона {templte}, {templateId} установлено исключений календаря \"{name}\", EsppValue: {esppValue}", template.Name, template.Id, template.Job.Group.ScheduleExcludeTypeCalendar.Name, template.Job.Group.ScheduleExcludeTypeCalendar.EsppValue); + + return template.Job.Group.ScheduleExcludeTypeCalendar.EsppValue; + } + + /// /// Получить тип календаря /// /// - private string GetTypeV60calendar() + private string GetTypeV60calendar(Template template) { - // Это костыль, нужно придумать как это хранить в БД. - switch (settingsFromDb.ScheduleExcludeType.ToLower()) + // мы знаем, что у нас точно в шаблоне есть инклуды до ScheduleExcludeType и ScheduleExcludeTypeCalendar + + // на всякий конечно же проверим + if (template.Job?.Group?.ScheduleExcludeType == null) { - case ("нет исключений"): - return "NONE"; - case ("выполнить только в указанном календаре"): - return "ONLY"; - default: - return ""; + logger.LogError("Для шаблона {templte}, {templateId} не смог получить тип исключения, установил значение по умолчанию \"Без исключения\"", template.Name, template.Id); + return "NONE"; } + + logger.LogDebug("Для шаблона шаблона {templte}, {templateId} тип исключения \"{name}\", EsppValue: {esppValue}", template.Name, template.Id, template.Job.Group.ScheduleExcludeType.Name, template.Job.Group.ScheduleExcludeType.EsppValue); + + return template.Job.Group.ScheduleExcludeType.EsppValue; + + + #region old logic + //// Это костыль, нужно придумать как это хранить в БД. + //switch (settingsFromDb.ScheduleExcludeType.ToLower()) + //{ + // case ("нет исключений"): + // return "NONE"; + // case ("выполнить только в указанном календаре"): + // return "ONLY"; + // default: + // return ""; + //} + #endregion } diff --git a/PARR.EsppSync/SyncService.cs b/PARR.EsppSync/SyncService.cs index 3f72c19a..19b37448 100644 --- a/PARR.EsppSync/SyncService.cs +++ b/PARR.EsppSync/SyncService.cs @@ -63,6 +63,12 @@ namespace PARR.EsppSync .Include(t => t.Job) .ThenInclude(j => j.Group) .ThenInclude(g => g.GroupType) + .Include(t => t.Job) + .ThenInclude(t => t.Group) + .ThenInclude(t => t.ScheduleExcludeType) + .Include(t => t.Job) + .ThenInclude(t => t.Group) + .ThenInclude(t => t.ScheduleExcludeTypeCalendar) .Include(t => t.Job) .ThenInclude(j => j.Tnk) .Include(t => t.UnitsInTemplate);