private void echoButton_Click(object sender, RoutedEventArgs e) { // Store the details of the daemon (Ae Title , IP , port ) var daemon = new Entity(DaemonTitleTextBox.Text, DaemonIpTextBox.Text, int.Parse(DaemonPortTextBox.Text)); // Store the details of the client (Ae Title , port ) -> IP address is determined by CreateLocal() method var local = Entity.CreateLocal(AEtitleTextBox.Text, int.Parse(AEportTextBox.Text)); // Set up a client ( DICOM SCU = Service Class User ) var client = new DICOMSCU(local); var storer = client.GetCStorer(daemon); //ushort msgId = 1; var canPing = client.Ping(daemon); if (canPing) { echoButton.Background = System.Windows.Media.Brushes.LawnGreen; ShowLogMsg("\nImport is possible. Echo to Daemon succeeded."); ProgressTextBlock.Text = "Echo succeeded. Press Start to begin Import."; } else { echoButton.Background = System.Windows.Media.Brushes.PaleVioletRed; ShowLogMsg("\nNo import is possible. Echo to Daemon failed."); ProgressTextBlock.Text = "Echo failed. Import will also fail."; } }
/// <summary> /// This tutorial is outlined in chapter 4 of Scripting in RT for Physicists (C-ECHO) /// </summary> public static void Run() { //Store the details of the daemon (Ae Title, IP, port) var daemon = new Entity("PHYSX_DICOM", "10.22.86.64", 51402); //Store the details of the client (Ae Title, port) -> IP address is determined by CreateLocal() method var local = Entity.CreateLocal("DICOMEC1", 9999); //Set up a client (DICOM SCU = Service Class User) var client = new DICOMSCU(local); //TRY C-ECHO var canPing = client.Ping(daemon); //Write results to console Console.WriteLine($"DICOM C-Echo from {local.AeTitle} => " + $"{daemon.AeTitle} @{daemon.IpAddress}:{daemon.Port} was successfull? {canPing}"); Console.Read(); //Stop here }
private void runButton_Click(object sender, RoutedEventArgs e) { // Store the details of the daemon (Ae Title , IP , port ) var daemon = new Entity(DaemonTitleTextBox.Text, DaemonIpTextBox.Text, int.Parse(DaemonPortTextBox.Text)); // Store the details of the client (Ae Title , port ) -> IP address is determined by CreateLocal() method var local = Entity.CreateLocal(AEtitleTextBox.Text, int.Parse(AEportTextBox.Text)); // Set up a client ( DICOM SCU = Service Class User ) var client = new DICOMSCU(local); var storer = client.GetCStorer(daemon); ushort msgId = 1; var canPing = client.Ping(daemon); if (canPing) { echoButton.Background = System.Windows.Media.Brushes.LawnGreen; progressBar.Value = 0; runButton.IsEnabled = false; if (!Directory.Exists(outputFolderPath)) { Directory.CreateDirectory(outputFolderPath); } runButton.IsEnabled = false; string dir = inputFolderPath; var toAnonymize = Enumerable.Empty <string>(); if (subDirCheckBox.IsChecked == false) { toAnonymize = Directory.GetFiles(dir).Where(f => DumpSingleDicomTag(f, "0008,0060") != "fail" & !Path.GetFileName(f).Contains("_ignore")); } else { toAnonymize = Directory.GetFiles(dir, "*", SearchOption.AllDirectories).Where(f => DumpSingleDicomTag(f, "0008,0060") != "fail" & !Path.GetFileName(f).Contains("_ignore")); } int np = toAnonymize.Count(); ShowLogMsg("\nNew import process has started."); ShowLogMsg("Number of DICOM files for importing: " + np.ToString() + "\n"); int count = 1; bool importSuccess = true; foreach (var file in toAnonymize) { // Reads DICOM object into memory var dcm = EvilDICOM.Core.DICOMObject.Read(file); var response = storer.SendCStore(dcm, ref msgId); // Write results to console //await Task.Run(() => ShowLogMsg($" DICOM C-Store of {Path.GetFileName(file)} from { local.AeTitle } => { daemon.AeTitle } {(EvilDICOM.Network.Enums.Status)response.Status }")); progressBar.Value = count * 100 / np; ProgressTextBlock.Text = "Import in progress...."; count++; } if (importSuccess == true) { ShowLogMsg("\nImport completed successfully."); ShowLogMsg(""); ProgressTextBlock.Text = "Import completed successfully"; progressBar.Value = 100; } else { ShowLogMsg("\nImport completed with Erros."); ShowLogMsg(""); ProgressTextBlock.Text = "Import completed with Errors"; progressBar.Value = 100; } runButton.IsEnabled = true; } else { echoButton.Background = System.Windows.Media.Brushes.PaleVioletRed; ShowLogMsg("\nNo import is possible. Echo to Daemon failed."); ProgressTextBlock.Text = "Echo failed. No Import was done."; } }