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(); }
public StorageSCUEmulator() { // // Required for Windows Form Designer support // InitializeComponent(); InitializeBackgoundWorker(); this.dvtkWebBrowserSCUEmulator.XmlStyleSheetFullFileName = applDirectory + "\\DVT_RESULTS.xslt"; this.dvtkWebBrowserSCUEmulator.BackwardFormwardEnabledStateChangeEvent +=new DvtkApplicationLayer.UserInterfaces.DvtkWebBrowserNew.BackwardFormwardEnabledStateChangeEventHandler(dvtkWebBrowserSCUEmulator_BackwardFormwardEnabledStateChangeEvent); this.dvtkWebBrowserSCUEmulator.ErrorWarningEnabledStateChangeEvent += new DvtkWebBrowserNew.ErrorWarningEnabledStateChangeEventHandler(dvtkWebBrowserSCUEmulator_ErrorWarningEnabledStateChangeEvent); selectedTS.Add("1.2.840.10008.1.2"); selectedTS.Add("1.2.840.10008.1.2.1"); selectedTS.Add("1.2.840.10008.1.2.2"); // // Set the .Net thread name for debugging purposes. // System.Threading.Thread.CurrentThread.Name = "Storage SCU Emulator"; this.threadsStateChangeEventHandler = new ThreadManager.ThreadsStateChangeEventHandler(this.HandleThreadsStateChangeEvent); updateUIControlsHandler = new UpdateUIControlsDelegate(UpdateUIControls); updateUIControlsFromBGThreadHandler = new UpdateUIControlsFromBGThreadDelegate(UpdateUIControlsFromBGThread); this.threadManager = new ThreadManager(); this.threadManager.ThreadsStateChangeEvent += this.threadsStateChangeEventHandler; // // Stored files options. // this.fileGroups = new FileGroups("Storage SCU Emulator"); this.validationResultsFileGroup = new ValidationResultsFileGroup(); this.validationResultsFileGroup.DefaultFolder = "Results"; this.fileGroups.Add(validationResultsFileGroup); this.fileGroups.CreateDirectories(); this.fileGroups.CheckIsConfigured("\"Stored Files\\Options...\" menu item"); // Set Storage thread StoreScu storageScu = new StoreScu(); storageScu.Initialize(this.threadManager); this.storageOptions = storageScu.Options; this.storageOptions.LoadFromFile(Path.Combine(applDirectory, "StorageSCUEmulator.ses")); this.storageOptions.StorageMode = Dvtk.Sessions.StorageMode.AsMediaOnly; this.storageOptions.ResultsDirectory = validationResultsFileGroup.Directory; this.storageOptions.DataDirectory = validationResultsFileGroup.Directory; //Environment.CurrentDirectory = this.storageOptions.ResultsDirectory; //Set the Commit thread CommitScu commitScu = new CommitScu(this); commitScu.Initialize(this.threadManager); this.storageCommitSCUOptions = commitScu.Options; this.storageCommitSCUOptions.LoadFromFile(Path.Combine(applDirectory, "CommitSCUEmulator.ses")); this.storageCommitSCUOptions.ResultsDirectory = validationResultsFileGroup.Directory; this.storageCommitSCUOptions.DataDirectory = validationResultsFileGroup.Directory; // Make sure the session files contain the same information as the Stored Files user settings. SaveToSessionFiles(this.storageOptions, this.storageCommitSCUOptions); this.storageCommitItems = new ReferencedSopItemCollection(); }