private void reconstructBackEndFromRolloutsFolder(object sender, DoWorkEventArgs e) { //1. Create back end xml file to be updated. CreateXmlFile.CreateBackEndXmlFileInRolloutDirectory(); var directory = new DirectoryInfo(this.RollOutDirectory + "Rollouts\\"); var fileCount = directory.EnumerateFiles("FE-*.zip").Count(); int progressPercentage = Convert.ToInt32(((double)1 / (fileCount + 1)) * 100); (sender as BackgroundWorker).ReportProgress(progressPercentage, e.Argument); int progress = 1; //2. Loop through the zipped files in the rollouts folder foreach (var file in directory.EnumerateFiles("FE-*.zip")) { //For each file, read the file into a ZipArchive object ZipArchive zipfile = ZipFile.OpenRead(file.FullName); //Find the only .xml file in the zip file and extract it to the reconstruction path. zipfile.Entries.FirstOrDefault(p => p.Name.Contains(".xml")).ExtractToFile(this.ReconstructionPath, true); //Release the object reference in memory to the zip file. zipfile.Dispose(); //Create a rolloutInfo file (which is plain object with only properties and not methods) out of //the newly extracted xml file. DTO.RolloutInfo rollout = GetDataFromXml.GetReconstructedInfo(this.ReconstructionPath); //Add a rollout record with the info in the rollout record. UpdateXmlFile.AddRolloutRecord(rollout); progressPercentage = Convert.ToInt32(((double)++progress / fileCount) * 100); (sender as BackgroundWorker).ReportProgress(progressPercentage, "Reconstructed " + file.Name); } }
//This will compare the copied files with the current installer manifest files. If a file to be //added doesn't exist within the manifest, it will add it to the manifest. private void compareWithManifest() { var manifest = GetDataFromXml.GetInstallerManifest(this._installerFilesDirectory, null); List <FileInfo> manifestFiles = manifest.Select(p => new FileInfo(p.SourceFilePath)).ToList(); foreach (FileInfo file in this.CopiedFiles) { if (!manifestFiles.Any(p => p.Name == file.Name)) { UpdateXmlFile.AddFileToManifest(this._installerFilesDirectory, file); } } }
public void Execute() { //1. Get Installer directory; this._installerFilesDirectory = PathManager.GetInstallerFilesDirectory(DTO.Enums.BackEndOrFrontEndEnum.BackEnd); //2. Get current launcher version this._newLauncherVersion = GetDataFromXml.GetCurrentLauncherVersion(this._installerFilesDirectory) + 1; //3. Archive existing files archiveExistingFiles(); //4. Copy each file in the filelist to the installer directory copyFiles(); //5. Compare the file list with the current manifest compareWithManifest(); //6. Update launcher version in backend.xml UpdateXmlFile.SetLauncherVersion(this._newLauncherVersion, this._installerFilesDirectory); }
public static void RollBackVersionNumber(int versionToRollTo, DTO.Enums.UserTypeEnum userType) { try { //This will attempt to roll back to the specified version number. UpdateXmlFile.RollBackToVersionNumber(versionToRollTo, userType); } catch (Exception) { //IF an exception is raised, it will delete the current backend.xml and then repair the back end, restoring it //to what it was before the rollback attempt. then it will throw a CouldNotRollBackException. var pathToAccess = GetDataFromXml.GetAccessPathFromCurrentConnectionString(DTO.Enums.BackEndOrFrontEndEnum.BackEnd); File.Delete(PathManager.GetBackEndXmlPath(DTO.Enums.BackEndOrFrontEndEnum.BackEnd)); var installer = new Installer(PathManager.GetRolloutDirectoryPath(DTO.Enums.BackEndOrFrontEndEnum.BackEnd), pathToAccess); installer.TryFixBrokenBackEnd(); throw new DTO.Exceptions.CouldNotRollBackException(); } }
private void reconstructBackEndFromRolloutsFolder() { //1. Create back end xml file to be updated. CreateXmlFile.CreateBackEndXmlFileInRolloutDirectory(); var directory = new DirectoryInfo(this.RollOutDirectory + "Rollouts\\"); //2. Loop through the zipped files in the rollouts folder foreach (var file in directory.EnumerateFiles("FE-*.zip")) { //For each file, read the file into a ZipArchive object ZipArchive zipfile = ZipFile.OpenRead(file.FullName); //Find the only .xml file in the zip file and extract it to the reconstruction path. zipfile.Entries.FirstOrDefault(p => p.Name.Contains(".xml")).ExtractToFile(this.ReconstructionPath, true); //Release the object reference in memory to the zip file. zipfile.Dispose(); //Create a rolloutInfo file (which is plain object with only properties and not methods) out of //the newly extracted xml file. DTO.RolloutInfo rollout = GetDataFromXml.GetReconstructedInfo(this.ReconstructionPath); //Add a rollout record with the info in the rollout record. UpdateXmlFile.AddRolloutRecord(rollout); } }
public static void UpdateOnNextLaunch() { UpdateXmlFile.SetFrontEndVersionToZero(); }
private static void updateFrontEndXML(DTO.Enums.UserTypeEnum userType) { DTO.RolloutInfo rollout = GetDataFromXml.GetLatestRollout(userType, DTO.Enums.BackEndOrFrontEndEnum.FrontEnd); UpdateXmlFile.UpdateFrontEndXml(rollout); }
//This will activate a global lockout. public static void SetLockout(bool enabled) { UpdateXmlFile.SetLockout(enabled); }
public void Execute() { string zipPath = zipUpPath(this.DirectoryPath); UpdateXmlFile.AddRolloutRecord(makeRolloutInfo(zipPath)); }
public static void UpdateFrontEndLauncherVersion(int currentLauncherVersion) { UpdateXmlFile.UpdateFrontEndLauncherVersion(currentLauncherVersion); }