コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: SessionManager.cs プロジェクト: ewcasas/DVTK
        /// <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;

            // 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;
            }
            sessionObjects.Add(session);
            return session;
        }
コード例 #3
0
ファイル: DvtCmd.cs プロジェクト: ewcasas/DVTK
        static void Main(string[] arguments)
        {
            _MainArgs = arguments;

            Console.WriteLine();
            Console.WriteLine("> Executing DvtCmd");
            try
            {
                //
                // Initialise dvtk library.
                //
                Dvtk.Setup.Initialize();

                //
                // Determine the options and non-options parameters.
                //
                for (int index = 0; index < arguments.Length; index++)
                {
                    string argument = (string)arguments[index];
                    //
                    // Each option starts with '-'.
                    // For instance;
                    // '-c' <=> Compile Only option.
                    //
                    if (argument.StartsWith("-"))
                    {
                        string optionsString = argument.TrimStart('-');
                        optionsString = optionsString.ToLower();

                        if (optionsString == "c")
                        {
                            _OptionCompileOnly = true;
                        }

                        if (optionsString == "v")
                        {
                            _OptionVerbose = true;
                        }

                        if (optionsString == "m")
                        {
                            _OptionValidateMediaFile = true;
                        }

                        if (optionsString == "estscp")
                        {
                            _OptionEmulatorStorageSCP = true;
                        }

                        if (optionsString == "estscu")
                        {
                            _OptionEmulatorStorageSCU = true;
                        }

                        if (optionsString == "eprscp")
                        {
                            _OptionEmulatorPrintSCP = true;
                        }

                        if (optionsString == "h")
                        {
                            _OptionHelp = true;
                        }
                    }
                    else
                    {
                        _NonOptions.Add(argument);
                    }
                }

                ///
                /// Do the actual thing.
                ///
                if (_OptionHelp)
                {
                    ShowCommandLineArguments();
                }
                else if (_OptionCompileOnly)
                {
                    if (_NonOptions.Count == 1)
                    {
                        String scriptFullFileName = (string)_NonOptions[0];

                        // If this is a Visual Basic Script...
                        if (Path.GetExtension(scriptFullFileName).ToLower() == ".vbs")
                        {
                            // Compile the Visual Basic Script and display progress and errors.
                            ExpandAndCompileVisualBasicScript(scriptFullFileName);
                        }
                        else
                        {
                            ShowCommandLineArguments();
                        }
                    }
                    else
                    {
                        ShowCommandLineArguments();
                    }
                }
                else if (_OptionValidateMediaFile)
                {
                    if (_NonOptions.Count == 2)
                    {
                        ValidateMediaFile();
                    }
                    else
                    {
                        ShowCommandLineArguments();
                    }
                }
                else if (_OptionEmulatorStorageSCP)
                {
                    if (_NonOptions.Count == 1) {
                        FileInfo firstArg = new FileInfo((string)_NonOptions[0]);
                        if (!firstArg.Exists){
                            Console.WriteLine("Error : Session File does not exists");
                        }else {
                            EmulateSCP();
                        }
                    }
                    else {
                        ShowCommandLineArguments();
                    }
                }
                else if (_OptionEmulatorStorageSCU)
                {
                    if (_NonOptions.Count >= 2)
                    {
                        EmulateStorageSCU();
                    }
                    else
                    {
                        ShowCommandLineArguments();
                    }
                }
                else if (_OptionEmulatorPrintSCP)
                {
                    if (_NonOptions.Count == 3)
                    {
                        FileInfo firstArg = new FileInfo((string)_NonOptions[0]);
                        if (!firstArg.Exists){
                            Console.WriteLine("Error : Session File does not exists");
                        }else {
                            EmulateSCP();
                        }
                    }
                    else
                    {
                        ShowCommandLineArguments();
                    }
                }
                else
                    // Execute script.
                {
                    if (_NonOptions.Count == 2)
                    {
                        ExecuteScript();
                    }
                    else
                    {
                        ShowCommandLineArguments();
                    }
                }
            }

            catch(System.Exception theException)
            {
                ShowException(theException);
            }

            finally
            {
                // Clean up
                if( SCPEmulator != null)
                {
                    SCPEmulator = null;
                }

                //
                // Terminate the setup
                //
                Dvtk.Setup.Terminate();
            }

            // Don't show exceptions anymore when cleaning up resources from this application.
            CustomExceptionHandler eh = new CustomExceptionHandler();
            eh.ShowExceptions = false;
            System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(eh.OnAppDomainUnhandledException);
        }
コード例 #4
0
ファイル: DvtCmd.cs プロジェクト: ewcasas/DVTK
        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);
        }
コード例 #5
0
ファイル: DvtCmd.cs プロジェクト: ewcasas/DVTK
        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.");
            }
        }
コード例 #6
0
        public void UpdateEmulatorSessionNode(TreeNode emulatorSessionTreeNode, EmulatorSession emulatorSession)
        {
            bool isSessionExecuting = emulatorSession.IsExecute;
            bool isSessionExecutingInOtherSessionTreeView = (isSessionExecuting && (emulatorSession != GetExecutingSession()));
            // Set the tag for this session tree node.
            emulatorSessionTreeNode.Tag = emulatorSession ;
            // Remove the old tree nodes that may be present under this session tree node.
            emulatorSessionTreeNode.Nodes.Clear();
            emulatorSession.CreateEmulatorFiles();
            if (isSessionExecutingInOtherSessionTreeView) {
                // Do nothing.
            }
            else if (!isSessionExecuting) {
                foreach(Emulator emulator in emulatorSession.Emulators) {
                    if ( emulator.EmulatorName == "Pr_Scp_Em") {
                        TreeNode printScpEmulatorTreeNode = new TreeNode();
                        emulatorSessionTreeNode.Nodes.Add(printScpEmulatorTreeNode);
                        UpdateEmulatorNode(printScpEmulatorTreeNode, emulator);
                    }
                    else if(emulator.EmulatorName == "St_Scp_Em") {
                        // Add the Storage SCP emulator tree node.
                        TreeNode storageScpEmulatorTreeNode = new TreeNode();
                        emulatorSessionTreeNode.Nodes.Add(storageScpEmulatorTreeNode);
                        UpdateEmulatorNode(storageScpEmulatorTreeNode,emulator);

                    }
                    else {
                        // Add the Storage SCU emulator tree node.
                        TreeNode storageScuEmulatorTreeNode = new TreeNode();
                        emulatorSessionTreeNode.Nodes.Add(storageScuEmulatorTreeNode);
                        UpdateEmulatorNode(storageScuEmulatorTreeNode,emulator);
                    }

                }
            }
            else {
                // Sanity check, pre-condition of this method is not fullfilled.
                Debug.Assert(false);
            }
        }
コード例 #7
0
        static void Main(string[] arguments)
        {
            _MainArgs = arguments;

            Console.WriteLine();
            Console.WriteLine("> Executing DvtCmd");
            try
            {
                //
                // Initialise dvtk library.
                //
                Dvtk.Setup.Initialize();

                //
                // Determine the options and non-options parameters.
                //
                for (int index = 0; index < arguments.Length; index++)
                {
                    string argument = (string)arguments[index];
                    //
                    // Each option starts with '-'.
                    // For instance;
                    // '-c' <=> Compile Only option.
                    //
                    if (argument.StartsWith("-"))
                    {
                        string optionsString = argument.TrimStart('-');
                        optionsString = optionsString.ToLower();

                        if (optionsString == "c")
                        {
                            _OptionCompileOnly = true;
                        }

                        if (optionsString == "v")
                        {
                            _OptionVerbose = true;
                        }

                        if (optionsString == "m")
                        {
                            _OptionValidateMediaFile = true;
                        }

                        if (optionsString == "estscp")
                        {
                            _OptionEmulatorStorageSCP = true;
                        }

                        if (optionsString == "estscu")
                        {
                            _OptionEmulatorStorageSCU = true;
                        }

                        if (optionsString == "eprscp")
                        {
                            _OptionEmulatorPrintSCP = true;
                        }

                        if (optionsString == "h")
                        {
                            _OptionHelp = true;
                        }
                    }
                    else
                    {
                        _NonOptions.Add(argument);
                    }
                }

                ///
                /// Do the actual thing.
                ///
                if (_OptionHelp)
                {
                    ShowCommandLineArguments();
                }
                else if (_OptionCompileOnly)
                {
                    if (_NonOptions.Count == 1)
                    {
                        String scriptFullFileName = (string)_NonOptions[0];

                        // If this is a Visual Basic Script...
                        if (Path.GetExtension(scriptFullFileName).ToLower() == ".vbs")
                        {
                            // Compile the Visual Basic Script and display progress and errors.
                            ExpandAndCompileVisualBasicScript(scriptFullFileName);
                        }
                        else
                        {
                            ShowCommandLineArguments();
                        }
                    }
                    else
                    {
                        ShowCommandLineArguments();
                    }
                }
                else if (_OptionValidateMediaFile)
                {
                    if (_NonOptions.Count == 2)
                    {
                        ValidateMediaFile();
                    }
                    else
                    {
                        ShowCommandLineArguments();
                    }
                }
                else if (_OptionEmulatorStorageSCP)
                {
                    if (_NonOptions.Count == 1)
                    {
                        FileInfo firstArg = new FileInfo((string)_NonOptions[0]);
                        if (!firstArg.Exists)
                        {
                            Console.WriteLine("Error : Session File does not exists");
                        }
                        else
                        {
                            EmulateSCP();
                        }
                    }
                    else
                    {
                        ShowCommandLineArguments();
                    }
                }
                else if (_OptionEmulatorStorageSCU)
                {
                    if (_NonOptions.Count >= 2)
                    {
                        EmulateStorageSCU();
                    }
                    else
                    {
                        ShowCommandLineArguments();
                    }
                }
                else if (_OptionEmulatorPrintSCP)
                {
                    if (_NonOptions.Count == 3)
                    {
                        FileInfo firstArg = new FileInfo((string)_NonOptions[0]);
                        if (!firstArg.Exists)
                        {
                            Console.WriteLine("Error : Session File does not exists");
                        }
                        else
                        {
                            EmulateSCP();
                        }
                    }
                    else
                    {
                        ShowCommandLineArguments();
                    }
                }
                else
                // Execute script.
                {
                    if (_NonOptions.Count == 2)
                    {
                        ExecuteScript();
                    }
                    else
                    {
                        ShowCommandLineArguments();
                    }
                }
            }

            catch (System.Exception theException)
            {
                ShowException(theException);
            }

            finally
            {
                // Clean up
                if (SCPEmulator != null)
                {
                    SCPEmulator = null;
                }

                //
                // Terminate the setup
                //
                Dvtk.Setup.Terminate();
            }

            // Don't show exceptions anymore when cleaning up resources from this application.
            CustomExceptionHandler eh = new CustomExceptionHandler();

            eh.ShowExceptions = false;
            System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(eh.OnAppDomainUnhandledException);
        }