private void AddReferencedSopSequence(ReferencedSopItemCollection storageCommitItems, uint tag, DvtkData.Dimse.AttributeSet attributeSet, InstanceStateEnum newInstanceState) { ushort group = (ushort)(tag >> 16); ushort element = (ushort)(tag & 0x0000FFFF); DvtkData.Dimse.Tag tagValue = new DvtkData.Dimse.Tag(group, element); DvtkData.Dimse.Attribute referencedSopSequence = attributeSet.GetAttribute(tagValue); if (referencedSopSequence != null) { attributeSet.Remove(referencedSopSequence); } referencedSopSequence = new DvtkData.Dimse.Attribute(tag, DvtkData.Dimse.VR.SQ); DvtkData.Dimse.SequenceOfItems referencedSopSequenceOfItems = new DvtkData.Dimse.SequenceOfItems(); referencedSopSequence.DicomValue = referencedSopSequenceOfItems; foreach (ReferencedSopItem referencedSopItem in storageCommitItems) { if ((referencedSopItem.InstanceState == InstanceStateEnum.InstanceStored) && (newInstanceState == InstanceStateEnum.InstanceStorageCommitRequested)) { DvtkData.Dimse.SequenceItem referencedSopSequenceItem = new DvtkData.Dimse.SequenceItem(); referencedSopSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.GroupNumber, DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.ElementNumber, DvtkData.Dimse.VR.UI, referencedSopItem.SopClassUid); referencedSopSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.GroupNumber, DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.ElementNumber, DvtkData.Dimse.VR.UI, referencedSopItem.SopInstanceUid); referencedSopItem.InstanceState = newInstanceState; referencedSopSequenceOfItems.Sequence.Add(referencedSopSequenceItem); } } attributeSet.Add(referencedSopSequence); }
private void menuItemStorageCommit_Click(object sender, System.EventArgs e) { toolBarButtonStoreCommit.Enabled = false; menuItemStorageCommit.Enabled = false; toolBarButtonResult.Enabled = false; //If result tab is present, remove it if(tabControlStorageSCU.Controls.Contains(tabPageResults)) { tabControlStorageSCU.Controls.Remove(tabPageResults); } tabControlStorageSCU.SelectedTab = tabPageLogging; //Update DVT & SUT settings UpdateConfig(); this.storageCommitSCUOptions.ResultsDirectory = validationResultsFileGroup.Directory; this.storageCommitSCUOptions.DataDirectory = this.storageOptions.DataDirectory; toolBarButtonAbort.Enabled = false; CommitScu commitScuThread = new CommitScu(this); 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; } commitScuThread.Initialize(this.overviewThread); commitScuThread.Options.CopyFrom(this.storageCommitSCUOptions); String resultsFileBaseName = "StorageCommitOperationAsSCU_" + System.DateTime.Now.ToString("yyyyMMddHHmmss", System.Globalization.CultureInfo.InvariantCulture); commitScuThread.Options.ResultsFileNameOnlyWithoutExtension = resultsFileBaseName; commitScuThread.Options.Identifier = resultsFileBaseName; commitScuThread.Options.LogThreadStartingAndStoppingInParent = false; commitScuThread.Options.LogWaitingForCompletionChildThreads = false; commitScuThread.Options.AutoValidate = false; DicomMessage nActionStorageCommitment = new DicomMessage(DvtkData.Dimse.DimseCommand.NACTIONRQ); nActionStorageCommitment.Set("0x00000003", DvtkData.Dimse.VR.UI, "1.2.840.10008.1.20.1"); nActionStorageCommitment.Set("0x00001001", DvtkData.Dimse.VR.UI, "1.2.840.10008.1.20.1.1"); // Well known Instance UID nActionStorageCommitment.Set("0x00001008", DvtkData.Dimse.VR.US, 1); DvtkData.Dimse.SequenceItem referencedStudyComponentSequenceItem = new DvtkData.Dimse.SequenceItem(); referencedStudyComponentSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.GroupNumber, DvtkData.Dimse.Tag.REFERENCED_SOP_CLASS_UID.ElementNumber, DvtkData.Dimse.VR.UI, "1.2.840.10008.3.1.2.3.3"); string refSopInstanceUID = UID.Create(); referencedStudyComponentSequenceItem.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.GroupNumber, DvtkData.Dimse.Tag.REFERENCED_SOP_INSTANCE_UID.ElementNumber, DvtkData.Dimse.VR.UI, refSopInstanceUID); nActionStorageCommitment.DataSet.DvtkDataDataSet.AddAttribute(DvtkData.Dimse.Tag.REFERENCED_STUDY_COMPONENT_SEQUENCE.GroupNumber, DvtkData.Dimse.Tag.REFERENCED_STUDY_COMPONENT_SEQUENCE.ElementNumber, DvtkData.Dimse.VR.SQ, referencedStudyComponentSequenceItem); AddReferencedSopSequence(storageCommitItems, 0x00081199, nActionStorageCommitment.DataSet.DvtkDataDataSet, InstanceStateEnum.InstanceStorageCommitRequested); string transUID = UID.Create(); nActionStorageCommitment.DataSet.DvtkDataDataSet.AddAttribute(DvtkData.Dimse.Tag.TRANSACTION_UID.GroupNumber, DvtkData.Dimse.Tag.TRANSACTION_UID.ElementNumber, DvtkData.Dimse.VR.UI, transUID); if (delay < 0) { //toolBarButtonStop.Enabled = true; commitScuThread.setSupportedTS(selectedTS); } commitScuThread.ThreadSettings = this.storageCommitSCUOptions; commitScuThread.Timeout = delay; commitScuThread.NActionMessage = nActionStorageCommitment; commitScuThread.Start(); }