private async Task Initialise() { if (!long.TryParse(Id.ToString(), out _)) { throw new InvalidCastException($"Unable to cast Actor Id {Id} to valid account Id "); } if (await actorCache.IsInitialiseFlagIsSet().ConfigureAwait(false)) { paymentLogger.LogVerbose($"Actor already initialised for employer {Id}"); return; } var stopwatch = Stopwatch.StartNew(); paymentLogger.LogInfo($"Initialising actor for employer {Id}"); await actorCache.SetInitialiseFlag().ConfigureAwait(false); paymentLogger.LogInfo($"Initialised actor for employer {Id}"); TrackInfrastructureEvent("LevyFundedService.Initialise", stopwatch); }
private async Task Initialise() { if (await actorCache.IsInitialiseFlagIsSet().ConfigureAwait(false)) { paymentLogger.LogVerbose($"Actor already initialised for employer {Id}"); return; } var stopwatch = Stopwatch.StartNew(); paymentLogger.LogInfo($"Initialising actor for employer {Id.GetLongId()}"); var paymentPriorities = await levyFundingSourceRepository.GetPaymentPriorities(Id.GetLongId()).ConfigureAwait(false); await employerProviderPriorities .AddOrReplace(CacheKeys.EmployerPaymentPriorities, paymentPriorities, default(CancellationToken)) .ConfigureAwait(false); await actorCache.SetInitialiseFlag().ConfigureAwait(false); paymentLogger.LogInfo($"Initialised actor for employer {Id.GetLongId()}"); TrackInfrastructureEvent("LevyFundedService.Initialise", stopwatch); }
private async Task Initialise() { try { paymentLogger.LogVerbose("Actor already initialised for apprenticeship"); if (await this.apprenticeships.IsInitialiseFlagIsSet()) { return; } var stopwatch = Stopwatch.StartNew(); paymentLogger.LogInfo("Initialising actor"); var uln = long.Parse(Id.ToString()); using (var repository = apprenticeshipRepository()) { var providerApprenticeships = await repository.ApprenticeshipsByUln(uln).ConfigureAwait(false); await this.apprenticeships.AddOrReplace(uln.ToString(), providerApprenticeships).ConfigureAwait(false); await this.apprenticeships.AddOrReplace(CacheKeys.DuplicateApprenticeshipsKey, providerApprenticeships).ConfigureAwait(false); //TODO: no need for this anymore var providerIds = await repository.GetProviderIdsByUln(uln); await this.providers.AddOrReplace(CacheKeys.ProvidersKey, providerIds).ConfigureAwait(false); } await apprenticeships.SetInitialiseFlag().ConfigureAwait(false); paymentLogger.LogInfo($"Initialised actor"); stopwatch.Stop(); TrackInfrastructureEvent("DataLockService.Initialise", stopwatch); } catch (Exception e) { paymentLogger.LogError($"Error initialising the actor. Error: {e.Message}", e); throw; } }