Пример #1
0
        public Task Handle(BatchSubmissionCompletedEvent notification, CancellationToken cancellationToken)
        {
            using (var scope = TracingExtensions.StartServerSpan(
                       _tracer,
                       notification.TracingKeys,
                       "batch-vetting-initiating"))
            {
                try
                {
                    _logger.LogInformation(
                        "Batch vetting initiated - URI: {BatchUri}",
                        notification.BatchUri);

                    var batchJobData = new BatchJobData
                    {
                        BatchUri    = notification.BatchUri,
                        TracingKeys = notification.TracingKeys
                    };

                    _backgroundJobClient
                    .Enqueue <VetBatchJob>(
                        job => job.Execute(batchJobData, null, JobCancellationToken.Null));
                }
                catch (Exception e)
                {
                    scope.Span.Log(new Dictionary <string, object>()
                    {
                        { "exception", e }
                    });
                    Tags.Error.Set(scope.Span, true);
                }

                return(Task.CompletedTask);
            }
        }
        private void EnqueueFeedbackGenerationBackgroundJob(Guid batchId, Dictionary <string, string> tracingKeys)
        {
            var batchJobData = new BatchJobData
            {
                BatchId     = batchId,
                TracingKeys = tracingKeys
            };

            _backgroundJobClient
            .Enqueue <GenerateBatchSubmissionFeedbackDocumentJob>(
                job => job.Execute(batchJobData, null, JobCancellationToken.Null));
        }
        public async Task <Guid> ProcessBatch(BatchSubmitModel model)
        {
            var id = Guid.NewGuid();

            var batch = new Batch
            {
                Id           = id,
                BatchUri     = $"HealthcareClaimsV1/{id}.json",
                CreationDate = DateTime.UtcNow
            };

            _batchesContext.Batches.Add(batch);

            using (var stream = model.BatchJsonFile.OpenReadStream())
            {
                await _objectsStorageService.UploadObjectAsync(
                    "healthcare-claims-app-v1",
                    batch.BatchUri,
                    stream);
            }

            await _batchesContext.SaveChangesAsync();

            var batchJobData = new BatchJobData
            {
                BatchId = batch.Id
            };

            var submissionJobId = _backgroundJobClient
                                  .Enqueue <GenerateBatchSubmissionFeedbackDocumentJob>(
                job => job.Execute(batchJobData, null, JobCancellationToken.Null));

            _backgroundJobClient
            .ContinueJobWith <VetBatchJob>(
                submissionJobId,
                job => job.Execute(batchJobData, null, JobCancellationToken.Null));

            _logger.LogInformation("Batch submission initiated: {Id}", batch.Id);

            return(batch.Id);
        }