Beispiel #1
0
        public void Execute()
        {
            string errorTextFromIsFileInUse;

            if (!Directory.Exists(GetSelectedSession().ResultsRootDirectory))
            {
                MessageBox.Show("The results directory specified for this session is not valid.\nExecution is cancelled.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else if (IsFileInUse(GetSelectedTreeNodeTag(), out errorTextFromIsFileInUse))
            {
                string firstPartWarningText = "";

                if (GetSelectedTreeNodeTag() is ScriptFileTag)
                {
                    firstPartWarningText = "Unable to execute script.\n\n";
                }
                else if (GetSelectedTreeNodeTag() is EmulatorTag)
                {
                    firstPartWarningText = "Unable to execute emulator.\n\n";
                }

                MessageBox.Show(firstPartWarningText + errorTextFromIsFileInUse + "\n\n(hint: change the session ID to obtain a different results file name)", "Warning");
            }
            else
            {
                _TagThatIsBeingExecuted  = GetSelectedTreeNodeTag();

                // Update the UI.
                StartExecution theStartExecution = new StartExecution(GetSelectedNode());
                Notify(theStartExecution);

                // If this is a script file tag, start execution of the script.
                if (_TagThatIsBeingExecuted is ScriptFileTag)
                {
                    ExecuteSelectedScript();
                }

                // If this is a emulator tag, start execution of the correct emulator.
                if (_TagThatIsBeingExecuted is EmulatorTag)
                {
                    ExecuteSelectedEmulator();
                }

                // If this is a media session tag, start execution of the media validator.
                if (_TagThatIsBeingExecuted is MediaSessionTag)
                {
                    ExecuteSelectedMediaSession();
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// This method performs the validation of a media direcetory
        /// </summary>
        /// <param name="MediaDirectoryInfo"></param>
        public void Execute(DirectoryInfo MediaDirectoryInfo)
        {
            _ISMediaDirectoryValidation = true;
            string errorTextFromIsFileInUse;
            DvtkApplicationLayer.Session session = GetSession();
            session.IsExecute = true;

            if (!Directory.Exists(session.ResultsRootDirectory))
            {
                MessageBox.Show("The results directory specified for this session is not valid.\nExecution is cancelled.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                session.IsExecute = false;
            }
            else if (IsFileInUse(GetSelectedTag(), out errorTextFromIsFileInUse))
            {
                string firstPartWarningText = "";

                if (GetSelectedTag() is Script)
                {
                    firstPartWarningText = "Unable to execute script.\n\n";
                }
                else if (GetSelectedTag() is Emulator)
                {
                    firstPartWarningText = "Unable to execute emulator.\n\n";
                }

                MessageBox.Show(firstPartWarningText + errorTextFromIsFileInUse + "\n\n(hint: change the session ID to obtain a different results file name)", "Warning");
            }
            else
            {
                _TagThatIsBeingExecuted = GetSelectedTag();

                /* if session is an emulator session or a script session .
                 * Since media session do not require any connection to have
                 * secured connection*/
                if ((_TagThatIsBeingExecuted is DvtkApplicationLayer.Emulator) || (_TagThatIsBeingExecuted is DvtkApplicationLayer.DicomScript))
                {
                    bool bDisplayPwdMsg = false;
                    bool bPwdMsg = true;
                    int certIndex = 0;
                    int credIndex = 0;

                    Dvtk.Sessions.ISecuritySettings theISecuritySettings = null;
                    theISecuritySettings = (GetSelectedSessionNew().Implementation as Dvtk.Sessions.ISecure).SecuritySettings;

                    /* If the session selected has security settings enabled
                      */
                    if (theISecuritySettings.SecureSocketsEnabled == true)
                    {

                        certIndex = theISecuritySettings.CertificateFileName.LastIndexOf("\\");
                        credIndex = theISecuritySettings.CredentialsFileName.LastIndexOf("\\");

                        /* if Certificate file name not specified */
                        if ((certIndex + 1) == theISecuritySettings.CertificateFileName.Length)
                        {
                            MessageBox.Show("Session cannot be executed as the certificate name is not specified ");

                            _TagThatIsBeingExecuted = null;
                            bDisplayPwdMsg = true;
                        }
                        /* if Certificate file donot exist */
                        else if (!File.Exists(theISecuritySettings.CertificateFileName))
                        {
                            MessageBox.Show("Certificate File does not exist ");
                            _TagThatIsBeingExecuted = null;
                            bDisplayPwdMsg = true;
                        }
                        /* if Credential file name not specified */
                        else if ((credIndex + 1) == theISecuritySettings.CredentialsFileName.Length)
                        {
                            MessageBox.Show("Session can not be executed as the credential name is not specified ");
                            _TagThatIsBeingExecuted = null;
                            bDisplayPwdMsg = true;
                        }
                        /* If credential file donot exist */
                        else if (!File.Exists(theISecuritySettings.CredentialsFileName))
                        {
                            MessageBox.Show("Credential File do not exist ");
                            _TagThatIsBeingExecuted = null;
                            bDisplayPwdMsg = true;
                        }

                        (GetSelectedSessionNew().Implementation as Dvtk.Sessions.ISecure).SecuritySettings.TlsPassword = "******";

                        while (!bDisplayPwdMsg)
                        {
                            try
                            {
                                (GetSelectedSessionNew().Implementation as Dvtk.Sessions.ISecure).CreateSecurityCredentialHandler();
                                bDisplayPwdMsg = true;
                                (GetSelectedSessionNew().Implementation as Dvtk.Sessions.ISecure).DisposeSecurityCredentialHandler();
                            }
                            catch (Exception theException)
                            {
                                if (theException.GetType().FullName == "Wrappers.Exceptions.PasswordExpection")
                                {
                                    bDisplayPwdMsg = false;
                                    PassWordForm passWordForm = new PassWordForm(GetSelectedSessionNew(), bPwdMsg);
                                    bPwdMsg = false;
                                    if (passWordForm.ShowDialog() != DialogResult.OK)
                                    {
                                        bDisplayPwdMsg = true;
                                        bPwdMsg = false;

                                        _TagThatIsBeingExecuted = null;
                                    }
                                }
                                else
                                {
                                    MessageBox.Show(theException.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    bDisplayPwdMsg = true;

                                    _TagThatIsBeingExecuted = null;

                                }

                            }
                        }
                    }
                }

                if (_TagThatIsBeingExecuted != null)
                {
                    // Update the UI.
                    StartExecution theStartExecution = new StartExecution(GetSelectedUserNode());
                    Notify(theStartExecution);

                    // If this is a script file tag, start execution of the script.
                    if (_TagThatIsBeingExecuted is Script)
                    {
                        ExecuteSelectedScript();
                    }

                    // If this is a emulator tag, start execution of the correct emulator.
                    if (_TagThatIsBeingExecuted is Emulator)
                    {
                        ExecuteSelectedEmulator();
                    }

                    // If this is a media session tag, start execution of the media validator.
                    if (_TagThatIsBeingExecuted is DvtkApplicationLayer.MediaSession)
                    {

                        ExecuteMediaDirectoryValidation(MediaDirectoryInfo);

                    }
                    else
                    {
                        session.IsExecute = false;
                        // Update the UI.
                        EndExecution theEndExecution = new EndExecution(GetSelectedTag());
                        Notify(theEndExecution);
                    }
                }
            }
        }