private Task SendVacancyALEIdMigrationMessage(int serialNumber, Guid vacancyId) { _logger.LogInformation($"Queueing up vacancy {vacancyId} for ALE Id migration"); var message = new DataMigrationQueueMessage(serialNumber, vacancyId); return(_recruitQueueService.AddMessageAsync <DataMigrationQueueMessage>(message)); }
private async Task UpsertUserAsync(VacancyUser user, UserType userType) { var now = _timeProvider.Now; var userEntity = await _userRepository.GetAsync(user.UserId) ?? new User { Id = Guid.NewGuid(), IdamsUserId = user.UserId, UserType = userType, CreatedDate = now }; userEntity.Name = user.Name; userEntity.LastSignedInDate = now; userEntity.Email = user.Email; if (userType == UserType.Provider) { userEntity.Ukprn = user.Ukprn; } await _userRepository.UpsertUserAsync(userEntity); if (userType == UserType.Employer) { await _queueService.AddMessageAsync(new UpdateEmployerUserAccountQueueMessage { IdamsUserId = user.UserId }); } }
public async Task GenerateAllVacancyAnalyticsAsync([QueueTrigger(QueueNames.GenerateAllVacancyAnalyticsSummariesQueueName, Connection = "QueueStorage")] string message, TextWriter log) { if (_jobsConfig.DisabledJobs.Contains(JobName)) { _logger.LogDebug($"{JobName} is disabled, skipping ..."); return; } try { _logger.LogInformation($"Starting {this.GetType().Name}"); var allVacancyReferences = await _vacancyQuery.GetAllVacancyReferencesAsync(); _logger.LogInformation($"Adding analytics generation messages for {allVacancyReferences.Count()} vacancies"); foreach (var vacancyReference in allVacancyReferences) { var queueMessage = new VacancyAnalyticsQueueMessage { VacancyReference = vacancyReference }; await _queue.AddMessageAsync(queueMessage); } _logger.LogInformation($"Finished {this.GetType().Name}"); } catch (Exception ex) { _logger.LogError(ex, "Unable to add analytics generation messages"); throw; } }
public async Task <Unit> Handle(CreateReportCommand message, CancellationToken cancellationToken) { _logger.LogInformation("Creating report '{reportType}' with parameters '{reportParameters}' requested by {userId}", message.ReportType, message.Parameters, message.RequestedBy.UserId); var now = _timeProvider.Now; var report = new Report( message.ReportId, message.Owner, ReportStatus.New, message.ReportName, message.ReportType, message.Parameters, message.RequestedBy, now); await _repository.CreateAsync(report); var queueMessage = new ReportQueueMessage { ReportId = report.Id }; await _queue.AddMessageAsync(queueMessage); _logger.LogInformation("Finished create report '{reportType}' with parameters '{reportParameters}' requested by {userId}", message.ReportType, message.Parameters, message.RequestedBy.UserId); return(Unit.Value); }
private async Task UpdateUserAsync(Guid userIdamsId) { var shouldUpdateUser = await DoesUserExistsAsync(userIdamsId); if (shouldUpdateUser) { await _queueService.AddMessageAsync(new UpdateEmployerUserAccountQueueMessage { IdamsUserId = userIdamsId.ToString() }); } }
public Task VacancyStatusAsync([TimerTrigger(Schedules.MidnightDaily)] TimerInfo timerInfo, TextWriter log) { _logger.LogInformation($"Timer trigger {this.GetType().Name} fired"); var message = new VacancyStatusQueueMessage { CreatedByScheduleDate = _timeProvider.Now }; return(_queue.AddMessageAsync(message)); }
public Task DeleteReportsAsync([TimerTrigger(Schedules.WeeklyFourAmSunday)] TimerInfo timerInfo, TextWriter log) { _logger.LogInformation($"Timer trigger {this.GetType().Name} fired"); var message = new DeleteStaleQueryStoreDocumentsQueueMessage { CreatedByScheduleDate = _timeProvider.Today }; return(_queue.AddMessageAsync(message)); }
public Task CommunicationsHouseKeepingAsync([TimerTrigger(Schedules.WeeklyTenAmSunday)] TimerInfo timerInfo, TextWriter log) { _logger.LogInformation($"Timer trigger {this.GetType().Name} fired"); var message = new CommunicationsHouseKeepingQueueMessage { CreatedByScheduleDate = _timeProvider.Now }; return(_queue.AddMessageAsync(message)); }
public Task UpdateApprenticeshipProgrammesAsync([TimerTrigger(Schedules.FourAmDaily)] TimerInfo timerInfo, TextWriter log) { _logger.LogInformation($"Timer trigger {this.GetType().Name} fired"); var message = new UpdateApprenticeshipProgrammesQueueMessage { CreatedByScheduleDate = _timeProvider.Now }; return(_queue.AddMessageAsync(message)); }
public Task UpdateQaDashboardAsync([TimerTrigger(Schedules.EveryFiveMinutes)] TimerInfo timerInfo, TextWriter log) { _logger.LogInformation($"Timer trigger {this.GetType().Name} fired"); var message = new UpdateQaDashboardQueueMessage { CreatedByScheduleDate = _timeProvider.Now }; return(_queue.AddMessageAsync(message)); }
public Task Add(IEvent @event) { var json = JsonConvert.SerializeObject(@event, Formatting.Indented); var item = new EventItem { EventType = @event.GetType().Name, Data = json }; return(_queue.AddMessageAsync(item)); }
public async Task Run(long ukprn, long legalEntityId, Guid userRef, string userEmail, string userName, TransferReason transferReason) { var vacancies = await _vacanciesQuery.GetProviderOwnedVacanciesForLegalEntityAsync(ukprn, legalEntityId); var tasks = vacancies.Select(vac => _queueService.AddMessageAsync(new TransferVacancyToLegalEntityQueueMessage { VacancyReference = vac.VacancyReference.Value, UserRef = userRef, UserEmailAddress = userEmail, UserName = userName, TransferReason = transferReason })); await Task.WhenAll(tasks); }
public async Task Handle(UpdatedPermissionsEvent message, IMessageHandlerContext context) { if (_jobsConfig.DisabledJobs.Contains(ExternalSystemEventHandlerName)) { _logger.LogDebug($"{ExternalSystemEventHandlerName} is disabled, skipping ..."); return; } _logger.LogInformation($"Attempting to process {nameof(UpdatedPermissionsEvent)} : {{@eventMessage}}", message); if (message.UserRef.HasValue == false) { _logger.LogInformation($"Not handling Provider {nameof(Operation.Recruitment)} Permission being revoked as it is a consequence of Provider being blocked by QA on Recruit."); return; } if (message.GrantedOperations.Contains(Operation.Recruitment) == false) { var legalEntity = await GetAssociatedLegalEntity(message); if (legalEntity == null) { throw new Exception($"Could not find matching Account Legal Entity Id {message.AccountLegalEntityId} for Employer Account {message.AccountId}"); } var noOfAssociatedVacancies = (await _vacancyQuery.GetNoOfProviderOwnedVacanciesForLegalEntityAsync(message.Ukprn, legalEntity.LegalEntityId)); if (noOfAssociatedVacancies > 0) { await _recruitQueueService.AddMessageAsync(new TransferVacanciesFromProviderQueueMessage { Ukprn = message.Ukprn, LegalEntityId = legalEntity.LegalEntityId, UserRef = message.UserRef.Value, UserEmailAddress = message.UserEmailAddress, UserName = $"{message.UserFirstName} {message.UserLastName}", TransferReason = TransferReason.EmployerRevokedPermission }); await _messaging.SendCommandAsync(new SetupProviderCommand(message.Ukprn)); } } }
private async Task UpsertUserAsync(VacancyUser user, UserType userType) { _logger.LogInformation("Upserting user {name} of type {userType}.", user.Name, userType.ToString()); var now = _timeProvider.Now; var userEntity = await _userRepository.GetAsync(user.UserId) ?? new User { Id = Guid.NewGuid(), IdamsUserId = user.UserId, UserType = userType, CreatedDate = now }; var userNotificationPreferences = await _userNotificationPreferencesRepository.GetAsync(userEntity.IdamsUserId) ?? new UserNotificationPreferences { Id = userEntity.IdamsUserId, NotificationTypes = userEntity.UserType == UserType.Provider ? NotificationTypes.VacancyRejectedByEmployer : NotificationTypes.VacancySentForReview, NotificationScope = NotificationScope.OrganisationVacancies }; userEntity.Name = user.Name; userEntity.LastSignedInDate = now; userEntity.Email = user.Email; if (userType == UserType.Provider) { userEntity.Ukprn = user.Ukprn; } await _userRepository.UpsertUserAsync(userEntity); await _userNotificationPreferencesRepository.UpsertAsync(userNotificationPreferences); if (userType == UserType.Employer) { await _queueService.AddMessageAsync(new UpdateEmployerUserAccountQueueMessage { IdamsUserId = user.UserId }); } _logger.LogInformation("Finished upserting user {name}.", user.Name); }
public async Task Run(long ukprn, string employerAccountId, string accountLegalEntityPublicHashedId, Guid userRef, string userEmail, string userName, TransferReason transferReason) { var vacanciesTask = _vacanciesQuery.GetProviderOwnedVacanciesForLegalEntityAsync(ukprn, accountLegalEntityPublicHashedId); var vacanciesWithoutLegalEntityIdTask = GetProviderOwnerVacanciesWithoutLegalEntityThatMustBeTransferred(ukprn, employerAccountId, accountLegalEntityPublicHashedId); await Task.WhenAll(vacanciesTask, vacanciesWithoutLegalEntityIdTask); var vacancies = vacanciesTask.Result.Concat(vacanciesWithoutLegalEntityIdTask.Result); var tasks = vacancies.Select(vac => _queueService.AddMessageAsync(new TransferVacancyToLegalEntityQueueMessage { VacancyReference = vac.VacancyReference.Value, UserRef = userRef, UserEmailAddress = userEmail, UserName = userName, TransferReason = transferReason })); await Task.WhenAll(tasks); }
public async Task Handle(UpdatedPermissionsEvent message, IMessageHandlerContext context) { if (_jobsConfig.DisabledJobs.Contains(ExternalSystemEventHandlerName)) { _logger.LogDebug($"{ExternalSystemEventHandlerName} is disabled, skipping ..."); return; } _logger.LogInformation($"Attempting to process {nameof(UpdatedPermissionsEvent)} : {{@eventMessage}}", message); if (message.UserRef.HasValue == false) { _logger.LogInformation($"Not handling Provider {nameof(Operation.Recruitment)} Permission being revoked as it is a consequence of Provider being blocked by QA on Recruit."); return; } if (message.GrantedOperations.Contains(Operation.Recruitment) == false) { _logger.LogInformation($"Transferring vacancies from Provider {message.Ukprn} to Employer {message.AccountId}"); var employerAccountId = _encoder.Encode(message.AccountId, EncodingType.AccountId); var legalEntity = await GetAssociatedLegalEntityAsync(message, employerAccountId); if (legalEntity == null) { throw new Exception($"Could not find matching Account Legal Entity Id {message.AccountLegalEntityId} for Employer Account {message.AccountId}"); } await _recruitQueueService.AddMessageAsync(new TransferVacanciesFromProviderQueueMessage { Ukprn = message.Ukprn, EmployerAccountId = employerAccountId, AccountLegalEntityPublicHashedId = legalEntity.AccountLegalEntityPublicHashedId, UserRef = message.UserRef.Value, UserEmailAddress = message.UserEmailAddress, UserName = $"{message.UserFirstName} {message.UserLastName}", TransferReason = TransferReason.EmployerRevokedPermission }); } else if (message.GrantedOperations.Contains(Operation.RecruitmentRequiresReview) == false) { _logger.LogInformation($"Transferring vacancies from Employer Review to QA Review for Provider {message.Ukprn}"); var employerAccountId = _encoder.Encode(message.AccountId, EncodingType.AccountId); var legalEntity = await GetAssociatedLegalEntityAsync(message, employerAccountId); if (legalEntity == null) { throw new Exception($"Could not find matching Account Legal Entity Id {message.AccountLegalEntityId} for Employer Account {message.AccountId}"); } await _recruitQueueService.AddMessageAsync(new TransferVacanciesFromEmployerReviewToQAReviewQueueMessage { Ukprn = message.Ukprn, AccountLegalEntityPublicHashedId = legalEntity.AccountLegalEntityPublicHashedId, UserRef = message.UserRef.Value, UserEmailAddress = message.UserEmailAddress, UserName = $"{message.UserFirstName} {message.UserLastName}" }); } await _messaging.SendCommandAsync(new SetupProviderCommand(message.Ukprn)); }