From 3a1e16a7a05c8bdc0b28e58824b78b2f3e87c013 Mon Sep 17 00:00:00 2001 From: TekH Date: Sun, 12 Jul 2026 00:04:40 +0200 Subject: [PATCH] feat: Update Application layer for Hangfire integration - Add CronSchedule property to CfgProfileDto for scheduling support - Create ProfileSqlJobDto for SQL job execution data transfer - Update TriggeringDEXJobBatchCommand to accept ProfileId and Jobs collection - Make TriggeringDEXJobBatchCommand public for Hangfire job activation - Update Application DependencyInjection with required service registrations --- .../Common/Dtos/CfgProfileDto.cs | 53 +------------------ .../Common/Dtos/ProfileSqlJobDto.cs | 53 +++++++++++++++++++ .../Commands/TriggeringDEXJobBatchCommand.cs | 2 +- .../DependencyInjection.cs | 7 ++- 4 files changed, 61 insertions(+), 54 deletions(-) create mode 100644 ECMJobRunner.Application/Common/Dtos/ProfileSqlJobDto.cs diff --git a/ECMJobRunner.Application/Common/Dtos/CfgProfileDto.cs b/ECMJobRunner.Application/Common/Dtos/CfgProfileDto.cs index 893b384..d64f40b 100644 --- a/ECMJobRunner.Application/Common/Dtos/CfgProfileDto.cs +++ b/ECMJobRunner.Application/Common/Dtos/CfgProfileDto.cs @@ -7,7 +7,7 @@ namespace ECMJobRunner.Application.Common.Dtos /// Data Transfer Object for CfgProfile entity /// Used for querying and returning profile data /// - public class CfgProfileDto + public record CfgProfileDto { /// /// Profile ID @@ -64,55 +64,4 @@ namespace ECMJobRunner.Application.Common.Dtos /// public List? SqlJobs { get; set; } } - - /// - /// Data Transfer Object for ProfileSqlJob entity - /// - public class ProfileSqlJobDto - { - /// - /// SQL Job ID - /// - public long Id { get; set; } - - /// - /// Profile ID (foreign key) - /// - public long ProfileId { get; set; } - - /// - /// Active / Inactive switch - /// - public bool Active { get; set; } - - /// - /// Execution sequence order - /// - public short Sequence { get; set; } - - /// - /// Job name - /// - public string? Name { get; set; } - - /// - /// SQL query for pre-check validation - /// - public string? SqlCheckQuery { get; set; } - - /// - /// Main SQL query to execute - /// - public string? SqlMainQuery { get; set; } - - /// - /// API command to execute - /// - public string? ApiCommand { get; set; } - - /// - /// Optional description - /// - public string? Comment { get; set; } - } } diff --git a/ECMJobRunner.Application/Common/Dtos/ProfileSqlJobDto.cs b/ECMJobRunner.Application/Common/Dtos/ProfileSqlJobDto.cs new file mode 100644 index 0000000..63bd731 --- /dev/null +++ b/ECMJobRunner.Application/Common/Dtos/ProfileSqlJobDto.cs @@ -0,0 +1,53 @@ +namespace ECMJobRunner.Application.Common.Dtos +{ + /// + /// Data Transfer Object for ProfileSqlJob entity + /// + public class ProfileSqlJobDto + { + /// + /// SQL Job ID + /// + public long Id { get; set; } + + /// + /// Profile ID (foreign key) + /// + public long ProfileId { get; set; } + + /// + /// Active / Inactive switch + /// + public bool Active { get; set; } + + /// + /// Execution sequence order + /// + public short Sequence { get; set; } + + /// + /// Job name + /// + public string? Name { get; set; } + + /// + /// SQL query for pre-check validation + /// + public string? SqlCheckQuery { get; set; } + + /// + /// Main SQL query to execute + /// + public string? SqlMainQuery { get; set; } + + /// + /// API command to execute + /// + public string? ApiCommand { get; set; } + + /// + /// Optional description + /// + public string? Comment { get; set; } + } +} diff --git a/ECMJobRunner.Application/DEXJob/Commands/TriggeringDEXJobBatchCommand.cs b/ECMJobRunner.Application/DEXJob/Commands/TriggeringDEXJobBatchCommand.cs index cf4c28f..91fb1f0 100644 --- a/ECMJobRunner.Application/DEXJob/Commands/TriggeringDEXJobBatchCommand.cs +++ b/ECMJobRunner.Application/DEXJob/Commands/TriggeringDEXJobBatchCommand.cs @@ -17,7 +17,7 @@ namespace ECMJobRunner.Application.DEXJob.Commands /// /// Profile ID to trigger all associated SQL jobs /// - public int ProfileId { get; set; } + public long ProfileId { get; set; } } /// diff --git a/ECMJobRunner.Application/DependencyInjection.cs b/ECMJobRunner.Application/DependencyInjection.cs index 060e1b9..f387338 100644 --- a/ECMJobRunner.Application/DependencyInjection.cs +++ b/ECMJobRunner.Application/DependencyInjection.cs @@ -1,6 +1,7 @@ using ECMJobRunner.Application.Behaviors; using MediatR; using Microsoft.Extensions.DependencyInjection; +using ReC.Client; using System.Reflection; namespace ECMJobRunner.Application @@ -16,7 +17,7 @@ namespace ECMJobRunner.Application /// /// The service collection /// The service collection for chaining - public static IServiceCollection AddApplication(this IServiceCollection services) + public static IServiceCollection AddJobRunnerServices(this IServiceCollection services, string recClientApiUrl) { var assembly = Assembly.GetExecutingAssembly(); @@ -26,6 +27,10 @@ namespace ECMJobRunner.Application #else services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(assembly)); #endif + services.AddRecClient(recClientApiUrl, opt => + { + opt.LogSuccessfulRequests = true; + }); // Register pipeline behaviors in execution order // Order matters: MainQuery -> CheckQuery -> ReCRequest