private static void ExecuteSCP() { EmulatorSession emulatorSession = new EmulatorSession(); emulatorSession.OptionVerbose = _OptionVerbose; string sessionFileName = (string)_NonOptions[0]; if (sessionFileName == "") { Console.WriteLine("Warning : Provide proper arguments.\n"); return; } else { emulatorSession.SessionFileName = sessionFileName; } SCPEmulator = emulatorSession; emulatorSession.scpEmulatorType = DvtkApplicationLayer.EmulatorSession.ScpEmulatorType.Storage; if (_OptionEmulatorPrintSCP) { emulatorSession.scpEmulatorType = DvtkApplicationLayer.EmulatorSession.ScpEmulatorType.Printing; } EmulatorInput emulatorInput = new EmulatorInput(); emulatorSession.Execute(emulatorInput); }
/// <summary> /// Create the instance of a seesion according to the session type. /// </summary> /// <param name="fileName">represents the sessionfile name.</param> /// <returns>instance of a session.</returns> public Session CreateSession(string fileName) { Session session = null; try { // Open the file and determine the SessionType Session.SessionType sessionType = DetermineSessionType(fileName); switch (sessionType) { case Session.SessionType.ST_MEDIA: session = new MediaSession(fileName); break; case Session.SessionType.ST_SCRIPT: session = new ScriptSession(fileName); break; case Session.SessionType.ST_EMULATOR: session = new EmulatorSession(fileName); break; case Session.SessionType.ST_UNKNOWN: break; } if (session != null) { sessionObjects.Add(session); } } catch (Exception ex) { session = null; Exception excp; throw excp = new Exception(ex.Message); } return(session); }
/// <summary> /// Save the session under a new file name. /// /// A new session object will be created from this new saved file (and returned by this method) /// and added to the project. The original session wil not be saved. /// </summary> /// <param name="theCurrentSession"></param> /// <returns>The new created session object, null if save as a new session has been cancelled or failed.</returns> public Session SaveSessionAs(Session theCurrentSession) { Session theNewSession = null; SaveFileDialog theSaveFileDialog = new SaveFileDialog(); theSaveFileDialog.AddExtension = true; theSaveFileDialog.DefaultExt = ".ses"; theSaveFileDialog.OverwritePrompt = false; theSaveFileDialog.Filter = "All session files (*.ses)|*.ses"; DialogResult theDialogResult = theSaveFileDialog.ShowDialog(); // User has specified a file name and has pressed the OK button. if (theDialogResult == DialogResult.OK) { if (File.Exists(theSaveFileDialog.FileName)) { MessageBox.Show(string.Format("File name \"{0}\" already exists.\nOperation cancelled", theSaveFileDialog.FileName)); } else { // Save the current session to a new file. string theCurrentSessionFullFileName = theCurrentSession.SessionFileName; theCurrentSession.SessionFileName = theSaveFileDialog.FileName; theCurrentSession.Save(); Session.SessionType sessionType = theCurrentSession.sessionType ; // Create a new session object from this new saved file and replace the current session. switch(sessionType) { case Session.SessionType.ST_MEDIA: theNewSession = new MediaSession(theSaveFileDialog.FileName); LoadSession(); break; case Session.SessionType.ST_SCRIPT: theNewSession = new ScriptSession(theSaveFileDialog.FileName); LoadSession(); break; case Session.SessionType.ST_EMULATOR: theNewSession = new EmulatorSession(theSaveFileDialog.FileName); LoadSession(); break; case Session.SessionType.ST_UNKNOWN: break; } // Create a new session object from this new saved file and replace the current session. if (theNewSession != null) { int theCurrentIndex = GetLoadedSessionsIndex(theCurrentSession); parentProject.Sessions[theCurrentIndex] = theNewSession; parentProject.HasProjectChanged = true; } } } return(theNewSession); }
/// <summary> /// Save the session under a new file name. /// /// A new session object will be created from this new saved file (and returned by this method) /// and added to the project. The original session wil not be saved. /// </summary> /// <param name="theCurrentSession"></param> /// <returns>The new created session object, null if save as a new session has been cancelled or failed.</returns> public Session SaveSessionAs(Session theCurrentSession) { Session theNewSession = null; SaveFileDialog theSaveFileDialog = new SaveFileDialog(); theSaveFileDialog.AddExtension = true; theSaveFileDialog.DefaultExt = ".ses"; theSaveFileDialog.OverwritePrompt = false; theSaveFileDialog.Filter = "All session files (*.ses)|*.ses"; DialogResult theDialogResult = theSaveFileDialog.ShowDialog(); // User has specified a file name and has pressed the OK button. if (theDialogResult == DialogResult.OK) { if (File.Exists(theSaveFileDialog.FileName)) { MessageBox.Show(string.Format("File name \"{0}\" already exists.\nOperation cancelled", theSaveFileDialog.FileName)); } else { // Save the current session to a new file. string theCurrentSessionFullFileName = theCurrentSession.SessionFileName; theCurrentSession.SessionFileName = theSaveFileDialog.FileName; theCurrentSession.Save(); Session.SessionType sessionType = theCurrentSession.sessionType; // Create a new session object from this new saved file and replace the current session. switch (sessionType) { case Session.SessionType.ST_MEDIA: theNewSession = new MediaSession(theSaveFileDialog.FileName); LoadSession(); break; case Session.SessionType.ST_SCRIPT: theNewSession = new ScriptSession(theSaveFileDialog.FileName); LoadSession(); break; case Session.SessionType.ST_EMULATOR: theNewSession = new EmulatorSession(theSaveFileDialog.FileName); LoadSession(); break; case Session.SessionType.ST_UNKNOWN: break; } // Create a new session object from this new saved file and replace the current session. if (theNewSession != null) { int theCurrentIndex = GetLoadedSessionsIndex(theCurrentSession); parentProject.Sessions[theCurrentIndex] = theNewSession; parentProject.HasProjectChanged = true; } } } return(theNewSession); }
private static void EmulateStorageSCU() { EmulatorSession emulatorSession = new EmulatorSession(); emulatorSession.OptionVerbose = _OptionVerbose; string sessionFileName = (string)_NonOptions[0]; FileInfo sessionFileInfo = null; if (sessionFileName == "") { Console.WriteLine("Warning : Provide proper arguments.\n"); return; } else { sessionFileInfo = new FileInfo(sessionFileName); } if (!sessionFileInfo.Exists) { Console.WriteLine("Error : Session File does not exists.\n"); } else { emulatorSession.SessionFileName = sessionFileName; emulatorSession.scuEmulatorType = DvtkApplicationLayer.EmulatorSession.ScuEmulatorType.Storage; EmulatorInput emulatorInput = new EmulatorInput(); // // Determine all media file names by parsing the string. // string mediaFiles = (string)_NonOptions[1]; string[] mediaFileNames = null; if (mediaFiles != "") { mediaFileNames = mediaFiles.Split(new char[] { ',' }); } else { Console.WriteLine("Warning : Provide proper arguments.\n"); return; } // // Trim whitespaces from both ends of the Media File Names // for (int i = 0; i < mediaFileNames.Length; i++) { emulatorInput.FileNames.Add(mediaFileNames[i].Trim()); } // // Determine Association option. // if (_NonOptions.Count == 3) { emulatorInput.ModeOfAssociation = (bool)_NonOptions[2]; } // // Determine Validate on import option. // if (_NonOptions.Count == 4) { emulatorInput.ValidateOnImport = (bool)_NonOptions[3]; } // // Determine send data under new study option. // if (_NonOptions.Count == 5) { emulatorInput.DataUnderNewStudy = (bool)_NonOptions[4]; } // // Determine Nr. of Repetiitons. // if (_NonOptions.Count == 6) { emulatorInput.NosOfRepetitions = (UInt16)_NonOptions[5]; } emulatorSession.Execute(emulatorInput); if (emulatorSession.Result) { Console.WriteLine("> Started Storage SCU Emulator successfully."); DisplayResultCounters(emulatorSession); } else { Console.WriteLine("> Error in starting Storage SCU Emulator."); } Console.WriteLine("> Sent the Data through Storage SCU Emulator successfully."); } }