author | moel.mich |
Mon, 01 Feb 2010 21:04:14 +0000 | |
changeset 18 | 49220085218d |
parent 1 | 361e324a0ed4 |
permissions | -rw-r--r-- |
moel@1 | 1 |
using System; |
moel@1 | 2 |
using System.Collections.Generic; |
moel@1 | 3 |
using System.IO; |
moel@1 | 4 |
using System.Text; |
moel@1 | 5 |
|
moel@1 | 6 |
namespace OpenHardwareMonitor.Hardware { |
moel@1 | 7 |
public class ReportWriter { |
moel@1 | 8 |
|
moel@1 | 9 |
private static void NewSection(TextWriter writer) { |
moel@1 | 10 |
for (int i = 0; i < 8; i++) |
moel@1 | 11 |
writer.Write("----------"); |
moel@1 | 12 |
writer.WriteLine(); |
moel@1 | 13 |
writer.WriteLine(); |
moel@1 | 14 |
} |
moel@1 | 15 |
|
moel@1 | 16 |
public static void Save(List<IGroup> groupList, Version version) { |
moel@1 | 17 |
|
moel@1 | 18 |
using (TextWriter w = |
moel@1 | 19 |
new StreamWriter("OpenHardwareMonitor.Report.txt")) { |
moel@1 | 20 |
|
moel@1 | 21 |
w.WriteLine(); |
moel@1 | 22 |
w.WriteLine("Open Hardware Monitor Report"); |
moel@1 | 23 |
w.WriteLine(); |
moel@18 | 24 |
|
moel@1 | 25 |
NewSection(w); |
moel@1 | 26 |
w.Write("Version: "); w.WriteLine(version.ToString()); |
moel@1 | 27 |
w.WriteLine(); |
moel@1 | 28 |
|
moel@18 | 29 |
NewSection(w); |
moel@18 | 30 |
foreach (IGroup group in groupList) { |
moel@18 | 31 |
foreach (IHardware hardware in group.Hardware) { |
moel@18 | 32 |
w.WriteLine("|"); |
moel@18 | 33 |
w.WriteLine("+-+ {0} ({1})", |
moel@18 | 34 |
new object[] { hardware.Name, hardware.Identifier }); |
moel@18 | 35 |
foreach (ISensor sensor in hardware.Sensors) { |
moel@18 | 36 |
w.WriteLine("| +- {0} : {1} : {2} : {3}", |
moel@18 | 37 |
new object[] { sensor.SensorType, sensor.Index, sensor.Name, |
moel@18 | 38 |
sensor.Value }); |
moel@18 | 39 |
} |
moel@18 | 40 |
} |
moel@18 | 41 |
} |
moel@18 | 42 |
w.WriteLine(); |
moel@18 | 43 |
|
moel@1 | 44 |
foreach (IGroup group in groupList) { |
moel@1 | 45 |
string report = group.GetReport(); |
moel@1 | 46 |
if (report != null) { |
moel@1 | 47 |
NewSection(w); |
moel@1 | 48 |
w.Write(report); |
moel@1 | 49 |
} |
moel@1 | 50 |
|
moel@1 | 51 |
IHardware[] hardwareArray = group.Hardware; |
moel@1 | 52 |
foreach (IHardware hardware in hardwareArray) { |
moel@1 | 53 |
string hardwareReport = hardware.GetReport(); |
moel@1 | 54 |
if (hardwareReport != null) { |
moel@1 | 55 |
NewSection(w); |
moel@1 | 56 |
w.Write(hardwareReport); |
moel@1 | 57 |
} |
moel@1 | 58 |
} |
moel@1 | 59 |
} |
moel@1 | 60 |
} |
moel@1 | 61 |
} |
moel@1 | 62 |
} |
moel@1 | 63 |
} |