using AccountsDAL.CustomCode.AccountReports.AccountCashFlow; using AccountsDAL.DTO.AccountsReports; using GB5Shared.DTO.Framework.Criteria; using GB5Shared.DTO.Framework.Login; using GB5Shared.Telemetry; namespace AccountsBLL.AccountReports.AccountCashFlow { public class AccountCashFlowReportBLL : IAccountCashFlowReportBLL { private const int DEFAULT_MAX_RESULT_CAP = 500; private readonly IAccountCashFlowReportDAL _accountCashFlowReportDAL; private readonly IAccountReportAccessControlBLL _accessControlBLL; public AccountCashFlowReportBLL( IAccountCashFlowReportDAL accountCashFlowReportDAL, IAccountReportAccessControlBLL accessControlBLL) { _accountCashFlowReportDAL = accountCashFlowReportDAL; _accessControlBLL = accessControlBLL; } public async Task GetCashFlowDirectReport( int firstNumber, int maxResult, CriteriaDTO criteriaDTO, List sortBy, int menuId, LoginDTO loginDTO) { try { GB5Trace.Step("parse-criteria-cash-flow-direct", new { firstNumber, maxResult, menuId }); var criteria = AccountReportCriteriaParser.Parse(criteriaDTO, loginDTO); var cappedMaxResult = Math.Min(maxResult, DEFAULT_MAX_RESULT_CAP); await _accessControlBLL.EnforceAsync(criteria, cappedMaxResult, menuId, loginDTO).ConfigureAwait(false); GB5Trace.Step("query-cash-flow-direct", new { firstNumber, cappedMaxResult, criteria.GroupType }); return await _accountCashFlowReportDAL .GetCashFlowDirectReport(firstNumber, cappedMaxResult, criteria, sortBy, loginDTO) .ConfigureAwait(false); } catch (Exception ex) { GB5Trace.MarkFailed("account-cash-flow-direct-failed", ex); throw; } } public async Task GetCashFlowIndirectReport( CriteriaDTO criteriaDTO, int menuId, LoginDTO loginDTO) { try { GB5Trace.Step("parse-criteria-cash-flow-indirect", new { menuId }); var criteria = AccountReportCriteriaParser.Parse(criteriaDTO, loginDTO); await _accessControlBLL.EnforceAsync(criteria, DEFAULT_MAX_RESULT_CAP, menuId, loginDTO).ConfigureAwait(false); GB5Trace.Step("query-cash-flow-indirect", new { }); return await _accountCashFlowReportDAL .GetCashFlowIndirectReport(criteria, loginDTO) .ConfigureAwait(false); } catch (Exception ex) { GB5Trace.MarkFailed("account-cash-flow-indirect-failed", ex); throw; } } } }