Example #1
0
        private InstanceStorageInfo(DicomCStoreRequest request, string storageRootFullPath, string calledAeTitle, uint associationId, IFileSystem fileSystem)
        {
            Guard.Against.Null(request, nameof(request));
            Guard.Against.NullOrWhiteSpace(storageRootFullPath, nameof(storageRootFullPath));
            Guard.Against.NullOrWhiteSpace(calledAeTitle, nameof(calledAeTitle));
            Guard.Against.Null(fileSystem, nameof(fileSystem));

            _fileSystem = fileSystem;

            AeStoragePath = storageRootFullPath;
            CalledAeTitle = calledAeTitle;

            var temp        = string.Empty;
            var missingTags = new List <DicomTag>();

            if (!request.Dataset.TryGetSingleValue(DicomTag.PatientID, out temp))
            {
                missingTags.Add(DicomTag.PatientID);
            }
            else
            {
                PatientId = temp;
            }

            if (!request.Dataset.TryGetSingleValue(DicomTag.StudyInstanceUID, out temp))
            {
                missingTags.Add(DicomTag.StudyInstanceUID);
            }
            else
            {
                StudyInstanceUid = temp;
            }
            if (!request.Dataset.TryGetSingleValue(DicomTag.SeriesInstanceUID, out temp))
            {
                missingTags.Add(DicomTag.SeriesInstanceUID);
            }
            else
            {
                SeriesInstanceUid = temp;
            }

            if (missingTags.Count != 0)
            {
                throw new MissingRequiredTagException(missingTags.ToArray());
            }

            SopClassUid    = request.SOPClassUID.UID;
            SopInstanceUid = request.SOPInstanceUID.UID;

            AeStoragePath      = fileSystem.Path.Combine(AeStoragePath, associationId.ToString());
            AeStoragePath      = fileSystem.Path.GetDicomStoragePath(AeStoragePath);
            PatientStoragePath = fileSystem.Path.Combine(AeStoragePath, PatientId.RemoveInvalidPathChars());

            StudyStoragePath  = fileSystem.Path.Combine(PatientStoragePath, StudyInstanceUid.RemoveInvalidPathChars());
            SeriesStoragePath = fileSystem.Path.Combine(StudyStoragePath, SeriesInstanceUid.RemoveInvalidPathChars());

            fileSystem.Directory.CreateDirectoryIfNotExists(SeriesStoragePath);

            InstanceStorageFullPath = fileSystem.Path.Combine(SeriesStoragePath, SopInstanceUid.RemoveInvalidPathChars()) + ".dcm";
        }
Example #2
0
        public string CopyTo(string targetRoot)
        {
            Guard.Against.NullOrWhiteSpace(targetRoot, nameof(targetRoot));

            var targetPath = _fileSystem.Path.Combine(targetRoot, PatientId.RemoveInvalidPathChars(), StudyInstanceUid.RemoveInvalidPathChars(), SeriesInstanceUid.RemoveInvalidPathChars());

            _fileSystem.Directory.CreateDirectoryIfNotExists(targetPath);
            targetPath = _fileSystem.Path.Combine(targetPath, SopInstanceUid.RemoveInvalidPathChars()) + ".dcm";
            _fileSystem.File.Copy(InstanceStorageFullPath, targetPath, true);
            return(targetPath);
        }
Example #3
0
        public override bool Equals(object obj)
        {
            if (obj is InstanceIdentifier identifier)
            {
                return(StudyInstanceUid.Equals(identifier.StudyInstanceUid, EqualsStringComparison) &&
                       SeriesInstanceUid.Equals(identifier.SeriesInstanceUid, EqualsStringComparison) &&
                       SopInstanceUid.Equals(identifier.SopInstanceUid, EqualsStringComparison));
            }

            return(false);
        }
        public override bool Equals(object obj)
        {
            if (obj is DicomInstanceId instanceId)
            {
                return(StudyInstanceUid.Equals(instanceId.StudyInstanceUid, EqualsStringComparison) &&
                       SeriesInstanceUid.Equals(instanceId.SeriesInstanceUid, EqualsStringComparison) &&
                       SopInstanceUid.Equals(instanceId.SopInstanceUid, EqualsStringComparison) &&
                       PartitionName.Equals(instanceId.PartitionName, EqualsStringComparison));
            }

            return(false);
        }
Example #5
0
 // override object.GetHashCode
 public override int GetHashCode() => SopInstanceUid.GetHashCode();
 public override int GetHashCode()
 {
     return(0x256E197F ^ StudyInstanceUid.GetHashCode() ^ SeriesInstanceUid.GetHashCode() ^ SopInstanceUid.GetHashCode());
 }