Beispiel #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);
            }
        }
Beispiel #2
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);
            }
        }