Esempio n. 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;

            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);
        }
Esempio n. 2
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;
        }
Esempio n. 3
0
        private static void ValidateMediaFile()
        {
            MediaSession mediaSession = new MediaSession();
            mediaSession.OptionVerbose = _OptionVerbose;
            mediaSession.SessionFileName = (string)_NonOptions[0];
            FileInfo sessionFileName = null;
            if(mediaSession.SessionFileName == "")
            {
                Console.WriteLine("Warning : Provide proper arguments.\n");
                return;
            }
            else
            {
                sessionFileName = new FileInfo(mediaSession.SessionFileName);
            }

            if (!sessionFileName.Exists){
                Console.WriteLine(" Error : Session File  does not exists.\n");
            }else {

                MediaInput mediaInput = new MediaInput();
                string mediaFile = (string)_NonOptions[1];
                FileInfo mediaFileInfo = null;
                if(mediaFile == "")
                {
                    Console.WriteLine("Warning : Provide proper arguments.\n");
                    return;
                }
                else
                {
                    mediaFileInfo = new FileInfo(mediaFile);
                }
                if (!mediaFileInfo.Exists){
                    Console.WriteLine("Error : Media File does not exists.\n");
                }else {
                    mediaInput.FileNames.Add(mediaFile);
                    Console.WriteLine();
                    Console.WriteLine("> Validating media file {0}...", mediaInput.FileNames[0]);
                    mediaSession.Execute(mediaInput);
                    DisplayResultCounters(mediaSession);
                }
            }
        }
Esempio n. 4
0
        /// <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);
        }
Esempio n. 5
0
        private static void ValidateMediaDirectory()
        {
            MediaSession mediaSession = new MediaSession();
            mediaSession.OptionVerbose = _OptionVerbose;
            mediaSession.SessionFileName = (string)_NonOptions[0];
            FileInfo sessionFileName = null;
            ArrayList allDCMFilesTemp = new ArrayList();
            FileInfo mediaFileInfo = null;
            if(mediaSession.SessionFileName == "")
            {
                Console.WriteLine("Warning : Provide proper arguments.\n");
                return;
            }
            else
            {
                sessionFileName = new FileInfo(mediaSession.SessionFileName);
            }

            if (!sessionFileName.Exists)
            {
                Console.WriteLine(" Error : Session File  does not exists.\n");
            }
            else
            {

                MediaInput mediaInput = new MediaInput();
                string mediaFile = (string)_NonOptions[1];
                mediaFileInfo = new FileInfo(mediaFile);

                if(mediaFile == "")
                {
                    Console.WriteLine("Warning : Provide proper arguments.\n");
                    return;
                }
                else if (mediaFileInfo.Exists)
                {
                    allDCMFilesTemp.Add (mediaFileInfo.FullName);
                    mediaInput.FileNames = allDCMFilesTemp;
                    Console.WriteLine();
                    Console.WriteLine("> Validating media file {0}...", mediaInput.FileNames[0]);
                    mediaSession.Execute(mediaInput);
                    DisplayResultCounters(mediaSession);
                    DetermineExitCode(mediaSession);
                }
                else
                {
                    DirectoryInfo theDirectoryInfo = new DirectoryInfo(mediaFile);
                    if (!theDirectoryInfo.Exists)
                    {
                        Console.WriteLine("Error : Directory or File mentioned does not exists.\n");
                    }
                    else
                    {

                        mediaInput.FileNames = GetFilesRecursively(theDirectoryInfo);
                        Console.WriteLine();
                        Console.WriteLine("> Validating media files ...");
                        _exitCode = mediaSession.ExecuteDir(mediaInput);
                        //DisplayResultCounters(mediaSession);
                        //DetermineExitCode(mediaSession);
                    }
                }
            }
        }