Skip to content

Commit

Permalink
Writer class
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhobean committed Nov 2, 2020
1 parent 85e9e88 commit 55cbbb7
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions SphereSave_Analyser/ReportWriter.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
using System;
using System.Configuration;
using System.IO;

namespace SphereSave_Analyser
{
public static class Report
//REPORT CLASS permit to write on a file
//EX:
// String Nameoffile = DateTime.Now.ToString("yyy.MM.dd") + " Report of item";
// Report.Createfile(Nameoffile);
// foreach (var x in queryitem)
// {
// Report.Write("id: " + x.Id + " Count: " + x.Nombre,Nameoffile);
// }

public static class Report
{
private static string dirpathreport = ConfigurationManager.AppSettings["dirpathreport"];


public static void Createfile(string title)
//Create the file and erase the old one with the same name
{
// Create a string array with head of file
string[] head = {"THIS REPORT WAS GENERATE AUTOMATICALLY BY SPHERESAVE_ANALYSER", "********************************" };

using (StreamWriter outputFile = new StreamWriter(Path.Combine(dirpathreport, $"{title}.txt")))
{
foreach (string line in head)
outputFile.WriteLine(line);

}
}

public static void Write(string s,string title)
//Add a line to an existing file
{
using (StreamWriter outputFile = new StreamWriter(Path.Combine(dirpathreport, $"{title}.txt"), true))
{
outputFile.WriteLine($"{s}");
}
}

}
}

0 comments on commit 55cbbb7

Please sign in to comment.