Hardware/ReportWriter.cs
author moel.mich
Tue, 26 Jan 2010 22:37:48 +0000
changeset 1 361e324a0ed4
child 18 49220085218d
permissions -rw-r--r--
Initial commit.
     1 using System;
     2 using System.Collections.Generic;
     3 using System.IO;
     4 using System.Text;
     5 
     6 namespace OpenHardwareMonitor.Hardware {
     7   public class ReportWriter {
     8 
     9     private static void NewSection(TextWriter writer) {      
    10       for (int i = 0; i < 8; i++)
    11         writer.Write("----------");
    12       writer.WriteLine();
    13       writer.WriteLine();
    14     }
    15 
    16     public static void Save(List<IGroup> groupList, Version version) {
    17 
    18       using (TextWriter w =
    19         new StreamWriter("OpenHardwareMonitor.Report.txt")) {
    20 
    21         w.WriteLine();
    22         w.WriteLine("Open Hardware Monitor Report");
    23         w.WriteLine();
    24         NewSection(w);
    25         w.Write("Version: "); w.WriteLine(version.ToString());
    26         w.WriteLine();
    27 
    28         foreach (IGroup group in groupList) {
    29           string report = group.GetReport();
    30           if (report != null) {
    31             NewSection(w);
    32             w.Write(report);            
    33           }
    34 
    35           IHardware[] hardwareArray = group.Hardware;
    36           foreach (IHardware hardware in hardwareArray) {
    37             string hardwareReport = hardware.GetReport();
    38             if (hardwareReport != null) {
    39               NewSection(w);
    40               w.Write(hardwareReport);
    41             }
    42           }
    43         }
    44       }
    45     }
    46   }
    47 }