using System.Runtime.CompilerServices; using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; using RecruitmentDAL.DTO.Reports; using RecruitmentDAL.Query.Reports; namespace RecruitmentDAL.CustomeCode.Reports.JobAdSpendPerformance { public class JobAdSpendPerformanceDAL : IJobAdSpendPerformanceDAL { private readonly IQueryExecutor _QueryExecutor; public JobAdSpendPerformanceDAL(IQueryExecutor queryExecutor) { _QueryExecutor = queryExecutor; } public async Task> GetJobAdSpendPerformance( int firstNumber, int maxResult, int? jobRequisitionId, LoginDTO login, CancellationToken ct) { var parameters = new { TenantId = login.ClientId, JobRequisitionId = jobRequisitionId, Offset = Math.Max(0, firstNumber - 1), PageSize = maxResult > 0 ? maxResult : 500 }; // NOTE: IQueryExecutor.QueryPagedAsync has no CancellationToken parameter (confirmed // against ~40 real call sites, e.g. CandidateDAL.GetSelectListCandidate, // ApplicationCycleTimeDAL.GetApplicationCycleTime) — ct is deliberately not forwarded // into this call. return await _QueryExecutor .QueryPagedAsync(login, JobAdSpendPerformanceQB.GET_JOBADSPEND_PERFORMANCE_PAGED, parameters) .ConfigureAwait(false); } public async IAsyncEnumerable GetJobAdSpendPerformanceStream( int? jobRequisitionId, LoginDTO login, [EnumeratorCancellation] CancellationToken ct) { var parameters = new { TenantId = login.ClientId, JobRequisitionId = jobRequisitionId }; await foreach (var row in _QueryExecutor .QueryStreamAsync(login, JobAdSpendPerformanceQB.GET_JOBADSPEND_PERFORMANCE, parameters, ct) .ConfigureAwait(false)) { yield return row; } } } }