public async Task <IEnumerable <string> > GetJobTypes(string specificationId, IEnumerable <string> jobTypes) { Guard.ArgumentNotNull(jobTypes, nameof(jobTypes)); IEnumerable <JobSummary> jobSummaries = await _jobManagement.GetLatestJobsForSpecification(specificationId, jobTypes); return(jobSummaries.Where(_ => _ != null && _.RunningStatus == RunningStatus.InProgress).Select(_ => _.JobType)); }
public async Task <bool> IsCalculationEngineRunning(string specificationId, IEnumerable <string> jobTypes) { Guard.ArgumentNotNull(jobTypes, nameof(jobTypes)); IEnumerable <JobSummary> jobSummaries = await _jobManagement.GetLatestJobsForSpecification(specificationId, jobTypes); return(jobSummaries.Any(j => j != null && j.RunningStatus == RunningStatus.InProgress)); }
private void GivenTheJobForTheJobId(Action <JobSummaryBuilder> setUp = null) { JobSummaryBuilder jobSummaryBuilder = new JobSummaryBuilder(); setUp?.Invoke(jobSummaryBuilder); _job = jobSummaryBuilder.Build(); _jobs.GetLatestJobsForSpecification(_specificationId, Arg.Is <IEnumerable <string> >(_ => _.Single() == JobConstants.DefinitionNames.CreateInstructAllocationJob)) .Returns(new[] { _job }); }
private void GivenGetLatestJobsForSpecification( string specificationId, IEnumerable <string> jobTypes, IEnumerable <JobSummary> latestJobs) { _jobManagement .GetLatestJobsForSpecification( Arg.Is(specificationId), Arg.Is <IEnumerable <string> >(_ => _.SequenceEqual(jobTypes))) .Returns(Task.FromResult(latestJobs)); }
private async Task <bool> RegenerateScopedProvidersForSpecification(string specificationId, bool setCachedProviders) { string scopedProviderSummariesCountCacheKey = $"{CacheKeys.ScopedProviderSummariesCount}{specificationId}"; string currentProviderCount = await _cachePolicy.ExecuteAsync(() => _cacheProvider.GetAsync <string>(scopedProviderSummariesCountCacheKey)); string cacheKeyScopedListCacheKey = $"{CacheKeys.ScopedProviderSummariesPrefix}{specificationId}"; long scopedProviderRedisListCount = await _cachePolicy.ExecuteAsync(() => _cacheProvider.ListLengthAsync <ProviderSummary>(cacheKeyScopedListCacheKey)); if (string.IsNullOrWhiteSpace(currentProviderCount) || int.Parse(currentProviderCount) != scopedProviderRedisListCount || setCachedProviders) { IEnumerable <JobSummary> latestJob = await _jobManagement.GetLatestJobsForSpecification(specificationId, new[] { JobConstants.DefinitionNames.PopulateScopedProvidersJob }); // the populate scoped providers job is already running so don't need to queue another job if (latestJob?.FirstOrDefault()?.RunningStatus == RunningStatus.InProgress) { return(true); } await _jobManagement.QueueJob(new JobCreateModel { JobDefinitionId = JobConstants.DefinitionNames.PopulateScopedProvidersJob, SpecificationId = specificationId, Trigger = new Trigger { EntityId = specificationId, EntityType = "Specification", Message = "Triggered for specification changes" }, Properties = new Dictionary <string, string> { { "specification-id", specificationId } } }); return(true); } return(false); }