コード例 #1
0
        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);
            }
        }
コード例 #2
0
        //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);
                }
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 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();
     }
 }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
 public static void UpdateOnNextLaunch()
 {
     UpdateXmlFile.SetFrontEndVersionToZero();
 }
コード例 #7
0
 private static void updateFrontEndXML(DTO.Enums.UserTypeEnum userType)
 {
     DTO.RolloutInfo rollout = GetDataFromXml.GetLatestRollout(userType, DTO.Enums.BackEndOrFrontEndEnum.FrontEnd);
     UpdateXmlFile.UpdateFrontEndXml(rollout);
 }
コード例 #8
0
 //This will activate a global lockout.
 public static void SetLockout(bool enabled)
 {
     UpdateXmlFile.SetLockout(enabled);
 }
コード例 #9
0
        public void Execute()
        {
            string zipPath = zipUpPath(this.DirectoryPath);

            UpdateXmlFile.AddRolloutRecord(makeRolloutInfo(zipPath));
        }
コード例 #10
0
 public static void UpdateFrontEndLauncherVersion(int currentLauncherVersion)
 {
     UpdateXmlFile.UpdateFrontEndLauncherVersion(currentLauncherVersion);
 }