public OEM(string path, WTMVersion version) { this.setPath(path); this.version = version; this.execSetting = new ExecSetting(this); LoadNameFromPath(); }
/// <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(); } }
/// <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(); } }
public InvalidExecSettingFileException(ExecSetting ExecSetting) { this.ExecSetting = ExecSetting; }
public UnableToRestoreExecSettingBackupException(ExecSetting ExecSetting, ErrorType error) : base() { this.ExecSetting = ExecSetting; this.Error = error; }