private string SetUpStatsFileIntermediateOutputFilename(IEnumerable <LegacyDataItem> inputRecords) { var tempDir = @"c:\path\to\tmp"; fileSystemOperationsServiceMock.GetTempPath().Returns(tempDir); return($"{tempDir}\\FoldingStatsData-{inputRecords.First().Date.ToString("yyyyMMdd")}.txt"); }
private void LegacyDbDumpReader_RecordsForDayRead(object sender, RecordsForDayReadEventArgs e) { loggingService.LogDebug($"Batch Read: {e.Records.First().Date} - {e.Records.Count()} record(s)"); // Map the data var statsData = dataMappingService.MapData(e.Records); // Build filenames var filename = $"FoldingStatsData-{e.Records.First().Date.ToString("yyyyMMdd")}.txt"; var path = fileSystemOperationsService.GetTempPath(); var fullPath = Path.Combine(path, filename); var targetPath = Path.Combine(outputPath, filename + fileCompressionService.FileExt); // Remove intermediate file, if it already exists DeleteFileIfExists(fullPath); // Write the data in stats file format statsDataWriter.Write(statsData, e.Records.First().Date, fullPath); try { // Compress the stats file var tempFile = fileSystemOperationsService.GetTempFilename(); fileCompressionService.CompressFile(fullPath, tempFile); // Move to output folder fileSystemOperationsService.MoveFile(tempFile, targetPath); } finally { // Cleanup DeleteFileIfExists(fullPath); } }