public async Task PerformExportPaymentsAndEarningsToV1(CollectionPeriod collectionPeriod)
        {
            logger.LogVerbose($"Started V1 payments export for collection period {collectionPeriod}");

            while (true)
            {
                int page = -1;
                try
                {
                    page = await paymentExportProgressCache.GetPage(collectionPeriod.AcademicYear, collectionPeriod.Period);

                    logger.LogVerbose($"Starting with page: {page}");

                    var payments = providerPaymentsRepository.GetMonthEndPayments(collectionPeriod, exportBatchSize, page);

                    if (payments.Count == 0)
                    {
                        logger.LogVerbose($"Finished exporting payments to V1 for collection period: {collectionPeriod}");
                        break;
                    }

                    logger.LogVerbose($"Found {payments.Count} payments to process");

                    var result = paymentMapper.MapV2Payments(payments);
                    await legacyPaymentsRepository
                    .WritePaymentInformation(result.payments, result.requiredPayments, result.earnings)
                    .ConfigureAwait(false);

                    logger.LogVerbose($"Completed write for page: {page} for collection period: {collectionPeriod}");

                    await paymentExportProgressCache
                    .IncrementPage(collectionPeriod.AcademicYear, collectionPeriod.Period)
                    .ConfigureAwait(false);
                }
                catch (Exception e)
                {
                    logger.LogError($"Error processing page: {page} during V1 legacy export", e);
                    throw;
                }
            }

            logger.LogVerbose($"Completed V1 payments export for collection period {collectionPeriod}");
        }
コード例 #2
0
 public async Task <List <PaymentModel> > GetMonthEndPayments(CollectionPeriod collectionPeriod, long ukprn, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(await providerPaymentsRepository.GetMonthEndPayments(collectionPeriod, ukprn, cancellationToken).ConfigureAwait(false));
 }