Beispiel #1
0
        /// <summary>
        /// Closes the currently running version of the wtm
        /// </summary>
        /// <returns></returns>
        public bool Close()
        {
            WTMVersion version = IsRunning();

            if (version != null)
            {
                bool result = version.Close();
                if (result && WTMClosed != null)
                {
                    WTMClosed(version);
                }
                return(result);
            }
            else
            {
                return(true);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Restarts currently running version of the wtm
        /// </summary>
        public bool Restart()
        {
            WTMVersion version = IsRunning();

            if (version != null)
            {
                if (version.Close())
                {
                    if (version.Open())
                    {
                        if (WTMRestarted != null)
                        {
                            WTMRestarted(version);
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// Use the given oem, makes the necessary folder name changes
        /// </summary>
        /// <param name="oemToUse">OEM to use</param>.
        /// <returns>Returns the WTM Version that was closed during the process if any</returns>
        /// <exception cref="Valutech.Agilent.UnableToCloseWTMException">Thrown when the wtm was not able to get closed by the system</exception>
        /// <exception cref="Valutech.Agilent.UnableToArchiveOEMException">Thrown when the oem was not able to get archived</exception>
        /// <exception cref="Valutech.Agilent.UnableToUseOEMException">Thrown when the oem was not able to get used</exception>
        /// <exception cref="Valutech.Agilent.UnableToCreateExecSettingBackupException">Thrown when the ExecSetting backup file could not be created</exception>
        public WTMVersion Archive()
        {
            WTMVersion closedVersion = null;
            //If the oem is not in use currently we need to close the wtm and rename the folders
            WTMVersion runningVersion = WirelessTestManager.GetInstance().IsRunning();

            if (this.InUse)
            {
                //Close the currently running wtm if running
                if (runningVersion != null)
                {
                    if (!runningVersion.Close())
                    {
                        throw new UnableToCloseWTMException(runningVersion);
                    }
                    else
                    {
                        closedVersion = runningVersion;
                    }
                }

                //Archive the oem in use
                if (this != null)
                {
                    if (this.Path != this.ArchivedPath)
                    {
                        try
                        {
                            if (!Directory.Exists(this.ArchivedPath))
                            {
                                Directory.Move(this.Path, this.ArchivedPath);
                                this.setPath(ArchivedPath);
                                if (Archived != null)
                                {
                                    Archived(this);
                                }
                            }
                            else
                            {
                                throw new UnableToArchiveOEMException(this, UnableToArchiveOEMException.ErrorType.ARCHIVED_OEM_ALREADY_EXISTS);
                            }
                        }
                        catch (IOException)
                        {
                            throw new UnableToArchiveOEMException(this, UnableToArchiveOEMException.ErrorType.IO_EXCEPTION);
                        }
                        catch (UnauthorizedAccessException)
                        {
                            throw new UnableToArchiveOEMException(this, UnableToArchiveOEMException.ErrorType.UNAUTHORIZED_ACCESS_EXCEPTION);
                        }
                    }
                }
            }

            //Close the currently running wtm if running
            if (runningVersion != null && this.ExecSetting.NeedsRestart)
            {
                if (!runningVersion.Close())
                {
                    throw new UnableToCloseWTMException(runningVersion);
                }
                else
                {
                    closedVersion = runningVersion;
                }
            }
            return(closedVersion);
        }
Beispiel #4
0
        /// <summary>
        /// Use the given oem, makes the necessary folder name changes
        /// </summary>
        /// <param name="oemToUse">OEM to use</param>.
        /// <returns>Returns the WTM Version that was closed during the process if any</returns>
        /// <exception cref="Valutech.Agilent.UnableToCloseWTMException">Thrown when the wtm was not able to get closed by the system</exception>
        /// <exception cref="Valutech.Agilent.UnableToArchiveOEMException">Thrown when the oem was not able to get archived</exception>
        /// <exception cref="Valutech.Agilent.UnableToUseOEMException">Thrown when the oem was not able to get used</exception>
        /// <exception cref="Valutech.Agilent.UnableToCreateExecSettingBackupException">Thrown when the ExecSetting backup file could not be created</exception>
        public WTMVersion Use()
        {
            this.ExecSetting.Load();
            WTMVersion closedVersion = null;
            //If the oem is not in use currently we need to close the wtm and rename the folders
            WTMVersion runningVersion = WirelessTestManager.GetInstance().IsRunning();

            if (!this.InUse)
            {
                //Close the currently running wtm if running
                if (runningVersion != null)
                {
                    if (!runningVersion.Close())
                    {
                        throw new UnableToCloseWTMException(runningVersion);
                    }
                    else
                    {
                        closedVersion = runningVersion;
                    }
                }

                //Utilizar el oem seleccionado
                if (this.Path != this.InUsePath)
                {
                    try
                    {
                        if (!Directory.Exists(this.InUsePath))
                        {
                            Directory.Move(this.Path, this.InUsePath);
                            this.setPath(InUsePath);
                            if (Used != null)
                            {
                                Used(this);
                            }
                        }
                        else
                        {
                            throw new UnableToUseOEMException(this, UnableToUseOEMException.ErrorType.OEM_ALREADY_IN_USE);
                        }
                    }
                    catch (IOException)
                    {
                        throw new UnableToUseOEMException(this, UnableToUseOEMException.ErrorType.IO_EXCEPTION);
                    }
                    catch (UnauthorizedAccessException)
                    {
                        throw new UnableToUseOEMException(this, UnableToUseOEMException.ErrorType.UNAUTHORIZED_ACCESS_EXCEPTION);
                    }
                }
            }

            //Set the location of the new model in the exec settings file of the current oem in use


            //Close the currently running wtm if running
            if (runningVersion != null && this.ExecSetting.NeedsRestart)
            {
                if (!runningVersion.Close())
                {
                    throw new UnableToCloseWTMException(runningVersion);
                }
                else
                {
                    closedVersion = runningVersion;
                }
            }
            return(closedVersion);
        }