using FrameworkDAL.DTO.EIPConversation; using FrameworkDAL.Query.EIPConversation.EIPSessionAdmin; using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; namespace FrameworkDAL.CustomCode.EIPConversation.EIPSessionAdmin { public class EIPSessionAdminDAL : IEIPSessionAdminDAL { private readonly IQueryExecutor _qe; private readonly ILogger _logger; public EIPSessionAdminDAL(IQueryExecutor qe, ILogger logger) { _qe = qe ?? throw new ArgumentNullException(nameof(qe)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); } public async Task> GetSessionListAsync( string? status, int? channelType, DateTime? fromDate, DateTime? toDate, LoginDTO login, CancellationToken ct = default) { ct.ThrowIfCancellationRequested(); try { _logger.LogInformation( "DAL | GetSessionList | Tenant={TenantId} | Status={Status} | ChannelType={ChannelType}", login.ClientId, status, channelType); var result = await _qe.QueryAsync( login, EIPSessionAdminQB.GET_SESSION_LIST, new { TenantId = login.ClientId, Status = status, ChannelType = channelType, FromDate = fromDate, ToDate = toDate }, cancellationToken: ct).ConfigureAwait(false); return result ?? []; } catch (OperationCanceledException) { _logger.LogWarning("DAL | GetSessionList | Cancelled | Tenant={TenantId}", login.ClientId); throw; } catch (Exception ex) { _logger.LogError(ex, "DAL | GetSessionList | Error | Tenant={TenantId}", login.ClientId); throw; } } } }