public static void Warning(eService _service, String _username, CodeMessages Code) { try { FinancyContext db = new FinancyContext(); LogServiceABC dataLogApi = new LogServiceABC(); dataLogApi.Service = _service; dataLogApi.UserName = _username; dataLogApi.DateTransaction = DateTime.Now;; dataLogApi.Type = TypeLog.Warning.ToString(); dataLogApi.Code = CodeString((int)Code); dataLogApi.Message = HlpLog.GetEnumDescription(Code); dataLogApi.StackTrace = ""; db.LogServiceABC.Add(dataLogApi); db.SaveChanges(); } catch (Exception ex) { ex.ToString(); } }
public static void writeLog(LogServiceABC log) { /* string pathlLogEvidente = System.Configuration.ConfigurationManager.AppSettings["rutalLogFirmaElectronica"]; * DateTime now=DateTime.Now; * String dd_mm_aaaa = now.Day.ToString() + "_" + now.Month.ToString() + "_" + now.Year.ToString(); * string nameFile = "Log_Api_Firma_Electronica_" + dd_mm_aaaa; * * if (!Directory.Exists(pathlLogEvidente)) * { * Directory.CreateDirectory(pathlLogEvidente); * } * StreamWriter WriteLogFile = File.AppendText(pathlLogEvidente + nameFile + ".log"); * WriteLogFile.WriteLine("------------------\n"); * WriteLogFile.WriteLine("Service: " + GetEnumDescription(log.Service) + "\n"); * WriteLogFile.WriteLine( "UserName: "******"\n"); * WriteLogFile.WriteLine("DateTransaction: " + log.DateTransaction.ToLongDateString() + " - " + log.DateTransaction.ToLongTimeString() + "\n"); * WriteLogFile.WriteLine( "Type: " + log.Type.ToString() + "\n"); * WriteLogFile.WriteLine( "Code: " + log.Code + "\n"); * WriteLogFile.WriteLine( "Message: " + log.Message + "\n"); * WriteLogFile.WriteLine( "StackTrace: " + log.StackTrace + "\n"); * WriteLogFile.Close(); */ }
public static void Information(eService _service, String _username, CodeMessages Code, String Message) { FinancyContext db = new FinancyContext(); LogServiceABC dataLogApi = new LogServiceABC(); try { dataLogApi.Service = _service; dataLogApi.UserName = _username; dataLogApi.DateTransaction = DateTime.Now;; dataLogApi.Type = TypeLog.Information.ToString(); dataLogApi.Code = CodeString((int)Code); dataLogApi.Message = Message; dataLogApi.StackTrace = ""; db.LogServiceABC.Add(dataLogApi); db.SaveChanges(); writeLog(dataLogApi); } catch (Exception ex) { writeLog(dataLogApi); ex.ToString(); } }