using FrameworkDAL.CustomCode.ActionProcessor; using FrameworkDAL.DTO.EIPConversation; using GB5Shared.DTO.Framework.Login; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; namespace FrameworkBLL.EIPConversation.EIPAdmin.EIPEventActionAdmin { public class EIPEventActionRunAdminBLL : IEIPEventActionRunAdminBLL { private readonly IEventActionRunAdminDAL _dal; private readonly ILogger _logger; public EIPEventActionRunAdminBLL( IEventActionRunAdminDAL dal, ILogger logger) { _dal = dal ?? throw new ArgumentNullException(nameof(dal)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); } public async Task> GetRunListAsync( int? runStatus, string? actionCode, DateTime? fromDate, DateTime? toDate, LoginDTO login, CancellationToken ct = default) { try { // Validate RunStatus (0=Pending, 1=InProgress, 2=Completed, 3=Failed) if (runStatus.HasValue && (runStatus < 0 || runStatus > 3)) throw new ArgumentException( "RunStatus must be 0=Pending, 1=InProgress, 2=Completed, or 3=Failed (or omit to return all)."); _logger.LogInformation( "BLL | GetRunList | Tenant={TenantId} | RunStatus={RunStatus} | ActionCode={ActionCode}", login.ClientId, runStatus, actionCode); return await _dal.GetRunListAsync( runStatus, actionCode?.Trim().ToUpperInvariant(), fromDate, toDate, login, ct).ConfigureAwait(false); } catch (Exception ex) { _logger.LogError(ex, "BLL | GetRunList | Error | Tenant={TenantId}", login.ClientId); throw; } } } }