/** * Physically remove the project from the project folder. The project must be opened * on order to delete it. If the user accepts the verification to delete the project * the project will be unloaded then all folders and files will be removed. This process * does NOT remove any related files from the document library. */ public static void DeleteProject() { TestProgramSet testSet = Instance.CurrentTestProgramSet; if (testSet != null) { string testSetName = testSet.TestSetName; string fullName = testSet.TestSetDirectory.FullName; if (DialogResult.Yes == MessageBox.Show( string.Format("Are you sure you want to delete Test Set Project \"{0}\"?", testSetName), @"V E R I F Y", MessageBoxButtons.YesNo, MessageBoxIcon.Question)) { HourGlass.Start(); try { CloseProject(); GC.Collect(); if (FileManager.DeleteDirectory(fullName, true)) { LogManager.Trace("Test Set Project \"{0}\" has been deleted.", testSetName); } } catch (Exception err) { LogManager.Error(err.Message); } finally { HourGlass.Stop(); } } } }
public static string OpenProject(string projectName) { string testSetName = null; ProjectManager pm = Instance; TestProgramSet tps = TestProgramSet.OpenTestSet(projectName); if (tps != null) { if (HasOpenProject()) { CloseProject(); } pm.CurrentTestProgramSet = tps; string projectFileName = Path.Combine(Instance.CurrentTestProgramSet.TestSetDirectory.FullName, ATMLContext.PROJECT_INFO_FILENAME); if (!FileManager.FileExists(projectFileName)) //Project Info File will not exist if it is an old project format is read. { pm.CurrentTestProgramSet.ProjectInfo = CreateProjectInfoFile(); } else { byte[] data = FileManager.ReadFile(projectFileName); pm.CurrentTestProgramSet.ProjectInfo = new ProjectInfo(data); } pm.OnProjectOpened(projectName); LogManager.Trace("Project \"{0}\" has been opened", pm.CurrentTestProgramSet.TestSetName); } return(pm.CurrentTestProgramSet.TestSetName); }
public static void CreateTestSetArchive() { TestProgramSet currenTestProgramSet = Instance.CurrentTestProgramSet; if (currenTestProgramSet == null) { throw new Exception("There is no test program set opened."); } currenTestProgramSet.CreateTestSetArchive(currenTestProgramSet.TestSetName); }
public static void RemoveATMLDocument(string documentName, AtmlFileType atmlType) { TestProgramSet currenTestProgramSet = Instance.CurrentTestProgramSet; if (currenTestProgramSet != null) { currenTestProgramSet.RemoveATMLDocument(documentName, atmlType); } ATMLNavigator.Instance.RemoveAtmlFile(documentName); }
public static void SaveATMLDocument(string documentName, AtmlFileType atmlType, byte[] contentBytes, bool forceOverWrite = false) { TestProgramSet currenTestProgramSet = Instance.CurrentTestProgramSet; if (currenTestProgramSet != null) { currenTestProgramSet.SaveATMLDocument(documentName, atmlType, contentBytes, forceOverWrite); } }
public static void SaveReaderDocument(string documentName, byte[] contentBytes) { TestProgramSet currenTestProgramSet = Instance.CurrentTestProgramSet; if (currenTestProgramSet == null) { throw new Exception("There is no test program set opened."); } currenTestProgramSet.SaveReaderDocument(documentName, contentBytes); }
public static byte[] GetReaderDocument(string documentName) { TestProgramSet currenTestProgramSet = Instance.CurrentTestProgramSet; if (currenTestProgramSet == null) { throw new Exception("There is no test program set opened."); } return(currenTestProgramSet.GetReaderDocument(documentName)); }
public static void ProcessUutChanges(UUTDescription uut) { TestProgramSet currentTestProgramSet = Instance.CurrentTestProgramSet; if (currentTestProgramSet != null) { ProjectInfo pi = currentTestProgramSet.ProjectInfo; if (pi != null) { pi.UutId = uut.uuid; pi.UutName = uut.Item.Identification.ModelName; SaveProjectInfo(pi, currentTestProgramSet); } } }
public static bool OpenProject(out string testSetName) { if (HasOpenProject()) { CloseProject(); } testSetName = null; //--- Display a list of available test sets and open the one that is selected ---// TestProgramSet tps = null; if (TestProgramSet.SelectTestSet(out tps)) { using (new HourGlass()) { Instance.CurrentTestProgramSet = tps; if (Instance.CurrentTestProgramSet != null) { try { byte[] data = FileManager.ReadFile( Path.Combine(Instance.CurrentTestProgramSet.TestSetDirectory.FullName, ATMLContext.PROJECT_INFO_FILENAME)); Instance.CurrentTestProgramSet.ProjectInfo = new ProjectInfo(data); } catch (Exception) { ProjectInfo pi = CreateProjectInfoFile(); Instance.CurrentTestProgramSet.ProjectInfo = pi; } testSetName = Instance.CurrentTestProgramSet.TestSetName; Instance.OnProjectOpened(testSetName); LogManager.Trace("Project \"{0}\" has been opened", testSetName); } } } return(testSetName != null); }
public static bool RenameProject(string oldProjectName, string newProjectName) { bool projectRenamed = false; ProjectManager pm = Instance; TestProgramSet ts = pm.CurrentTestProgramSet; if (ts != null) { string oldPath = Path.Combine(ATMLContext.TESTSET_PATH, oldProjectName); string newPath = Path.Combine(ATMLContext.TESTSET_PATH, newProjectName); try { if (Directory.Exists(newPath)) { LogManager.Warn("Project {0} already exists.", newProjectName); } else { CloseProject(); FileManager.CopyFolder(oldPath, newPath, true); OpenProject(newProjectName); FileManager.DeleteDirectory(oldPath, true); ProjectInfo pi = ProjectInfo; pi.ProjectName = newProjectName; SaveProjectInfo(pi, Instance.CurrentTestProgramSet); LogManager.Trace("Project {0} renamed to {1}.", oldProjectName, newProjectName); //Loop through file looking for old project name - rename with new file names FileManager.RenameProjectFiles(newPath, oldProjectName, newProjectName); projectRenamed = true; } } catch (Exception e) { LogManager.Error(e, "Failed to rename folder {0}\n{1}", newProjectName, e.Message); } } return(projectRenamed); }
public static void CreateProject(ProjectInfo projectInfo) { //--- Prompt for a test set name ---// //--- Check if the name exisists ---// //--- If name exists then notify the user, ask if they want to open that test set ---// //--- Otherwise create the test set and open it ---// if (projectInfo != null) { TestProgramSet currentTestProgramSet = TestProgramSet.CreateTestSet(projectInfo.ProjectName); if (currentTestProgramSet != null) { SaveProjectInfo(projectInfo, currentTestProgramSet); OpenProject(projectInfo.ProjectName); Document uutDescriptionDocument = DocumentManager.GetDocument(projectInfo.UutId); if (uutDescriptionDocument != null) { SaveATMLDocument(UutManager.BuildAtmlFileName(projectInfo.UutName), AtmlFileType.AtmlTypeUut, uutDescriptionDocument.DocumentContent); } //--- Create a Test Description ---// if (uutDescriptionDocument != null) { var uutDoc = new DocumentReference(); uutDoc.ID = "UUT1"; uutDoc.uuid = uutDescriptionDocument.uuid; var uutRef = new ItemDescriptionReference(); uutRef.Item = uutDoc; var testConfiguration = new TestConfiguration15(); testConfiguration.uuid = Guid.NewGuid().ToString(); testConfiguration.TestedUUTs.Add(uutRef); SaveATMLDocument(projectInfo.ProjectName + ATMLContext.ATML_CONFIG_FILENAME_SUFFIX, AtmlFileType.AtmlTypeTestConfiguration, Encoding.UTF8.GetBytes(testConfiguration.Serialize())); } } } }
public static bool HasProject(string projectName) { return(TestProgramSet.HasTestProgramSet(projectName)); }
private static void SaveProjectInfo(ProjectInfo projectInfo, TestProgramSet currentTestProgramSet) { FileManager.WriteFile(currentTestProgramSet.TestSetDirectory.FullName + @"\project-info.xml", Encoding.UTF8.GetBytes(projectInfo.Serialize())); }