Esempio n. 1
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);
        }
Esempio n. 2
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();
            }
        }