using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; using FrameworkDAL.CustomCode.GOP.DTOs; using FrameworkDAL.Query.GOP; using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; using GB5Shared.Resource.Response; using GB5Shared.Validation; namespace FrameworkDAL.CustomCode.GOP { public class GopReportDAL : IGopReportDAL { private readonly IQueryExecutor _QueryExecutor; private readonly IValidation _Validation; public GopReportDAL(IQueryExecutor queryExecutor, IValidation validation) { _QueryExecutor = queryExecutor; _Validation = validation; } public async Task> GetExecutionSummaryReport( DateTime? dateFrom, DateTime? dateTo, LoginDTO loginDTO, CancellationToken ct = default) { try { var result = await _QueryExecutor.QueryAsync( loginDTO, GopReportQB.GET_EXECUTION_SUMMARY, new { ClientId = loginDTO.ClientId, DateFrom = dateFrom, DateTo = dateTo }, cancellationToken: ct); return (result ?? []).ToList(); } catch (Exception ex) { throw new Exception(await _Validation.HandleException(ex, ErrorResponse.GetFetchingMessge)); } } public async Task> GetDlqAgingReport( int? minAgeDays, LoginDTO loginDTO, CancellationToken ct = default) { try { var result = await _QueryExecutor.QueryAsync( loginDTO, GopReportQB.GET_DLQ_AGING, new { ClientId = loginDTO.ClientId, MinAgeDays = minAgeDays }, cancellationToken: ct); return (result ?? []).ToList(); } catch (Exception ex) { throw new Exception(await _Validation.HandleException(ex, ErrorResponse.GetFetchingMessge)); } } public async Task> GetQualifierFindingFrequencyReport( DateTime? dateFrom, DateTime? dateTo, LoginDTO loginDTO, CancellationToken ct = default) { try { var result = await _QueryExecutor.QueryAsync( loginDTO, GopReportQB.GET_QUALIFIER_FINDING_FREQUENCY, new { ClientId = loginDTO.ClientId, TenantId = loginDTO.ClientId, DateFrom = dateFrom, DateTo = dateTo }, cancellationToken: ct); return (result ?? []).ToList(); } catch (Exception ex) { throw new Exception(await _Validation.HandleException(ex, ErrorResponse.GetFetchingMessge)); } } public async Task> GetQualifierPerformanceReport( DateTime? dateFrom, DateTime? dateTo, LoginDTO loginDTO, CancellationToken ct = default) { try { var result = await _QueryExecutor.QueryAsync( loginDTO, GopReportQB.GET_QUALIFIER_PERFORMANCE, new { ClientId = loginDTO.ClientId, TenantId = loginDTO.ClientId, DateFrom = dateFrom, DateTo = dateTo }, cancellationToken: ct); return (result ?? []).ToList(); } catch (Exception ex) { throw new Exception(await _Validation.HandleException(ex, ErrorResponse.GetFetchingMessge)); } } public async Task> GetFlowDriftReport( LoginDTO loginDTO, CancellationToken ct = default) { try { var result = await _QueryExecutor.QueryAsync( loginDTO, GopReportQB.GET_FLOW_DRIFT, new { TenantId = loginDTO.ClientId }, cancellationToken: ct); return (result ?? []).ToList(); } catch (Exception ex) { throw new Exception(await _Validation.HandleException(ex, ErrorResponse.GetFetchingMessge)); } } public async Task> GetQualifierCoverageReport( LoginDTO loginDTO, CancellationToken ct = default) { try { var result = await _QueryExecutor.QueryAsync( loginDTO, GopReportQB.GET_QUALIFIER_COVERAGE, new { TenantId = loginDTO.ClientId }, cancellationToken: ct); return (result ?? []).ToList(); } catch (Exception ex) { throw new Exception(await _Validation.HandleException(ex, ErrorResponse.GetFetchingMessge)); } } } }