Beispiel #1
0
        /// <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;
        }
Beispiel #2
0
        private static void ExecuteScript()
        {
            ScriptSession scriptSession = new ScriptSession();
            scriptSession.SessionFileName = (string)_NonOptions[0];
            scriptSession.OptionVerbose = _OptionVerbose;

            ScriptInput scriptInput = new ScriptInput();
            scriptInput.FileName = (string)_NonOptions[1];
            scriptInput.Arguments = _MainArgs;

            if((scriptSession.SessionFileName == "") || (scriptSession.SessionFileName == ""))
            {
                Console.WriteLine("Warning : Provide proper arguments.\n");
                return;
            }

            string scriptFullFileName = "";
            if (Path.GetDirectoryName(scriptInput.FileName )!= "") {
                    scriptFullFileName = scriptInput.FileName;
                 }
            else {
                scriptFullFileName = Path.Combine(scriptSession.DicomScriptRootDirectory ,scriptInput.FileName);
            }

            FileInfo fileInfoFirstArg = new FileInfo(scriptSession.SessionFileName);
            if(!fileInfoFirstArg.Exists) {
                    Console.WriteLine("Error : Session File does not exists.\n");
                return;
            }
            else {
                string fileExtension = Path.GetExtension(scriptInput.FileName);
                FileInfo fileInfoSecondArg = new FileInfo(scriptFullFileName);
                if (((fileExtension == ".ds") ||(fileExtension == ".dss")||(fileExtension == ".vbs")||(fileExtension == ".vb")) && (fileInfoSecondArg.Exists)){
                    Console.WriteLine("> Executing  Script {0}...", scriptFullFileName);
                    scriptSession.Execute(scriptInput);
                    if (scriptSession.Result) {
                        Console.WriteLine("> Execution succeeded.\n");
                        DisplayResultCounters(scriptSession);
                    }
                    else {
                        Console.WriteLine("> Execution failed.\n");
                        DisplayResultCounters(scriptSession);
                    }
                }
                else if (((fileExtension == ".ds") ||(fileExtension == ".dss")||(fileExtension == ".vbs")||(fileExtension == ".vb")) && (!fileInfoSecondArg.Exists))
                {
                    Console.WriteLine("Error : Script File does not exists.\n");
                }
                else
                {
                    Console.WriteLine("Error : Script File does not exists.\n");
                    ShowCommandLineArguments();
                }
            }
        }
Beispiel #3
0
        public void UpdateScriptSessionNode(TreeNode scriptSessionTreeNode, ScriptSession scriptSession )
        {
            bool isSessionExecuting = scriptSession.IsExecute;
            bool isSessionExecutingInOtherSessionTreeView = (isSessionExecuting && (scriptSession != GetExecutingSession()));
            // Set the tag for this session tree node.

            scriptSessionTreeNode.Tag = scriptSession;
            // Remove the old tree nodes that may be present under this session tree node.
            scriptSessionTreeNode.Nodes.Clear();
            scriptSession.CreateScriptFiles();
            // If this session is executing...
            if (isSessionExecutingInOtherSessionTreeView) {
                // Do nothing.
            }
            else if (!isSessionExecuting) {

                // Create a sub-node for each script file contained in this session.
                if (scriptSession.ScriptFiles == null ){

                }
                else {
                    foreach(Script script in scriptSession.ScriptFiles) {
                        TreeNode scriptNode = new TreeNode();
                        scriptSessionTreeNode.Nodes.Add(scriptNode);
                        UpdateScriptFileNode(scriptNode,script);
                    }
                }
            }
            else {
                // Sanity check, pre-condition of this method is not fullfilled.
                Debug.Assert(false);
            }
        }
Beispiel #4
0
        public void UpdateScriptSessionNode(TreeNode scriptSessionTreeNode, ScriptSession scriptSession, ref bool isEmpty )
        {
            bool isSessionExecuting = scriptSession.IsExecute;
            bool isSessionExecutingInOtherSessionTreeView = (isSessionExecuting && (scriptSession != GetExecutingSession()));
            IList scriptFilesTemp = new ArrayList();

            // Set the tag for this session tree node.
            scriptSessionTreeNode.Tag = scriptSession;

            // Remove the old tree nodes that may be present under this session tree node.
            scriptSessionTreeNode.Nodes.Clear();
            scriptSession.CreateScriptFiles();

            // If this session is executing...
            if (isSessionExecutingInOtherSessionTreeView)
            {
                // Do nothing.
            }
            else if (!isSessionExecuting)
            {
                // Create a sub-node for each script file contained in this session.
                if (scriptSession.ScriptFiles != null)
                {
                    // Determine the visible scripts.
                    ArrayList visibleScripts = GetVisibleScripts(scriptSession);
                    isEmpty = (visibleScripts.Count == 0);
                    foreach (string scriptName in visibleScripts)
                    {
                        foreach (Script script in scriptSession.ScriptFiles)
                        {
                            if (scriptName == script.ScriptFileName)
                            {
                                scriptFilesTemp.Add(script);
                            }
                        }
                    }

                    foreach (Script script in scriptFilesTemp)
                    {
                        TreeNode scriptNode = new TreeNode();
                        scriptSessionTreeNode.Nodes.Add(scriptNode);
                        UpdateScriptFileNode(scriptNode, script);
                    }
                }
                else
                {
                    TreeNode scriptNode = new TreeNode();
                    scriptNode.Text = "Warning: Session doesn't contain any scripts";
                    scriptSessionTreeNode.Nodes.Add(scriptNode);
                }
            }
            else
            {
                // Sanity check, pre-condition of this method is not fullfilled.
                Debug.Assert(false);
            }
        }