-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}"); | ||
} | ||
} | ||
|
||
} | ||
} |