Exemple #1
0
        private bool HandleSubOperation(System.String moveDestinationAE, System.String dcmFilename, int subOperationIndex)
        {
            SCU storageScu = new SCU();

            storageScu.Initialize(DicomThread.ThreadManager);
            storageScu.Options.DeepCopyFrom(DicomThread.Options);

            storageScu.Options.Identifier = "StorageSubOperationAsScu";

            ////Check for Secure connection
            //if (DicomThread.Options.SecureConnection)
            //{
            //    storageScu.Options.SecureConnection = true;
            //    storageScu.Options.CertificateFilename = DicomThread.Options.CertificateFilename;
            //    storageScu.Options.CredentialsFilename = DicomThread.Options.CredentialsFilename;
            //}

            storageScu.Options.ResultsFileNameOnlyWithoutExtension = "StorageSubOperationAsScu" + subOperationIndex.ToString();
            storageScu.Options.ResultsDirectory = DicomThread.Options.ResultsDirectory;

            storageScu.Options.LocalAeTitle = DicomThread.Options.LocalAeTitle;
            storageScu.Options.LocalPort    = DicomThread.Options.LocalPort;
            if (IsHaveMoveDestinations)
            {
                storageScu.Options.RemoteAeTitle  = moveDestinationAE;
                storageScu.Options.RemotePort     = MoveDestiantions[MoveAEdetailsIndex].Port;
                storageScu.Options.RemoteHostName = MoveDestiantions[MoveAEdetailsIndex].IP;
            }
            else
            {
                storageScu.Options.RemoteAeTitle  = moveDestinationAE;
                storageScu.Options.RemotePort     = DicomThread.Options.RemotePort;
                storageScu.Options.RemoteHostName = DicomThread.Options.RemoteHostName;
            }

            storageScu.Options.DataDirectory = DicomThread.Options.DataDirectory;
            storageScu.Options.StorageMode   = Dvtk.Sessions.StorageMode.AsDataSet;

            // Read the DCM File
            DicomFile dcmFile = new DicomFile();

            dcmFile.Read(dcmFilename, storageScu);

            FileMetaInformation fMI = dcmFile.FileMetaInformation;

            // Get the transfer syntax and SOP class UID
            System.String transferSyntax = "1.2.840.10008.1.2";
            if ((fMI != null) && fMI.Exists("0x00020010"))
            {
                // Get the Transfer syntax
                DvtkHighLevelInterface.Dicom.Other.Attribute tranferSyntaxAttr = fMI["0x00020010"];
                transferSyntax = tranferSyntaxAttr.Values[0];
            }

            Values values = dcmFile.DataSet["0x00080016"].Values;

            System.String sopClassUid = values[0];

            PresentationContext presentationContext = new PresentationContext(sopClassUid,             // Abstract Syntax Name
                                                                              transferSyntax);         // Transfer Syntax Name(s)

            PresentationContext[] presentationContexts = new PresentationContext[1];
            presentationContexts[0] = presentationContext;

            DicomMessage storageMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CSTORERQ);

            storageMessage.DataSet.CloneFrom(dcmFile.DataSet);

            storageScu.Start();

            bool sendResult = storageScu.TriggerSendAssociationAndWait(storageMessage, presentationContexts);

            if (!sendResult)
            {
                WriteWarning("Association to move destination for Storage Sub-Operation is rejected.");
            }

            if (storageScu.HasExceptionOccured)
            {
                WriteError("Storage Sub-Operation As SCU Failed");
            }
            storageScu.Stop();

            DicomMessageCollection cStoreResponses = storageScu.Messages.DicomMessages.CStoreResponses;

            // Obtain the value of the C-STORE RSP.The value of this variable is used to determine the attributes of the C-MOVE RSP.
            foreach (DicomMessage cStoreRsp in cStoreResponses)
            {
                cStoreStatusVal = Int32.Parse(cStoreRsp.CommandSet.GetValues("0x00000900")[0]);
            }

            // Transform the sub results
            Xslt.StyleSheetFullFileName = DicomThread.Options.StyleSheetFullFileName;
            System.String htmlResultsFilename = Xslt.Transform(storageScu.Options.ResultsDirectory, storageScu.Options.ResultsFileNameOnly);

            // Make link to the sub-operation results file
            System.String message = System.String.Format("<a href=\"{0}\">Storage sub-operation {1} to AE Title \"{2}\"</a><br/>",
                                                         htmlResultsFilename,
                                                         subOperationIndex,
                                                         moveDestinationAE);
            DicomThread.WriteHtmlInformation(message);

            return(sendResult);
        }
        private void dICOMEchoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string detailedEchoFileName = "";

            if (registeredPeersGrid.SelectedIndices.Count > 0)
            {
                int selectedIndex = registeredPeersGrid.SelectedIndices[0];

                //isStorageEcho = true;
                allThreadsFinished = false;
                if ((peers[selectedIndex].IP == null) || (peers[selectedIndex].IP.Length == 0))
                {
                    MessageBox.Show("Pl Specify SCP IP Address.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                //Update DVT & SUT settings
                OverviewThread overviewThread = new OverviewThread();
                overviewThread.Initialize(threadManager);
                overviewThread.Options.DeepCopyFrom(options);
                overviewThread.Options.Identifier = "Move_Destinations";
                overviewThread.Options.AttachChildsToUserInterfaces         = true;
                overviewThread.Options.LogThreadStartingAndStoppingInParent = false;
                overviewThread.Options.LogWaitingForCompletionChildThreads  = false;
                String resultsFileName = "MoveDestinations_" + System.DateTime.Now.ToString("yyyyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture);
                overviewThread.Options.ResultsFileNameOnlyWithoutExtension = resultsFileName;


                SCU echoScu = new SCU();
                echoScu.Initialize(overviewThread);
                echoScu.Options.DeepCopyFrom(options);

                String resultsFileBaseName = "MoveDestinationsEcho_" + System.DateTime.Now.ToString("yyyyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture);
                echoScu.Options.ResultsFileNameOnlyWithoutExtension = resultsFileBaseName;
                echoScu.Options.Identifier = resultsFileBaseName;

                echoScu.Options.LogThreadStartingAndStoppingInParent = false;
                echoScu.Options.LogWaitingForCompletionChildThreads  = false;
                echoScu.Options.AutoValidate     = false;
                echoScu.Options.ResultsDirectory = options.ResultsDirectory;

                //echoScu.Options.LocalAeTitle ="SCU";
                echoScu.Options.RemoteAeTitle  = peers[selectedIndex].AE;
                echoScu.Options.RemotePort     = peers[selectedIndex].Port;
                echoScu.Options.RemoteHostName = peers[selectedIndex].IP;
                //this.userControlActivityLogging.Attach(echoScu);

                detailedEchoFileName = echoScu.Options.DetailResultsFullFileName;
                PresentationContext presentationContext = new PresentationContext("1.2.840.10008.1.1",  // Abstract Syntax Name
                                                                                  "1.2.840.10008.1.2"); // Transfer Syntax Name(s)
                PresentationContext[] presentationContexts = new PresentationContext[1];
                presentationContexts[0] = presentationContext;

                DvtkHighLevelInterface.Dicom.Messages.DicomMessage echoMessage = new DvtkHighLevelInterface.Dicom.Messages.DicomMessage(DvtkData.Dimse.DimseCommand.CECHORQ);

                echoScu.Start();

                bool sendResult = echoScu.TriggerSendAssociationAndWait(echoMessage, presentationContexts);

                if (!sendResult)
                {
                    MessageBox.Show("DICOM Echo failed ", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("DICOM Echo successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                echoScu.Stop();
                if (OnShowEchoResults != null)
                {
                    OnShowEchoResults.Invoke(detailedEchoFileName, sendResult);
                }
                allThreadsFinished = false;
            }
        }