예제 #1
0
        private List <string> ProcessDicomDir
        (
            DirectoryInfo mediaDirectory,
            CompositeInstanceDataSet dicomInstances,
            DicomDir dicomDir,
            IDicomMediaProfileProcessor profileProcessor
        )
        {
            string        rootKey;
            List <string> createdFiles;
            int           patientIndex;
            bool          allowLossyCompression;

            rootKey      = "DICOM";
            createdFiles = new List <string> (dicomInstances.Instance.Count);
            patientIndex = 0;

            allowLossyCompression = (MediaObject.AllowLossyCompression == null ||
                                     MediaObject.AllowLossyCompression.Value != YesNo.No);

            foreach (CompositeInstanceDataSet.PatientRow patient in dicomInstances.Patient)
            {
                string patientKey;
                int    studyIndex;


                patientIndex++;

                patientKey = "PATIENT" + patientIndex.ToString( );
                studyIndex = 0;

                foreach (CompositeInstanceDataSet.StudyRow study in patient.GetStudyRows( ))
                {
                    string studyKey;
                    int    seriesIndex;

                    studyIndex++;

                    studyKey    = "STUDY" + studyIndex.ToString( );
                    seriesIndex = 0;

                    foreach (CompositeInstanceDataSet.SeriesRow series in study.GetSeriesRows( ))
                    {
                        string seriesKey;
                        int    instanceIndex;

                        seriesIndex++;

                        seriesKey     = "SERIES" + seriesIndex.ToString( );
                        instanceIndex = 0;

                        foreach (CompositeInstanceDataSet.InstanceRow instance in series.GetInstanceRows( ))
                        {
                            string instanceKey;
                            string instancePath;

                            instanceIndex++;

                            instanceKey = instanceIndex.ToString( );

                            instancePath = GetInstancePath(mediaDirectory, rootKey, patientKey, studyKey, seriesKey, instanceKey);

                            if (!Directory.Exists(Path.GetDirectoryName(instancePath)))
                            {
                                Directory.CreateDirectory(Path.GetDirectoryName(instancePath));
                            }

                            File.Copy(instance.ReferencedFile, instancePath, true);

                            profileProcessor.BeforeAddingToDicomDir(instancePath, instance, allowLossyCompression);

                            dicomDir.InsertFile(instancePath);

                            profileProcessor.AfterAddingToDicomDir(instancePath, instance, dicomDir.DataSet);

                            createdFiles.Add(instancePath);
                        }
                    }
                }
            }

            return(createdFiles);
        }