public FeedbackMessage(string value, eFeedbackType type, Guid guid, string registeredBy) { this.Guid = guid.ToString(); this.Value = value; this.Type = type.ToString(); this.RegisteredBy = string.IsNullOrEmpty(registeredBy) ? "NO_USER_LOGGED" : registeredBy; }
public void WriteLog(eFeedbackType type , string message /**/ , bool IsToWriteOnConsole = true , Guid?guid = null /**/ , eApiCallerMethod?method = null /**/ , Object obj = null , Exception ex = null , bool IsToSendEmail = false) { string guidString = guid.HasValue ? guid.ToString() : Guid.NewGuid().ToString(); string startMessage = string.Format("[{0}] [{1}] [{2}]", type.ToString(), DateTime.Now.ToString("yyyyMMdd hh:mm:ss"), guidString); { string messageLog = string.Format("{0} {1}", startMessage, message); Log.Info(messageLog); if (IsToWriteOnConsole) { Console.WriteLine(messageLog); } } if (method.HasValue) { string messageLog = string.Format("{0} Method: {1}", startMessage, method.ToString()); Log.Info(messageLog); if (IsToWriteOnConsole) { Console.WriteLine(messageLog); } } if (obj != null) { string messageLog = string.Format("{0} Object: {1}", startMessage, JsonConvert.SerializeObject(obj)); Log.Info(messageLog); if (IsToWriteOnConsole) { Console.WriteLine(messageLog); } } if (ex != null && !string.IsNullOrEmpty(ex.Message)) { string messageLog = string.Format("{0} exMessage: {1}", startMessage, ex.Message.ToString()); Log.Info(messageLog); if (IsToWriteOnConsole) { Console.WriteLine(messageLog); } } if (ex != null && ex.InnerException != null && !string.IsNullOrEmpty(ex.InnerException.Message)) { string messageLog = string.Format("{0} exInnerException: {1}", startMessage, ex.InnerException.Message.ToString()); Log.Info(messageLog); if (IsToWriteOnConsole) { Console.WriteLine(messageLog); } } if (IsToSendEmail) { string messageLog = string.Format("{0} Email Error Sent to: {1}", startMessage, _EmailAdm); Log.Info(messageLog); if (IsToWriteOnConsole) { Console.WriteLine(messageLog); } } { string messageLog = string.Format("->"); Log.Info(messageLog); if (IsToWriteOnConsole) { Console.WriteLine(messageLog); } } }