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.
39 lines
1.3 KiB
C#
39 lines
1.3 KiB
C#
using ECMJobRunner.Application.Common.Dtos;
|
|
using ECMJobRunner.Application.Profiles.Commands;
|
|
using MediatR;
|
|
|
|
namespace ECMJobRunner.WebCron.Extensions;
|
|
|
|
/// <summary>
|
|
/// Extension methods for profile DTOs to support Hangfire job operations.
|
|
/// </summary>
|
|
public static class DtoExtensions
|
|
{
|
|
/// <summary>
|
|
/// Generates a unique Hangfire job identifier for a profile.
|
|
/// </summary>
|
|
/// <param name="profile">The profile configuration DTO.</param>
|
|
/// <returns>A unique job identifier in the format "profile-{Id}-{normalized-name}".</returns>
|
|
/// <example>
|
|
/// Example: profile with Id=123 and ProfileName="Import Data"
|
|
/// returns "profile-123-import_data"
|
|
/// </example>
|
|
public static string JobId(this CfgProfileDto profile)
|
|
{
|
|
return $"profile-{profile.Id}-{profile.ProfileName.Replace(' ', '_').ToLowerInvariant()}";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Converts a profile DTO to a DEX job batch command.
|
|
/// </summary>
|
|
/// <param name="profile">The profile configuration DTO.</param>
|
|
/// <returns>A <see cref="TriggeringProfileJobBatchCommand"/> ready to execute the profile job.</returns>
|
|
public static TriggeringProfileJobBatchCommand ToJob(this CfgProfileDto profile)
|
|
{
|
|
return new TriggeringProfileJobBatchCommand
|
|
{
|
|
ProfileId = profile.Id,
|
|
};
|
|
}
|
|
}
|