示例#1
0
 public OEM(string path, WTMVersion version)
 {
     this.setPath(path);
     this.version     = version;
     this.execSetting = new ExecSetting(this);
     LoadNameFromPath();
 }
示例#2
0
        /// <summary>
        /// Gets the installed versions according to the registry entries
        /// </summary>
        /// <returns></returns>
        public ArrayList LoadInstalledVersions()
        {
            RegistryKey regKey   = Registry.LocalMachine.OpenSubKey(WTM_VERSIONS_REGISTRY_PATH, false);
            ArrayList   versions = new ArrayList();

            if (regKey != null)
            {
                string[] keys = regKey.GetSubKeyNames();
                foreach (string name in keys)
                {
                    WTMVersion version = new WTMVersion(name);
                    versions.Add(version);
                }
            }
            return(versions);
        }
示例#3
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);
            }
        }
示例#4
0
        /// <summary>
        /// Gets the current model in use
        /// </summary>
        /// <returns></returns>
        public Model GetModelInUse()
        {
            Model model = null;

            try
            {
                WTMVersion version = this.IsRunning();
                if (version != null)
                {
                    OEM oem = version.GetOEMInUse();
                    oem.ExecSetting.Load(true);
                    model = oem.GetModelFromPath(oem.ExecSetting.PathLossFile);
                }
            }
            catch
            {
            }
            return(model);
        }
示例#5
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);
        }
示例#6
0
 /// <summary>
 /// Checks every 5 minutes for any test plan updates
 /// </summary>
 public void PeriodicallyCheckForTestPlanUpdates()
 {
     TestPlanUpdaterTimer.Enabled = false;
     try
     {
         WTMVersion runningVersion = IsRunning();
         if (runningVersion != null)
         {
             OEM oemInUse = runningVersion.GetOEMInUse();
             if (oemInUse != null && oemInUse.TestPlan != String.Empty)
             {
                 CheckForTestPlanUpdates(oemInUse);
             }
         }
     }
     catch (Exception ex)
     {
         Debug.Print("Periodically check for test plan updates exceptions: " + ex.ToString());
     }
     TestPlanUpdaterTimer.Enabled = true;
 }
示例#7
0
        /// <summary>
        /// Makes the directory rename if needed and the changes in the exec settings file if needed
        /// </summary>
        /// <param name="model"></param>
        /// <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 void UseModel(Model model)
        {
            //Use OEM, a wtm close can happen
            OEM inUseOEM = model.OEM.Version.GetOEMInUse();

            if (inUseOEM != null && inUseOEM.Name != model.OEM.Name)
            {
                inUseOEM.Archive();
            }
            model.OEM.Use();
            if (ModelSelected != null)
            {
                ModelSelected(model);
            }

            //Check for the exec settings, the reload just happens if the wtm has been closed
            ExecSetting execSetting = model.OEM.ExecSetting;

            execSetting.Load();
            execSetting.ResetAllSettings();
            execSetting.PathLossFile = model.InUsePath;

            if (execSetting.ChangesNotSaved)
            {
                execSetting.Write();
            }

            WTMVersion runningVersion = IsRunning();

            if (execSetting.NeedsRestart && runningVersion != null)
            {
                Restart();
            }
            else
            {
                model.OEM.Version.Open();
            }
        }
示例#8
0
        /// <summary>
        /// Updates the testplan
        /// </summary>
        /// <param name="oem"></param>
        public void UpdateTestPlan(OEM oem, string version)
        {
            WTMVersion runningVersion = this.IsRunning();

            try
            {
                string      remoteTargetTestPlan = Path.Combine(Path.GetDirectoryName(ONLINE_PLANS_DIRECTORY), Path.GetFileName(oem.TestPlan));
                string      localTargetTestPlan  = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), Path.GetFileName(oem.TestPlan));
                ExecSetting execSetting          = oem.ExecSetting;
                execSetting.Load();
                string database = (execSetting.Database.Length > 3)? Path.Combine(oem.ModelsPath, Path.GetFileName(execSetting.Database)):Path.Combine(oem.ModelsPath, Path.GetFileName(remoteTargetTestPlan));
                File.Copy(remoteTargetTestPlan, localTargetTestPlan, true);
                if (runningVersion != null)
                {
                    this.Close();
                }
                Thread.Sleep(2000);
                File.Copy(localTargetTestPlan, database, true);
                execSetting.Database = database;
                execSetting.Write();
                oem.TestPlanVersion = version;
                if (WTMTestPlanUpdatedSuccessfull != null)
                {
                    WTMTestPlanUpdatedSuccessfull(oem);
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                if (WTMTestPlanUpdateError != null)
                {
                    WTMTestPlanUpdateError(WTMTestPlanUpdateErrorType.UNAUTHORIZED_ACCESS, ex);
                }
            }
            catch (DirectoryNotFoundException ex)
            {
                if (WTMTestPlanUpdateError != null)
                {
                    WTMTestPlanUpdateError(WTMTestPlanUpdateErrorType.DIRECTORY_NOT_FOUND, ex);
                }
            }
            catch (FileNotFoundException ex)
            {
                if (WTMTestPlanUpdateError != null)
                {
                    WTMTestPlanUpdateError(WTMTestPlanUpdateErrorType.FILE_NOT_FOUND, ex);
                }
            }
            catch (IOException ex)
            {
                if (WTMTestPlanUpdateError != null)
                {
                    WTMTestPlanUpdateError(WTMTestPlanUpdateErrorType.IO_EXCEPTION, ex);
                }
            }
            catch (Exception ex)
            {
                if (WTMTestPlanUpdateError != null)
                {
                    WTMTestPlanUpdateError(WTMTestPlanUpdateErrorType.UNKNOWN_ERROR, ex);
                }
            }
            if (runningVersion != null && IsRunning() == null)
            {
                runningVersion.Open();
            }
        }
示例#9
0
 /// <summary>
 /// Handles the event when the wtm has been restarted and resets the flag to false
 /// </summary>
 /// <param name="version"></param>
 private void wtm_WTMRestarted(WTMVersion version)
 {
     fileNeedsRestart = false;
     loaded           = false;
 }
示例#10
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);
        }
示例#11
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);
        }