public ElementValidationException(string name, DicomVR vr, string value, ValidationErrorCode errorCode, string message) : base(message)
 {
     Name      = EnsureArg.IsNotNull(name, nameof(name));
     VR        = EnsureArg.IsNotNull(vr, nameof(vr));
     Value     = EnsureArg.IsNotNull(value, nameof(value));
     ErrorCode = EnsureArg.EnumIsDefined(errorCode, nameof(errorCode));
 }
Exemplo n.º 2
0
        public override async Task AddExtendedQueryTagErrorAsync(
            int tagKey,
            ValidationErrorCode errorCode,
            long watermark,
            CancellationToken cancellationToken = default)
        {
            EnsureArg.EnumIsDefined(errorCode, nameof(errorCode));

            using SqlConnectionWrapper sqlConnectionWrapper = await ConnectionWrapperFactory.ObtainSqlConnectionWrapperAsync(cancellationToken);

            using SqlCommandWrapper sqlCommandWrapper = sqlConnectionWrapper.CreateSqlCommand();
            VLatest.AddExtendedQueryTagError.PopulateCommand(
                sqlCommandWrapper,
                tagKey,
                (short)errorCode,
                watermark);

            try
            {
                await sqlCommandWrapper.ExecuteNonQueryAsync(cancellationToken);
            }
            catch (SqlException e)
            {
                if (e.Number == SqlErrorCodes.NotFound)
                {
                    throw new ExtendedQueryTagNotFoundException(
                              string.Format(
                                  CultureInfo.InvariantCulture,
                                  DicomSqlServerResource.ExtendedQueryTagNotFoundWhenAddingError,
                                  tagKey));
                }

                throw new DataStoreException(e);
            }
        }
Exemplo n.º 3
0
 public void NotDefined_ShouldThrow(Only1IsValidEnum item)
 {
     ShouldThrow <ArgumentOutOfRangeException>(
         string.Format(ExceptionMessages.Enum_IsValidEnum, item, typeof(Only1IsValidEnum)),
         () => Ensure.Enum.IsDefined(item, ParamName),
         () => EnsureArg.EnumIsDefined(item, ParamName),
         () => Ensure.That(item, ParamName).IsDefined());
 }
Exemplo n.º 4
0
        public ServerResourceId(ResourceType resourceType, string resourceId)
        {
            EnsureArg.EnumIsDefined(resourceType, nameof(resourceType));
            EnsureArg.IsNotNullOrWhiteSpace(resourceId, nameof(resourceId));

            ResourceType = resourceType;
            ResourceId   = resourceId;
        }
Exemplo n.º 5
0
        public void IsDefined_ShouldNotThrow()
        {
            var item = Only1IsValidEnum.Valid;

            ShouldNotThrow(
                () => Ensure.Enum.IsDefined(item, ParamName),
                () => EnsureArg.EnumIsDefined(item, ParamName),
                () => Ensure.That(item, ParamName).IsDefined());
        }
Exemplo n.º 6
0
        public void FlagIsDefined_ShouldNotThrow_IfNotCombined()
        {
            var item = TestFlagsEnum.Bar;

            ShouldNotThrow(
                () => Ensure.Enum.IsDefined(item, ParamName),
                () => EnsureArg.EnumIsDefined(item, ParamName),
                () => Ensure.That(item, ParamName).IsDefined());
        }
 public Task AddExtendedQueryTagErrorAsync(int tagKey, ValidationErrorCode errorCode, long watermark, CancellationToken cancellationToken)
 {
     EnsureArg.EnumIsDefined(errorCode, nameof(errorCode));
     return(_extendedQueryTagErrorStore.AddExtendedQueryTagErrorAsync(
                tagKey,
                errorCode,
                watermark,
                cancellationToken));
 }
Exemplo n.º 8
0
        public void FlagNotDefined_ShouldThrow()
        {
            var item = (TestFlagsEnum)3;

            ShouldThrow <ArgumentOutOfRangeException>(
                string.Format(ExceptionMessages.Enum_IsValidEnum, item, typeof(TestFlagsEnum)),
                () => Ensure.Enum.IsDefined(item, ParamName),
                () => EnsureArg.EnumIsDefined(item, ParamName),
                () => Ensure.That(item, ParamName).IsDefined());
        }
 public ExtendedQueryTagStoreEntry(int key, string path, string vr, string privateCreator, QueryTagLevel level, ExtendedQueryTagStatus status, QueryStatus queryStatus, int errorCount)
 {
     Key            = key;
     Path           = EnsureArg.IsNotNullOrWhiteSpace(path);
     VR             = EnsureArg.IsNotNullOrWhiteSpace(vr);
     PrivateCreator = privateCreator;
     Level          = EnsureArg.EnumIsDefined(level);
     Status         = EnsureArg.EnumIsDefined(status);
     QueryStatus    = EnsureArg.EnumIsDefined(queryStatus);
     ErrorCount     = EnsureArg.IsGte(errorCount, 0, nameof(errorCount));
 }
        public FhirTransactionRequestEntry(
            FhirTransactionRequestMode requestMode,
            Bundle.RequestComponent request,
            IResourceId resourceId,
            Resource resource)
        {
            EnsureArg.EnumIsDefined(requestMode, nameof(requestMode));

            RequestMode = requestMode;
            Request     = request;
            ResourceId  = resourceId;
            Resource    = resource;
        }
        public async Task <DicomWebResponse <GetExtendedQueryTagEntry> > UpdateExtendedQueryTagAsync(string tagPath, UpdateExtendedQueryTagEntry newValue, CancellationToken cancellationToken)
        {
            EnsureArg.IsNotNullOrWhiteSpace(tagPath, nameof(tagPath));
            EnsureArg.IsNotNull(newValue, nameof(newValue));
            EnsureArg.EnumIsDefined(newValue.QueryStatus, nameof(newValue));
            string jsonString = JsonSerializer.Serialize(newValue, _jsonSerializerOptions);
            var    uri        = new Uri($"/{_apiVersion}{DicomWebConstants.BaseExtendedQueryTagUri}/{tagPath}", UriKind.Relative);

            using var request = new HttpRequestMessage(HttpMethod.Patch, uri);
            {
                request.Content = new StringContent(jsonString);
                request.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(DicomWebConstants.ApplicationJsonMediaType);
            }

            HttpResponseMessage response = await HttpClient.SendAsync(request, cancellationToken).ConfigureAwait(false);

            await EnsureSuccessStatusCodeAsync(response).ConfigureAwait(false);

            return(new DicomWebResponse <GetExtendedQueryTagEntry>(response, ValueFactory <GetExtendedQueryTagEntry>));
        }
Exemplo n.º 12
0
        ///<inheritdoc/>
        public override async Task <ExtendedQueryTagStoreJoinEntry> UpdateQueryStatusAsync(string tagPath, QueryStatus queryStatus, CancellationToken cancellationToken)
        {
            EnsureArg.IsNotNullOrWhiteSpace(tagPath, nameof(tagPath));
            EnsureArg.EnumIsDefined(queryStatus, nameof(queryStatus));

            using SqlConnectionWrapper sqlConnectionWrapper = await ConnectionWrapperFactory.ObtainSqlConnectionWrapperAsync(cancellationToken);

            using SqlCommandWrapper sqlCommandWrapper = sqlConnectionWrapper.CreateSqlCommand();

            VLatest.UpdateExtendedQueryTagQueryStatus.PopulateCommand(sqlCommandWrapper, tagPath, (byte)queryStatus);

            try
            {
                using SqlDataReader reader = await sqlCommandWrapper.ExecuteReaderAsync(cancellationToken);

                if (!await reader.ReadAsync(cancellationToken))
                {
                    throw new ExtendedQueryTagNotFoundException(string.Format(CultureInfo.InvariantCulture, DicomSqlServerResource.ExtendedQueryTagNotFound, tagPath));
                }

                (int rTagKey, string rTagPath, string rTagVR, string rTagPrivateCreator, byte rTagLevel, byte rTagStatus, byte rQueryStatus, int errorCount, Guid? operationId) = reader.ReadRow(
                    VLatest.ExtendedQueryTag.TagKey,
                    VLatest.ExtendedQueryTag.TagPath,
                    VLatest.ExtendedQueryTag.TagVR,
                    VLatest.ExtendedQueryTag.TagPrivateCreator,
                    VLatest.ExtendedQueryTag.TagLevel,
                    VLatest.ExtendedQueryTag.TagStatus,
                    VLatest.ExtendedQueryTag.QueryStatus,
                    VLatest.ExtendedQueryTag.ErrorCount,
                    VLatest.ExtendedQueryTagOperation.OperationId.AsNullable());

                return(new ExtendedQueryTagStoreJoinEntry(rTagKey, rTagPath, rTagVR, rTagPrivateCreator, (QueryTagLevel)rTagLevel, (ExtendedQueryTagStatus)rTagStatus, (QueryStatus)rQueryStatus, errorCount, operationId));
            }
            catch (SqlException ex)
            {
                throw new DataStoreException(ex);
            }
        }
 public UpdateExtendedQueryTagEntry(QueryStatus queryStatus)
 {
     QueryStatus = EnsureArg.EnumIsDefined(queryStatus, nameof(queryStatus));
 }
 public async Task <GetExtendedQueryTagEntry> UpdateExtendedQueryTagAsync(string tagPath, UpdateExtendedQueryTagEntry newValue, CancellationToken cancellationToken)
 {
     EnsureArg.IsNotNull(tagPath, nameof(tagPath));
     EnsureArg.IsNotNull(newValue?.QueryStatus, nameof(newValue));
     EnsureArg.EnumIsDefined(newValue.QueryStatus, nameof(UpdateExtendedQueryTagEntry.QueryStatus));
     if (!_dicomTagParser.TryParse(tagPath, out DicomTag[] tags, supportMultiple: false))