public bool DealWithVerificationFailures(IVerificationIssueSolver form, string scratchFolder, string projectFile) { XmlDocument appconfig = new XmlDocument(); string appConfigPath = Path.Combine(scratchFolder, "appconfig.xml"); if (File.Exists(appConfigPath)) { appconfig = new XmlDocument(); appconfig.Load(appConfigPath); } else if (!failures.Contains(Failure.AppConfig_CouldNotLoad) && !failures.Contains(Failure.AppConfig_Invalid)) { form.InformUserThatAppConfigIsInvalid("Your project is corrupted. The AppConfig XML file is missing."); } foreach (Failure failure in failures) { switch (failure) { case Failure.AppConfig_CouldNotLoad: case Failure.AppConfig_Invalid: form.InformUserThatAppConfigIsInvalid( "Your project is corrupted. The AppConfig XML file is missing, unreadable, or invalid. Contact Slyce for further assistance."); break; case Failure.ProjectDirectory_DoesNotExist: if (appconfig == null) { break; } string newDir = form.GetValidProjectDirectory(projectFile, GetAbsoluteProjectPath(appconfig.SelectSingleNode("appconfig/projectpath").InnerXml)); if (newDir == null) { return(false); } SetProjectPath(appconfig, newDir); appconfig.Save(Path.Combine(scratchFolder, "appconfig.xml")); break; case Failure.TemplateAssembly_DoesNotExist: if (appconfig == null) { break; } string newFile = form.GetValidTemplateFilePath(projectFile, GetAbsoluteTemplateFilename(appconfig)); if (newFile == null) { return(false); } SetTemplateFilename(appconfig, newFile); appconfig.Save(Path.Combine(scratchFolder, "appconfig.xml")); break; } } return(true); }
public bool DealWithVerificationFailures(IVerificationIssueSolver form, string scratchFolder, string projectFile) { XmlDocument appconfig = new XmlDocument(); string appConfigPath = Path.Combine(scratchFolder, "appconfig.xml"); if (File.Exists(appConfigPath)) { appconfig = new XmlDocument(); appconfig.Load(appConfigPath); } else if (!failures.Contains(Failure.AppConfig_CouldNotLoad) && !failures.Contains(Failure.AppConfig_Invalid)) form.InformUserThatAppConfigIsInvalid("Your project is corrupted. The AppConfig XML file is missing."); foreach (Failure failure in failures) { switch (failure) { case Failure.AppConfig_CouldNotLoad: case Failure.AppConfig_Invalid: form.InformUserThatAppConfigIsInvalid( "Your project is corrupted. The AppConfig XML file is missing, unreadable, or invalid. Contact Slyce for further assistance."); break; case Failure.ProjectDirectory_DoesNotExist: if (appconfig == null) break; string newDir = form.GetValidProjectDirectory(projectFile, GetAbsoluteProjectPath(appconfig.SelectSingleNode("appconfig/projectpath").InnerXml)); if (newDir == null) return false; SetProjectPath(appconfig, newDir); appconfig.Save(Path.Combine(scratchFolder, "appconfig.xml")); break; case Failure.TemplateAssembly_DoesNotExist: if (appconfig == null) break; string newFile = form.GetValidTemplateFilePath(projectFile, GetAbsoluteTemplateFilename(appconfig)); if (newFile == null) return false; SetTemplateFilename(appconfig, newFile); appconfig.Save(Path.Combine(scratchFolder, "appconfig.xml")); break; } } return true; }
public bool Load(string projectFilename, IVerificationIssueSolver VerificationIssueSolver) { return Load(projectFilename, VerificationIssueSolver, false, null); }
public bool Load(string projectFilename, IVerificationIssueSolver VerificationIssueSolver, bool skipTemplateLoad, string templateFilename) { log.DebugFormat("Attempting to load project file \"{0}\"", projectFilename); string tempFolder = PathHelper.GetTempFilePathFor("ArchAngel", projectFilename, ComponentKey.Designer_TempRun); if (Utility.StringsAreEqual(Path.GetExtension(projectFilename), ".aaproj", false)) { ProjectFile = projectFilename; // Open the project file and check it for errors. Utility.UnzipFile(projectFilename, tempFolder); //Utility.CopyDirectory(Path.GetDirectoryName(projectFilename).PathSlash); if (!VerifyProjectFile(projectFilename, tempFolder, VerificationIssueSolver)) return false; // this is the Workbench project version //int fileVersion = int.Parse(Utility.ReadTextFile(Path.Combine(tempFolder, "version.txt"))); AppConfigFilename = Path.Combine(tempFolder, "appconfig.xml"); if (!File.Exists(AppConfigFilename)) { AppConfigFilename = Path.Combine(tempFolder, "project.settings"); } } else if (Utility.StringsAreEqual(Path.GetExtension(projectFilename), ".wbproj", false)) { ProjectFile = projectFilename; // Get information about project tempFolder = ArchAngel.Interfaces.ProviderHelper.GetProjectFilesFolder(projectFilename); if (!VerifyProjectFile(projectFilename, tempFolder, VerificationIssueSolver)) return false; // this is the Workbench project version //int fileVersion = int.Parse(Utility.ReadTextFile(Path.Combine(tempFolder, "version.txt"))); AppConfigFilename = Path.Combine(tempFolder, "appconfig.xml"); } else // Old format { AppConfigFilename = projectFilename; } // Load the Project Settings from the appconfig.xml file LoadAppConfig(AppConfigFilename, skipTemplateLoad, templateFilename); // Load the project information from the template assembly if (skipTemplateLoad == false) LoadProjectInfo(TemplateLoader.GetProjectInfoXml()); else { // Load serialised provider info LoadAndFillProviders(SharedData.ProjectSettingsFolder); FillVirtualProperties(); } InitCustomFunctions(); log.Debug("Sucessfully loaded project file."); return true; }
private bool VerifyProjectFile(string projectFilename, string tempFolder, IVerificationIssueSolver VerificationIssueSolver) { ProjectVerifier verifier = new ProjectVerifier(Path.GetDirectoryName(projectFilename)); if (verifier.Verify(tempFolder) == false) { if (verifier.DealWithVerificationFailures(VerificationIssueSolver, tempFolder, projectFilename) == false) { return false; } } return true; }