Commit Graph

20 Commits

Author SHA1 Message Date
90916f6d03 Refactor exceptions to include profileId context
Refactored `JobException` and derived classes (`InactiveProfileException`, `JobHttpException`, `JobSqlException`) to include `profileId` as a required parameter in their constructors. This ensures consistent context for exceptions related to job execution.

Updated behaviors (`CheckQueryExecutionBehavior`, `MainQueryExecutionBehavior`, `ReCRequestExecutionBehavior`) to use the new constructors, passing `profileId` where applicable. Improved exception messages for better debugging context.

Simplified property initialization and enhanced XML documentation for clarity.
2026-08-03 13:36:42 +02:00
eb060aa54e Add CreateProfileHistoryCommand and mapping profiles
Introduce `CreateProfileHistoryCommand` to handle the creation of profile execution history records, including properties for `ProfileId`, `Result`, `ResultText`, and `AddedWho`.

Add `CreateProfileHistoryCommandHandler` to process the command and persist the data using `IProfileHistoryRepository`.

Define AutoMapper mappings in `MappingProfiles` to map `CreateProfileHistoryCommand` to the `ProfileHistory` entity, with specific configurations for ignored and mapped properties.
2026-08-03 12:08:54 +02:00
1110728741 Refactor DEXJob to ProfileJob across the codebase
Renamed namespaces, classes, and commands from `DEXJob` to `ProfileJob` to align with the new "Profiles" context. Updated pipeline behaviors (`CheckQueryExecutionBehavior`, `MainQueryExecutionBehavior`, `ReCRequestExecutionBehavior`) to handle `TriggeringProfileJobCommand`.

Refactored unit tests to reflect the new naming convention, including mock setups and assertions. Updated `DtoExtensions` to return `TriggeringProfileJobBatchCommand`. Adjusted queries and dependency injection to use the new `Profiles` namespace.

Performed general refactoring to replace all references to "DEXJob" with "ProfileJob" in method names, variables, and documentation for consistency and clarity.
2026-08-03 11:36:45 +02:00
a698f8daae Refactor namespaces for DEX job behaviors
Updated namespaces for `CheckQueryExecutionBehavior`,
`MainQueryExecutionBehavior`, and `ReCRequestExecutionBehavior`
from `ECMJobRunner.Application.Behaviors` to
`ECMJobRunner.Application.DEXJob.Commands.Behaviors` to better
align with the `DEXJob.Commands` context.

Updated `DependencyInjection.cs` and test files to reference the
new namespace. Added `using Microsoft.Extensions.Options;` to
support the Options pattern in the updated files.
2026-08-03 11:17:27 +02:00
2d7c54ceae Refactor JobException message handling
Renamed the `Message` method to `CreateMessage` for clarity and updated its usage in the `JobException` constructor. Simplified the error message format by removing visual separator lines, resulting in cleaner and more concise output.
2026-08-03 10:34:35 +02:00
af3c8be133 Add AutoMapper and update database connection string
Updated `DependencyInjection.cs` to register AutoMapper with all profiles from the assembly, improving object mapping setup.

Modified `appsettings.json` to update the connection string for `SDD-VMP04-SQL17`, including a new server name and a more secure password, reflecting a move to a different environment or configuration.
2026-08-03 09:52:13 +02:00
3a1e16a7a0 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
2026-07-12 00:04:40 +02:00
8255f1f6aa feat(application): add inactive profile validation with custom exception
- Create InactiveProfileException for profile active status validation
- Update TriggeringDEXJobBatchCommand to check profile active status before execution
- Add ICfgProfileRepository dependency to batch command handler
- Throw InactiveProfileException when attempting to execute inactive profiles
- Add profile not found validation with descriptive error message
- Reorganize commands under DEXJob/Commands directory structure
2026-07-11 19:16:35 +02:00
eaf24e05ee refactor(application): consolidate query architecture with AutoMapper integration
- Add AutoMapper profile for CfgProfile and ProfileSqlJob entity-to-DTO mappings
- Consolidate GetProfileByIdQuery and GetAllActiveProfilesQuery into unified GetProfileQuery
- Implement flexible filtering with nullable query options (Id, Active, TypeId, ProfileName)
- Add IncludeSqlJobs option for optimized SQL job loading
- Move CfgProfileDto to Common/Dtos for better architecture alignment
- Add comprehensive unit tests for GetProfileQuery with multiple filter scenarios
- Move ISQLExecutor interface from Domain to Application layer
- Add GetByIdWithSqlJobsAsync and GetAllActiveWithSqlJobsAsync to repository
2026-07-11 19:14:51 +02:00
3f924b75b0 chore(application): remove old ISQLExecutor interface location
- Delete ECMJobRunner.Application/Common/Interfaces/ISQLExecutor.cs
- Interface moved to ECMJobRunner.Domain/Interfaces/ (committed in 26ea1db)
2026-07-11 16:45:15 +02:00
5d2f128cc7 feat(application): add dependency injection configuration & documentation
- Implement DependencyInjection.cs with AddApplication() extension
  - Register MediatR with assembly scanning
  - Register pipeline behaviors in execution order:
    1. CheckQueryExecutionBehavior
    2. MainQueryExecutionBehavior
    3. ReCRequestExecutionBehavior
  - Conditional package versions (MediatR 9.0.0/12.4.1)
- Add comprehensive README.md
  - Architecture overview & CQRS pipeline flow
  - Configuration guide (DexJobOptions, ErrorAction)
  - DI setup examples (AddApplication, AddInfrastructure)
  - Exception handling patterns
  - Multi-targeting notes & troubleshooting
- Update project file with MediatR.Extensions.DependencyInjection
2026-07-11 16:44:39 +02:00
63a16410ea feat(application): implement MediatR pipeline behaviors for DEX job stages
- Add MainQueryExecutionBehavior
  - Execute main SQL query via ISQLExecutor
  - Populate command.MainQueryResults
  - Throw JobSqlException on failure
- Add CheckQueryExecutionBehavior
  - Execute check SQL query via ISQLExecutor
  - Validate ErrorAction.SkipInsert for zero results
  - Throw JobSqlException on failure/validation error
- Add ReCRequestExecutionBehavior
  - Execute ReC API requests for each main query result
  - Batch ID tracking, error handling
  - Throw JobHttpException on API failures
- Conditional compilation for MediatR signature differences
  - net480: Handle(request, cancellationToken, next)
  - net8.0: Handle(request, next, cancellationToken)
- Refactor TriggeringDEXJobCommand handler: delegate all logic to behaviors
2026-07-11 16:44:25 +02:00
222a5e24bf refactor(application): redesign exception hierarchy with flexible base class
- Replace DEXJobException with JobException base class
  - Flexible params-based detail collection
  - Automatic message formatting with visual separators
  - Optional null-handling for contextual details
- Add JobHttpException for HTTP client failures
  - Properties: ClientLibrary, ClientMethod
  - Use case: ReC API, REST requests
- Add JobSqlException for SQL query failures
  - Property: Query (virtual for customization)
  - Use case: Main/Check query execution
- Comprehensive XML documentation for all exception classes
2026-07-11 16:44:10 +02:00
2af17ec870 feat: implement DEX job triggering commands with CQRS pattern
TriggeringDEXJobBatchCommand:
- Orchestrates batch job execution for a profile
- Creates unique 20-character timestamp-based batch ID
- Executes all SQL jobs sequentially for given profile ID
- Uses MediatR ISender to trigger individual job commands

TriggeringDEXJobCommand:
- Executes single DEX job with three-stage pipeline:
  1. Main Query: executes primary SQL with batch ID placeholder replacement
  2. Check Query: validates execution with return value check (> 0)
  3. ReC Request: invokes ReC API with batch ID reference
- Configurable error handling per stage via DexJobOptions
- Regex-based placeholder replacement for dynamic batch ID injection
- Returns Unit for void-like MediatR command pattern

Both commands include:
- Comprehensive XML documentation
- Primary constructor injection (modern C# syntax)
- Proper async/await with CancellationToken support
- Integration with ISQLExecutor and ReCClient abstractions
2026-07-11 12:38:42 +02:00
8a1a579501 feat: add DEX job exception handling and configuration
Exceptions:
- DEXJobException: custom exception with formatted error messages
  * Includes query name, batch ID, SQL query, and detailed error info
  * Two constructors: with inner exception or reason message
  * Comprehensive XML documentation

Options:
- DexJobOptions: hierarchical configuration for DEX job execution
  * Error handling per stage (MainQuery, CheckQuery, ReCRequest)
  * Granular error actions (OnExecution, IfNullOrWhiteSpace, OnUnexpectedResult)
  * Placeholder configuration with regex pattern support
  * Default BatchId placeholder: #INT#BATCH_ID (case-insensitive)
  * Fully documented with XML comments
2026-07-11 12:38:31 +02:00
7e267b427e 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
2026-07-11 12:38:21 +02:00
30a2a4ce3b build: add ReC.Client package reference
- Add ReC.Client v2.0.0-beta for DEX job HTTP request integration
2026-07-11 12:38:13 +02:00
bd6c1c1309 Update AutoMapper versions and suppress NU1903 warning
- Suppressed AutoMapper vulnerability warning (NU1903) as acceptable.
- Updated comments for AutoMapper references to clarify alignment with Infrastructure.
- Added `AutoMapper.Extensions.Microsoft.DependencyInjection`:
  - Version 8.1.1 for .NET Framework 4.8.
  - Version 12.0.1 for .NET 8.
- Downgraded AutoMapper for .NET 8 from 13.0.1 to 12.0.1.
2026-07-09 15:58:52 +02:00
eb9c5c323a Update AGENTS.md and csproj for ECMJobRunner.Application
Added detailed documentation to AGENTS.md, including project overview, architecture, components, and usage examples for the ECMJobRunner.Application layer. Documented target frameworks (.NET Framework 4.8 and .NET 8.0) and their dependencies (AutoMapper and MediatR).

Updated ECMJobRunner.Application.csproj:
- Changed `<Product>` tag to reflect the correct project name.
- Added a project reference to ECMJobRunner.Domain.
- Introduced conditional NuGet package references for framework-specific dependencies.
2026-07-09 13:35:24 +02:00
26dc58d82e Add Application and Infrastructure projects to solution
Two new projects, `ECMJobRunner.Application` and
`ECMJobRunner.Infrastructure`, were added to the solution file
(`ECM.JobRunner.sln`). Build configurations for these projects
were also added.

`ECMJobRunner.Application.csproj` targets both .NET Framework 4.8
and .NET 8.0, with properties such as `LangVersion`, `Nullable`,
and `PackageId` defined.

`ECMJobRunner.Infrastructure.csproj` also targets .NET Framework
4.8 and .NET 8.0. It includes conditional dependencies:
- For `net480`, it references `EntityFramework` 6.5.1.
- For `net8.0`, it references `Microsoft.EntityFrameworkCore`
  and related packages (version 8.0.11).
2026-07-09 11:48:10 +02:00