public void DecompressFile(string downloadFilePath, string decompressedDownloadFilePath)
        {
            if (settingsService.IsFileCompressionDisabled())
            {
                File.Copy(downloadFilePath, decompressedDownloadFilePath);
                return;
            }

            innerService.DecompressFile(downloadFilePath, decompressedDownloadFilePath);
        }
示例#2
0
        public ParseResults ValidateFile(FilePayload filePayload)
        {
            fileCompressionService.DecompressFile(filePayload.DownloadFilePath,
                                                  filePayload.DecompressedDownloadFilePath);
            fileReaderService.ReadFile(filePayload);
            ParseResults parseResults = statsFileParserService.Parse(filePayload);

            filePayload.FileUtcDateTime = parseResults.DownloadDateTime;
            return(parseResults);
        }
示例#3
0
        private async void DecompressButton_Click(object sender, EventArgs e)
        {
            await RunActionAsync(() =>
            {
                string decompressDirectory = DecompressDirectoryTextBox.Text;

                if (!Directory.Exists(decompressDirectory))
                {
                    Log(
                        $"The directory does not exist, provide a new directory and try again. Directory: '{decompressDirectory}'");
                    return(Task.CompletedTask);
                }

                string[] importFiles = Directory.GetFiles(decompressDirectory, "*.bz2", SearchOption.TopDirectoryOnly);

                if (importFiles.Length == 0)
                {
                    Log(
                        $"There are no text files in the top directory, provide a directory with files to decompress and try again. Directory: '{decompressDirectory}'");
                    return(Task.CompletedTask);
                }

                int filesRemaining = importFiles.Length;

                IFileCompressionService fileCompressionService = null;
                try
                {
                    fileCompressionService = WindsorContainer.Instance.Resolve <IFileCompressionService>();

                    Log($"'{filesRemaining}' files are to be imported");

                    foreach (string importFile in importFiles)
                    {
                        fileCompressionService.DecompressFile(importFile,
                                                              importFile.Substring(importFile.Length - 4, 4));
                        filesRemaining--;
                        Log($"File imported. '{filesRemaining}' remaining files to be imported");
                    }
                }
                finally
                {
                    WindsorContainer.Instance.Release(fileCompressionService);
                }

                return(Task.CompletedTask);
            });
        }