- Add SectionName constant to DexJobOptions
- Update placeholder pattern to {#INT#BATCH_ID}
- Add DexJob configuration section to appsettings.json
- Add IConfiguration parameter to DependencyInjection for options binding
- Add Microsoft.Extensions.Options.ConfigurationExtensions package for .NET Framework 4.8
- Improve code documentation and move class into namespace
110 lines
3.3 KiB
C#
110 lines
3.3 KiB
C#
using ECMJobRunner.Application.Common.Constants;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace ECMJobRunner.Application.Common.Options;
|
|
|
|
/// <summary>
|
|
/// Configuration options for DEX job execution
|
|
/// </summary>
|
|
public class DexJobOptions
|
|
{
|
|
/// <summary>
|
|
/// The configuration section name used to bind this options class from application settings
|
|
/// </summary>
|
|
public const string SectionName = "DexJob";
|
|
|
|
/// <summary>
|
|
/// Error handling options for DEX job operations
|
|
/// </summary>
|
|
public record DexJobErrorHandlingOptions
|
|
{
|
|
/// <summary>
|
|
/// Error handling options for SQL query execution
|
|
/// </summary>
|
|
public record SqlQueryErrorHandlingOptions
|
|
{
|
|
/// <summary>
|
|
/// Action to take when query execution fails
|
|
/// </summary>
|
|
public ErrorAction OnExecution { get; set; } = ErrorAction.Stop;
|
|
|
|
/// <summary>
|
|
/// Action to take when query is null or whitespace
|
|
/// </summary>
|
|
public ErrorAction IfNullOrWhiteSpace { get; set; } = ErrorAction.Ignore;
|
|
|
|
/// <summary>
|
|
/// Action to take when query returns unexpected result
|
|
/// </summary>
|
|
public ErrorAction OnUnexpectedResult { get; set; } = ErrorAction.Stop;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Error handling options for HTTP requests
|
|
/// </summary>
|
|
public record HttpRequestErrorHandlingOptions
|
|
{
|
|
/// <summary>
|
|
/// Action to take when HTTP request fails
|
|
/// </summary>
|
|
public ErrorAction OnSending { get; set; } = ErrorAction.Stop;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Error handling for main SQL query
|
|
/// </summary>
|
|
public SqlQueryErrorHandlingOptions MainQuery { get; set; } = new();
|
|
|
|
/// <summary>
|
|
/// Error handling for check SQL query
|
|
/// </summary>
|
|
public SqlQueryErrorHandlingOptions CheckQuery { get; set; } = new();
|
|
|
|
/// <summary>
|
|
/// Error handling for ReC HTTP request
|
|
/// </summary>
|
|
public HttpRequestErrorHandlingOptions ReCRequest { get; set; } = new();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Error handling configuration
|
|
/// </summary>
|
|
public DexJobErrorHandlingOptions Error { get; set; } = new();
|
|
|
|
/// <summary>
|
|
/// Placeholder configuration for dynamic value replacement
|
|
/// </summary>
|
|
public record PlaceHolderOptions
|
|
{
|
|
/// <summary>
|
|
/// Configuration for a single placeholder
|
|
/// </summary>
|
|
public record PlaceHolder
|
|
{
|
|
/// <summary>
|
|
/// Regex pattern to match the placeholder
|
|
/// </summary>
|
|
public string Pattern { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Regex options for pattern matching
|
|
/// </summary>
|
|
public RegexOptions RegexOptions { get; set; } = RegexOptions.IgnoreCase;
|
|
}
|
|
|
|
/// <summary>
|
|
/// BatchId placeholder configuration
|
|
/// </summary>
|
|
public PlaceHolder BatchId { get; set; } = new()
|
|
{
|
|
Pattern = "{#INT#BATCH_ID}",
|
|
RegexOptions = RegexOptions.IgnoreCase
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// Placeholder configuration
|
|
/// </summary>
|
|
public PlaceHolderOptions Placeholders { get; set; } = new();
|
|
}
|