moel@1: using System; moel@1: using System.Collections.Generic; moel@1: using System.IO; moel@1: using System.Text; moel@1: moel@1: namespace OpenHardwareMonitor.Hardware { moel@1: public class ReportWriter { moel@1: moel@1: private static void NewSection(TextWriter writer) { moel@1: for (int i = 0; i < 8; i++) moel@1: writer.Write("----------"); moel@1: writer.WriteLine(); moel@1: writer.WriteLine(); moel@1: } moel@1: moel@1: public static void Save(List groupList, Version version) { moel@1: moel@1: using (TextWriter w = moel@1: new StreamWriter("OpenHardwareMonitor.Report.txt")) { moel@1: moel@1: w.WriteLine(); moel@1: w.WriteLine("Open Hardware Monitor Report"); moel@1: w.WriteLine(); moel@18: moel@1: NewSection(w); moel@1: w.Write("Version: "); w.WriteLine(version.ToString()); moel@1: w.WriteLine(); moel@1: moel@18: NewSection(w); moel@18: foreach (IGroup group in groupList) { moel@18: foreach (IHardware hardware in group.Hardware) { moel@18: w.WriteLine("|"); moel@18: w.WriteLine("+-+ {0} ({1})", moel@18: new object[] { hardware.Name, hardware.Identifier }); moel@18: foreach (ISensor sensor in hardware.Sensors) { moel@18: w.WriteLine("| +- {0} : {1} : {2} : {3}", moel@18: new object[] { sensor.SensorType, sensor.Index, sensor.Name, moel@18: sensor.Value }); moel@18: } moel@18: } moel@18: } moel@18: w.WriteLine(); moel@18: moel@1: foreach (IGroup group in groupList) { moel@1: string report = group.GetReport(); moel@1: if (report != null) { moel@1: NewSection(w); moel@1: w.Write(report); moel@1: } moel@1: moel@1: IHardware[] hardwareArray = group.Hardware; moel@1: foreach (IHardware hardware in hardwareArray) { moel@1: string hardwareReport = hardware.GetReport(); moel@1: if (hardwareReport != null) { moel@1: NewSection(w); moel@1: w.Write(hardwareReport); moel@1: } moel@1: } moel@1: } moel@1: } moel@1: } moel@1: } moel@1: }