public async Task CheckIfWorkersCompletedJob(IEnumerable <ExportManagerQueueRecord> exportManagerQueueRecords) { var jobsInTheWorkerQueue = exportManagerQueueRecords.Where(x => x.QueueStatus == Constant.Status.Queue.WAITING_FOR_WORKERS_TO_FINISH); foreach (var exportManagerQueueRecord in jobsInTheWorkerQueue) { try { SetJobProperties(exportManagerQueueRecord); Int32 numberOfWorkerRecords = await SqlQueryHelper.CountNumberOfExportWorkerRecordsAsync( eddsDbContext : AgentHelper.GetDBContext(-1), workspaceArtifactId : exportManagerQueueRecord.WorkspaceArtifactId, exportJobArtifactId : exportManagerQueueRecord.ExportJobArtifactId); if (numberOfWorkerRecords == 0) { FileInfo exportFileInfo = await ConstructExportFileNameAsync(exportManagerQueueRecord.ObjectType, exportManagerQueueRecord.ExportJobArtifactId); //create export file Int32 numberOfRecordsExported = await CreateExportFileAsync(exportManagerQueueRecord, exportFileInfo); //attach export file to RDO await AttachFileToExportJobAsync(exportManagerQueueRecord, exportFileInfo.FullName); //delete export file from temp directory await DeleteExportFileAsync(exportFileInfo); //drop results table await DropExportWorkerResultsTableAsync(exportManagerQueueRecord.ResultsTableName); //delete record from export manager queue await ClearRecordsFromQueueTables(exportManagerQueueRecord); Boolean jobErrorsRecorded = await ArtifactQueries.JobErrorRecordExistsAsync(RsapiApiOptions, exportManagerQueueRecord.WorkspaceArtifactId, RsapiRepositoryGroup.RdoRepository, Constant.Guids.ObjectType.ExportUtilityJobErrors, Constant.Guids.Field.ExportUtilityJobErrors.ExportUtilityJob, exportManagerQueueRecord.ExportJobArtifactId); await FinalizeJobStatiaticsAsync(exportManagerQueueRecord, numberOfRecordsExported); //update status of export job to complete if (jobErrorsRecorded) { await UpdateExportJobStatus(Constant.Status.Job.COMPLETED_WITH_ERRORS, exportManagerQueueRecord); await SendEmail(exportManagerQueueRecord, Constant.Status.Job.COMPLETED_WITH_ERRORS); } else { await UpdateExportJobStatus(Constant.Status.Job.COMPLETED, exportManagerQueueRecord); await SendEmail(exportManagerQueueRecord, Constant.Status.Job.COMPLETED); } } } catch (Exception ex) { throw new AdminMigrationUtilityException(Constant.ErrorMessages.CheckIfExportWorkersAreStillWorkingOnExportJobInExportWorkerQueueTableError, ex); } } }