public async Task Handle(ReceivedProviderEarningsEvent message, CancellationToken cancellationToken) { logger.LogVerbose($"Handling ILR Submissions. Data: {message.ToJson()}"); var currentIlr = await GetCurrentIlrSubmissionEvent(message.Ukprn, cancellationToken); var isNewIlrSubmission = validateIlrSubmission.IsNewIlrSubmission(new IlrSubmissionValidationRequest { IncomingPaymentUkprn = message.Ukprn, IncomingPaymentSubmissionDate = message.IlrSubmissionDateTime, CurrentIlr = currentIlr }); if (!isNewIlrSubmission) { logger.LogInfo($"Ignored same Ilr Submission Data for Ukprn {message.Ukprn} and Job Id {message.JobId} Submission already processed"); return; } logger.LogInfo($"Updating current Ilr Submission Data for Ukprn {message.Ukprn} and Job Id {message.JobId}"); await ilrSubmittedEventCache.Clear(message.Ukprn.ToString(), cancellationToken); await ilrSubmittedEventCache.Add(message.Ukprn.ToString(), message, cancellationToken); logger.LogDebug($"Successfully Updated current Ilr Submission Data for Ukprn {message.Ukprn} and Job Id {message.JobId}"); await providerPaymentsRepository.DeleteOldMonthEndPayment(message.CollectionPeriod, message.Ukprn, message.IlrSubmissionDateTime, cancellationToken); logger.LogInfo($"Successfully Deleted Old Month End Payment for Ukprn {message.Ukprn} and Job Id {message.JobId}"); }
public async Task <ReadOnlyCollection <FundingSourcePaymentEvent> > HandleMonthEnd(long employerAccountId, long jobId) { var fundingSourceEvents = new List <FundingSourcePaymentEvent>(); var keys = await generateSortedPaymentKeys.GeyKeys().ConfigureAwait(false); var levyAccount = await levyFundingSourceRepository.GetLevyAccount(employerAccountId); levyBalanceService.Initialise(levyAccount.Balance, levyAccount.TransferAllowance); paymentLogger.LogDebug($"Processing {keys.Count} required payments, levy balance {levyAccount.Balance}, account {employerAccountId}, job id {jobId}"); foreach (var key in keys) { var requiredPaymentEvent = await requiredPaymentsCache.TryGet(key).ConfigureAwait(false); if (!requiredPaymentEvent.HasValue) { continue; } fundingSourceEvents.AddRange(CreateFundingSourcePaymentsForRequiredPayment(requiredPaymentEvent.Value, employerAccountId, jobId)); await requiredPaymentsCache.Clear(key).ConfigureAwait(false); } paymentLogger.LogDebug($"Created {fundingSourceEvents.Count} payments - {GetFundsDebugString(fundingSourceEvents)}, account {employerAccountId}, job id {jobId}"); levyAccount.Balance = levyBalanceService.RemainingBalance; levyAccount.TransferAllowance = levyBalanceService.RemainingTransferAllowance; await levyAccountCache.AddOrReplace(CacheKeys.LevyBalanceKey, levyAccount); await refundSortKeysCache.Clear(CacheKeys.RefundPaymentsKeyListKey).ConfigureAwait(false); await transferPaymentSortKeysCache.Clear(CacheKeys.SenderTransferKeyListKey).ConfigureAwait(false); await requiredPaymentSortKeysCache.Clear(CacheKeys.RequiredPaymentKeyListKey).ConfigureAwait(false); await monthEndCache.AddOrReplace(CacheKeys.MonthEndCacheKey, true, CancellationToken.None); paymentLogger.LogInfo($"Finished generating levy and/or co-invested payments for the account: {employerAccountId}, number of payments: {fundingSourceEvents.Count}."); return(fundingSourceEvents.AsReadOnly()); }
public IObservable <Unit> ClearCache() { return(_dataCache.Clear()); }
public IActionResult Clear() { cache.Clear(); return(Ok()); }
/// <inheritdoc /> /// <summary> /// We want to clear the cache on a new connection - we may have missed some events /// And can't be sure /// </summary> protected override void OnConnection() { base.OnConnection(); _dataCache.Clear(); }