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; } }
private void buttonCommitEcho_Click(object sender, System.EventArgs e) { labelEcho.Text = ""; if ((textBoxStorageCommitIPAdd.Text == null) || (textBoxStorageCommitIPAdd.Text.Length == 0)) { MessageBox.Show("Pl Specify SCP IP Address.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } SCU storageScu = new SCU(); storageScu.Initialize(this.threadManager); storageScu.Options.Identifier = "CommitSCPEchoMessage"; storageScu.Options.ResultsFileNameOnlyWithoutExtension = "CommitSCPCEcho_" + System.DateTime.Now.ToString("yyyyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture); storageScu.Options.ResultsDirectory = this.storageOptions.ResultsDirectory; storageScu.Options.LocalAeTitle = textBoxCommitSCPAETitle.Text; storageScu.Options.RemoteAeTitle = textBoxStorageCommitAETitle.Text; storageScu.Options.RemotePort = UInt16.Parse(textBoxStorageCommitPort.Text); storageScu.Options.RemoteHostName = textBoxStorageCommitIPAdd.Text; storageScu.Options.AutoValidate = false; this.userControlActivityLogging.Attach(storageScu); 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; DicomMessage echoMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CECHORQ); storageScu.Start(); bool sendResult = storageScu.TriggerSendAssociationAndWait(echoMessage, presentationContexts); if (!sendResult) { labelEcho.Text = "DICOM Echo failed (See logging for details)"; } else labelEcho.Text = "DICOM Echo successful"; storageScu.Stop(); }
private void buttonEcho_Click(object sender, System.EventArgs e) { //isStorageEcho = true; labelStorageEcho.Text = ""; toolBarButtonResult.Enabled = false; if ((textBoxStorageSCPIPAdd.Text == null) || (textBoxStorageSCPIPAdd.Text.Length == 0)) { MessageBox.Show("Pl Specify SCP IP Address.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //Update DVT & SUT settings this.storageOptions.RemoteAeTitle = textBoxStorageSCPAETitle.Text; this.storageOptions.RemoteHostName = textBoxStorageSCPIPAdd.Text; this.storageOptions.RemotePort = UInt16.Parse(textBoxStorageSCPPort.Text); this.storageOptions.LocalAeTitle = textBoxSCUAETitle.Text; this.storageOptions.ResultsDirectory = validationResultsFileGroup.Directory; SCU echoScu = new SCU(); if (isStopped) { this.overviewThread = new OverviewThread(); this.overviewThread.Initialize(threadManager); this.overviewThread.Options.ResultsDirectory = validationResultsFileGroup.Directory; this.overviewThread.Options.Identifier = "Storage_SCU_Emulator"; this.overviewThread.Options.AttachChildsToUserInterfaces = true; this.overviewThread.Options.LogThreadStartingAndStoppingInParent = false; this.overviewThread.Options.LogWaitingForCompletionChildThreads = false; this.userControlActivityLogging.Attach(overviewThread); String resultsFileName = "StoreSCUEmulator_" + System.DateTime.Now.ToString("yyyyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture); this.overviewThread.Options.ResultsFileNameOnlyWithoutExtension = resultsFileName; // // Start the Dicom Overview Thread // this.overviewThread.Start(); isStopped = false; } echoScu.Initialize(this.overviewThread); echoScu.Options.DeepCopyFrom(this.storageOptions); String resultsFileBaseName = "StoreSCUEcho_" + 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 = this.storageOptions.ResultsDirectory; echoScu.Options.LocalAeTitle = textBoxSCUAETitle.Text; echoScu.Options.RemoteAeTitle = textBoxStorageSCPAETitle.Text; echoScu.Options.RemotePort = UInt16.Parse(textBoxStorageSCPPort.Text); echoScu.Options.RemoteHostName = textBoxStorageSCPIPAdd.Text; //this.userControlActivityLogging.Attach(echoScu); 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; DicomMessage echoMessage = new DicomMessage(DvtkData.Dimse.DimseCommand.CECHORQ); echoScu.Start(); bool sendResult = echoScu.TriggerSendAssociationAndWait(echoMessage, presentationContexts); if (!sendResult) { labelStorageEcho.Text = "DICOM Echo failed (See logging for details)"; } else labelStorageEcho.Text = "DICOM Echo successful"; echoScu.Stop(); toolBarButtonResult.Enabled = true; }