From 7e267b427e3f5712fcdbb079686f25a7652232e1 Mon Sep 17 00:00:00 2001 From: TekH Date: Sat, 11 Jul 2026 12:38:21 +0200 Subject: [PATCH] feat: add DEX job common infrastructure Add foundational types for DEX job execution: Constants: - ErrorAction enum (Ignore, Stop) for error handling strategy DTOs: - CheckQueryResult: check query execution result with ReturnValue - MainQueryResult: main query execution result with ReturnValue Interfaces: - ISQLExecutor: abstraction for SQL query execution and DTO mapping All types include comprehensive XML documentation --- .../Common/Constants/ErrorAction.cs | 18 +++++++++++++++++ .../Common/Dtos/CheckQueryResult.cs | 16 +++++++++++++++ .../Common/Dtos/MainQueryResult.cs | 16 +++++++++++++++ .../Common/Interfaces/ISQLExecutor.cs | 20 +++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 ECMJobRunner.Application/Common/Constants/ErrorAction.cs create mode 100644 ECMJobRunner.Application/Common/Dtos/CheckQueryResult.cs create mode 100644 ECMJobRunner.Application/Common/Dtos/MainQueryResult.cs create mode 100644 ECMJobRunner.Application/Common/Interfaces/ISQLExecutor.cs diff --git a/ECMJobRunner.Application/Common/Constants/ErrorAction.cs b/ECMJobRunner.Application/Common/Constants/ErrorAction.cs new file mode 100644 index 0000000..6575895 --- /dev/null +++ b/ECMJobRunner.Application/Common/Constants/ErrorAction.cs @@ -0,0 +1,18 @@ +namespace ECMJobRunner.Application.Common.Constants +{ + /// + /// Defines actions to take when an error occurs during job execution + /// + public enum ErrorAction + { + /// + /// Ignore the error and continue execution + /// + Ignore, + + /// + /// Stop execution and throw an exception + /// + Stop, + } +} diff --git a/ECMJobRunner.Application/Common/Dtos/CheckQueryResult.cs b/ECMJobRunner.Application/Common/Dtos/CheckQueryResult.cs new file mode 100644 index 0000000..6629b40 --- /dev/null +++ b/ECMJobRunner.Application/Common/Dtos/CheckQueryResult.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace ECMJobRunner.Application.Common.Dtos +{ + /// + /// Result of a check query execution + /// + public class CheckQueryResult + { + /// + /// Return value from the check query (expected: > 0 for success) + /// + [Column("Return Value")] + public int? ReturnValue { get; set; } + } +} diff --git a/ECMJobRunner.Application/Common/Dtos/MainQueryResult.cs b/ECMJobRunner.Application/Common/Dtos/MainQueryResult.cs new file mode 100644 index 0000000..82d2fdf --- /dev/null +++ b/ECMJobRunner.Application/Common/Dtos/MainQueryResult.cs @@ -0,0 +1,16 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace ECMJobRunner.Application.Common.Dtos +{ + /// + /// Result of a main query execution + /// + public class MainQueryResult + { + /// + /// Return value from the main query (expected: null for success) + /// + [Column("Return Value")] + public int? ReturnValue { get; set; } + } +} diff --git a/ECMJobRunner.Application/Common/Interfaces/ISQLExecutor.cs b/ECMJobRunner.Application/Common/Interfaces/ISQLExecutor.cs new file mode 100644 index 0000000..d14b0e8 --- /dev/null +++ b/ECMJobRunner.Application/Common/Interfaces/ISQLExecutor.cs @@ -0,0 +1,20 @@ +using System.Threading; +using System.Threading.Tasks; + +namespace ECMJobRunner.Application.Common.Interfaces +{ + /// + /// Interface for executing SQL queries and mapping results to DTOs + /// + public interface ISQLExecutor + { + /// + /// Executes a SQL query and maps the result to the specified type + /// + /// The type to map the query result to + /// The SQL query to execute + /// Cancellation token + /// The mapped result or null if no result + Task ExecuteQueryAsync(string sql, CancellationToken cancellationToken = default); + } +}