Beispiel #1
0
        public override void HandleInstance(InstanceStorageInfo value)
        {
            if (value is null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            ;
            if (!value.CalledAeTitle.Equals(_configuration.AeTitle))
            {
                throw new InstanceNotSupportedException(value);
            }
            ;


            if (!_dicomToolkit.TryGetString(value.InstanceStorageFullPath, _grouping, out string key) ||
                string.IsNullOrWhiteSpace(key))
            {
                _logger.Log(LogLevel.Error, "Instance missing required DICOM key for grouping by {0}, ignoring", _grouping.ToString());
                return;
            }

            InstanceCollection collection = null;

            lock (SyncRoot)
            {
                if (_instances.TryGetValue(key, out InstanceCollection val))
                {
                    collection = val;
                }
                else
                {
                    collection = new InstanceCollection(key);
                    _instances.Add(key, collection);
                    _logger.Log(LogLevel.Debug, "New collection created for {0}", key);
                }
                collection.AddInstance(value);
            }
            _logger.Log(LogLevel.Debug, "Instance received and added with key {0}", key);
        }