author | moel.mich |
Tue, 26 Jan 2010 22:37:48 +0000 | |
changeset 1 | 361e324a0ed4 |
child 18 | 49220085218d |
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@1 | 24 |
NewSection(w); |
moel@1 | 25 |
w.Write("Version: "); w.WriteLine(version.ToString()); |
moel@1 | 26 |
w.WriteLine(); |
moel@1 | 27 |
|
moel@1 | 28 |
foreach (IGroup group in groupList) { |
moel@1 | 29 |
string report = group.GetReport(); |
moel@1 | 30 |
if (report != null) { |
moel@1 | 31 |
NewSection(w); |
moel@1 | 32 |
w.Write(report); |
moel@1 | 33 |
} |
moel@1 | 34 |
|
moel@1 | 35 |
IHardware[] hardwareArray = group.Hardware; |
moel@1 | 36 |
foreach (IHardware hardware in hardwareArray) { |
moel@1 | 37 |
string hardwareReport = hardware.GetReport(); |
moel@1 | 38 |
if (hardwareReport != null) { |
moel@1 | 39 |
NewSection(w); |
moel@1 | 40 |
w.Write(hardwareReport); |
moel@1 | 41 |
} |
moel@1 | 42 |
} |
moel@1 | 43 |
} |
moel@1 | 44 |
} |
moel@1 | 45 |
} |
moel@1 | 46 |
} |
moel@1 | 47 |
} |