Пример #1
0
        QueryRetrieveInformationModels CreateQueryRetrieveInformationModels(bool randomizeFirst, string directory)
        {
            WriteInformation(string.Format("Creating the QR information model based on data directory : {0}", directory));
            QueryRetrieveInformationModels queryRetrieveInformationModels = new QueryRetrieveInformationModels();

            //Specify directory for temp DCM files
            //String tempDir = Path.Combine(Path.GetTempPath(), "DVTkStorageSCP");
            //if (!Directory.Exists(tempDir))
            //{
            //    Directory.CreateDirectory(tempDir);
            //}

            queryRetrieveInformationModels.DataDirectory = directory;

            DirectoryInfo directoryInfo = new DirectoryInfo(directory);

            FileInfo[] fileInfos = directoryInfo.GetFiles();

            foreach (FileInfo fileInfo in fileInfos)
            {
                if ((fileInfo.Extension.ToLower() == ".dcm") ||
                    (fileInfo.Extension == "") || (fileInfo.Extension == null))
                {
                    try
                    {
                        DvtkHighLevelInterface.Dicom.Files.DicomFile dicomFile = new DvtkHighLevelInterface.Dicom.Files.DicomFile();

                        dicomFile.Read(fileInfo.FullName, this);

                        if (randomizeFirst)
                        {
                            dicomFile.DataSet.Randomize("@");
                        }

                        queryRetrieveInformationModels.Add(dicomFile, false);
                    }

                    catch (Exception)
                    {
                        string theErrorText = string.Format("Invalid DICOM File - {0} will be skiped from QR information model.", fileInfo.FullName);
                        WriteInformation(theErrorText);
                    }
                }
            }

            return(queryRetrieveInformationModels);
        }
Пример #2
0
        /// <summary>
        /// Overridden C-STORE-RQ message handler that makes use of the appropriate Information Model to handle the storage.
        /// </summary>
        /// <param name="queryMessage">C-STORE-RQ and Dataset.</param>
        /// <returns>Boolean - true if dicomMessage handled here.</returns>
        public override bool HandleCStoreRequest(DicomMessage dicomMessage)
        {
            // Validate the received message
            System.String iodName = DicomThread.GetIodNameFromDefinition(dicomMessage);
            DicomThread.Validate(dicomMessage, iodName);

            // update the information models
            if (_informationModels != null)
            {
                // add this dataset to the information models
                _informationModels.Add(dicomMessage.DataSet);
            }

            // set up the default C-STORE-RSP with a successful status
            DicomMessage responseMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CSTORERSP);

            responseMessage.Set("0x00000900", DvtkData.Dimse.VR.US, 0);

            // send the response
            this.Send(responseMessage);

            // message handled
            return(true);
        }
Пример #3
0
        QueryRetrieveInformationModels CreateQueryRetrieveInformationModels(bool randomizeFirst, string directory)
        {
            WriteInformation(string.Format("Creating the QR information model based on data directory : {0}", directory));
            QueryRetrieveInformationModels queryRetrieveInformationModels = new QueryRetrieveInformationModels();

            //Specify directory for temp DCM files
            //String tempDir = Path.Combine(Path.GetTempPath(), "DVTkStorageSCP");
            //if (!Directory.Exists(tempDir))
            //{
            //    Directory.CreateDirectory(tempDir);
            //}

            queryRetrieveInformationModels.DataDirectory = directory;

            DirectoryInfo directoryInfo = new DirectoryInfo(directory);

            FileInfo[] fileInfos = directoryInfo.GetFiles();

            foreach (FileInfo fileInfo in fileInfos)
            {
                if ((fileInfo.Extension.ToLower() == ".dcm") ||
                    (fileInfo.Extension == "") || (fileInfo.Extension == null))
                {
                    try
                    {
                        DvtkHighLevelInterface.Dicom.Files.DicomFile dicomFile = new DvtkHighLevelInterface.Dicom.Files.DicomFile();

                        dicomFile.Read(fileInfo.FullName, this);

                        if (randomizeFirst)
                            dicomFile.DataSet.Randomize("@");

                        queryRetrieveInformationModels.Add(dicomFile, false);
                    }

                    catch (Exception)
                    {
                        string theErrorText = string.Format("Invalid DICOM File - {0} will be skiped from QR information model.", fileInfo.FullName);
                        WriteInformation(theErrorText);
                    }
                }
            }

            return (queryRetrieveInformationModels);
        }