Example #1
0
        /// <inheritdoc/>
        public async Task WriteExceptionAsync(ChangeFeedEntry changeFeedEntry, Exception exceptionToStore, ErrorType errorType, CancellationToken cancellationToken)
        {
            CloudTable  table;
            TableEntity entity;
            string      tableName;

            EnsureArg.IsNotNull(changeFeedEntry, nameof(changeFeedEntry));

            switch (errorType)
            {
            case ErrorType.FhirError:
                tableName = Constants.FhirExceptionTableName;
                break;

            case ErrorType.DicomError:
                tableName = Constants.DicomExceptionTableName;
                break;

            case ErrorType.DicomValidationError:
                tableName = Constants.DicomValidationTableName;
                break;

            case ErrorType.TransientFailure:
                tableName = Constants.TransientFailureTableName;
                break;

            default:
                return;
            }

            DicomDataset dataset            = changeFeedEntry.Metadata;
            string       studyUid           = dataset.GetSingleValue <string>(DicomTag.StudyInstanceUID);
            string       seriesUid          = dataset.GetSingleValue <string>(DicomTag.SeriesInstanceUID);
            string       instanceUid        = dataset.GetSingleValue <string>(DicomTag.SOPInstanceUID);
            long         changeFeedSequence = changeFeedEntry.Sequence;

            table  = _client.GetTableReference(tableName);
            entity = new IntransientEntity(studyUid, seriesUid, instanceUid, changeFeedSequence, exceptionToStore);

            var operation = TableOperation.InsertOrMerge(entity);

            try
            {
                await table.ExecuteAsync(operation, cancellationToken);

                _logger.LogInformation("Error when processsing changefeed entry: {ChangeFeedSequence} for DICOM instance with StudyUID: {StudyUID}, SeriesUID: {SeriesUID}, InstanceUID: {InstanceUID}. Stored into table: {Table} in table storage.", changeFeedSequence, studyUid, seriesUid, instanceUid, tableName);
            }
            catch
            {
                _logger.LogInformation("Error when processsing changefeed entry: {ChangeFeedSequence} for DICOM instance with StudyUID: {StudyUID}, SeriesUID: {SeriesUID}, InstanceUID: {InstanceUID}. Failed to store to table storage.", changeFeedSequence, studyUid, seriesUid, instanceUid);
                throw;
            }
        }
Example #2
0
        /// <inheritdoc/>
        public async Task WriteExceptionAsync(ChangeFeedEntry changeFeedEntry, Exception exceptionToStore, ErrorType errorType, CancellationToken cancellationToken)
        {
            EnsureArg.IsNotNull(changeFeedEntry, nameof(changeFeedEntry));

            string tableName = errorType switch
            {
                ErrorType.FhirError => Constants.FhirExceptionTableName,
                ErrorType.DicomError => Constants.DicomExceptionTableName,
                ErrorType.DicomValidationError => Constants.DicomValidationTableName,
                ErrorType.TransientFailure => Constants.TransientFailureTableName,
                _ => null,
            };

            if (tableName == null)
            {
                return;
            }

            DicomDataset dataset            = changeFeedEntry.Metadata;
            string       studyInstanceUid   = dataset.GetSingleValue <string>(DicomTag.StudyInstanceUID);
            string       seriesInstanceUid  = dataset.GetSingleValue <string>(DicomTag.SeriesInstanceUID);
            string       sopInstanceUid     = dataset.GetSingleValue <string>(DicomTag.SOPInstanceUID);
            long         changeFeedSequence = changeFeedEntry.Sequence;

            var tableClient = _tableServiceClient.GetTableClient(tableName);
            var entity      = new IntransientEntity(studyInstanceUid, seriesInstanceUid, sopInstanceUid, changeFeedSequence, exceptionToStore);

            try
            {
                await tableClient.UpsertEntityAsync(entity, cancellationToken : cancellationToken);

                _logger.LogInformation("Error when processing changefeed entry: {ChangeFeedSequence} for DICOM instance with StudyUID: {StudyInstanceUid}, SeriesUID: {SeriesInstanceUid}, InstanceUID: {SopInstanceUid}. Stored into table: {Table} in table storage.", changeFeedSequence, studyInstanceUid, seriesInstanceUid, sopInstanceUid, tableName);
            }
            catch
            {
                _logger.LogInformation("Error when processing changefeed entry: {ChangeFeedSequence} for DICOM instance with StudyUID: {StudyInstanceUid}, SeriesUID: {SeriesInstanceUid}, InstanceUID: {SopInstanceUid}. Failed to store to table storage.", changeFeedSequence, studyInstanceUid, seriesInstanceUid, sopInstanceUid);
                throw;
            }
        }