54249c1766
- primo rilascio.
71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
|
|
namespace ib.essetre.integration.egaltech
|
|
{
|
|
static class ErrorManager
|
|
{
|
|
public enum ErrorType
|
|
{
|
|
[DescriptionAttribute("Nessun errore")]
|
|
NONE = 0,
|
|
|
|
[DescriptionAttribute("Errore da definire 1")]
|
|
ERROR1 = 1,
|
|
|
|
[DescriptionAttribute("Errore da definire 2")]
|
|
ERROR2 = 2,
|
|
|
|
[DescriptionAttribute("Errore da definire 3")]
|
|
ERROR3 = 3,
|
|
|
|
[DescriptionAttribute("Errore da definire 4")]
|
|
ERROR4 = 4
|
|
}
|
|
|
|
public static void writeErrorToFile(ErrorType et, string BTLname)
|
|
{
|
|
//DirectoryInfo di = new DirectoryInfo(Path.GetTempPath() + @"TestoErrore\");
|
|
|
|
//// Se la directory non esiste viene creata
|
|
//if (!di.Exists)
|
|
//{
|
|
// di.Create();
|
|
//}
|
|
|
|
//string filename = Path.Combine(di.FullName, String.Format("{0}.txt", "Prova" + DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss")));
|
|
|
|
string filePath = "C:\\Temp\\" + BTLname + ".txt";
|
|
|
|
using (StreamWriter writer = new StreamWriter(filePath, true))
|
|
{
|
|
writer.WriteLine("Errore: " + (int)et);
|
|
writer.WriteLine();
|
|
writer.WriteLine("Descrizione : " + GetDescription(et) + " (" + DateTime.Now.ToString() + ") ");
|
|
writer.WriteLine();
|
|
}
|
|
}
|
|
|
|
public static string GetDescription(this Enum currentEnum)
|
|
{
|
|
string description = String.Empty;
|
|
DescriptionAttribute da;
|
|
|
|
FieldInfo fi = currentEnum.GetType().GetField(currentEnum.ToString());
|
|
da = (DescriptionAttribute)Attribute.GetCustomAttribute(fi, typeof(DescriptionAttribute));
|
|
|
|
if (da != null)
|
|
description = da.Description;
|
|
else
|
|
description = currentEnum.ToString();
|
|
|
|
return description;
|
|
}
|
|
}
|
|
}
|