public static async Task SendLevyMonthEndForEmployers(long monthEndJobId, IEnumerable <long> employerAccountIds, short academicYear, byte collectionPeriod, IMessageSession messageSession) { Console.WriteLine($"Month end job id: {monthEndJobId}"); foreach (var employerAccountId in employerAccountIds) { var processLevyFundsAtMonthEndCommand = new ProcessLevyPaymentsOnMonthEndCommand { JobId = monthEndJobId, CollectionPeriod = new CollectionPeriod { AcademicYear = academicYear, Period = collectionPeriod }, RequestTime = DateTime.Now, SubmissionDate = DateTime.UtcNow, AccountId = employerAccountId, }; await messageSession.Send(processLevyFundsAtMonthEndCommand).ConfigureAwait(false); } }
public async Task <ReadOnlyCollection <FundingSourcePaymentEvent> > HandleMonthEnd( ProcessLevyPaymentsOnMonthEndCommand command) { paymentLogger.LogVerbose( $"Handling ProcessLevyPaymentsOnMonthEndCommand for {Id}, Job: {command.JobId}, Account: {command.AccountId}"); try { using (var operation = telemetry.StartOperation("LevyFundedService.HandleMonthEnd", command.CommandId.ToString())) { var stopwatch = Stopwatch.StartNew(); var fundingSourceEvents = await fundingSourceEventGenerationService.HandleMonthEnd(command.AccountId, command.JobId, command.CollectionPeriod); await monthEndCache.AddOrReplace(CacheKeys.MonthEndStartedForThisAccountCacheKey, true, CancellationToken.None); telemetry.TrackDurationWithMetrics("LevyFundedService.HandleMonthEnd", stopwatch, command, command.AccountId, new Dictionary <string, double> { { TelemetryKeys.Count, fundingSourceEvents.Count } }); telemetry.StopOperation(operation); return(fundingSourceEvents); } } catch (Exception ex) { paymentLogger.LogError($"Failed to get levy or co-invested month end payments. Error: {ex.Message}", ex); throw; } }
public async Task <ReadOnlyCollection <FundingSourcePaymentEvent> > HandleMonthEnd(ProcessLevyPaymentsOnMonthEndCommand command) { paymentLogger.LogVerbose($"Handling ProcessLevyPaymentsOnMonthEndCommand for {Id}, Job: {command.JobId}, Account: {command.AccountId}"); try { using (var operation = telemetry.StartOperation()) { var stopwatch = Stopwatch.StartNew(); var fundingSourceEvents = await fundingSourceService.HandleMonthEnd(command.AccountId, command.JobId); telemetry.StopOperation(operation); return(fundingSourceEvents); } } catch (Exception ex) { paymentLogger.LogError($"Failed to get levy or co-invested month end payments. Error: {ex.Message}", ex); throw; } }