From a23a74ffa49128a61935468afc8bbdecb2bc2d27 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Tue, 12 Jun 2018 12:23:04 -0700 Subject: [PATCH] Attempt to write out all information --- MainWindow.xaml.cs | 4 +++- Utilities.cs | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 4b071906..44cf4d6b 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -209,6 +209,7 @@ namespace DICUI } // Invoke the program with all 3 configurations + // TODO: Use these outputs for PSX information Process psxt001z = new Process() { StartInfo = new ProcessStartInfo() @@ -244,8 +245,9 @@ namespace DICUI break; } - // TODO: UNUSED Dictionary templateValues = Utilities.ExtractOutputInformation(outputDirectory, outputFilename, selected.Item2, selected.Item3); + List formattedValues = Utilities.FormatOutputData(templateValues, selected.Item2, selected.Item3); + bool success = Utilities.WriteOutputData(formattedValues); btn_Start.IsEnabled = true; } diff --git a/Utilities.cs b/Utilities.cs index 210351fb..0d95f38e 100644 --- a/Utilities.cs +++ b/Utilities.cs @@ -1213,5 +1213,38 @@ namespace DICUI return null; } } + + /// + /// Write the data to the output folder + /// + /// Base directory to use + /// Base filename to use + /// Preformatted list of lines to write out to the file + /// True on success, false on error + public static bool WriteOutputData(string outputDirectory, string outputFilename, List lines) + { + // First, sanitized the output filename to strip off any potential extension + outputFilename = Path.GetFileNameWithoutExtension(outputFilename); + + // Now write out to a generic file + string combinedBase = Path.Combine(outputDirectory, outputFilename); + try + { + using (StreamWriter sw = new StreamWriter(File.OpenWrite(combinedBase + ".txt"))) + { + foreach (string line in lines) + { + sw.WriteLine(line); + } + } + } + catch + { + // We don't care what the error is right now + return false; + } + + return true; + } } }