Exemplo n.º 1
0
        /// <summary>
        /// SaveError
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="ex"></param>
        /// <param name="sendMail"></param>
        public static void SaveError(string msg, Exception ex = null, bool sendMail = false)
        {
            try
            {
                if (ex == null)
                {
                    SaveLogs.AddLogs(new LogInfo()
                    {
                        logType = LOG_TYPE.ERROR_LOGS,
                        msgLogs = msg
                    });
                }
                else
                {
                    SaveLogs.AddLogs(new LogInfo()
                    {
                        logType = LOG_TYPE.ERROR_LOGS,
                        msgLogs = msg + ": " + ex
                    });
                }

                if (sendMail)
                {
                    ErrorLogsClass.AddErrorLogs(new ErrorLogs()
                    {
                        error = msg,
                        ex    = ex
                    });
                }
            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 2
0
 public void SendMail()
 {
     while (flag)
     {
         try
         {
             var listErrorLogs = ErrorLogsClass.GetListErrorLogs(10);
             foreach (var item in listErrorLogs)
             {
                 Logs.SendMailError("[" + SERVER_TYPE + "]" + item.error, item.ex);
                 ErrorLogsClass.RemoveErrorLog(item);
                 Thread.Sleep(1000);
             }
         }
         catch (Exception)
         {
         }
         finally
         {
             Thread.Sleep(10000); //10 second
         }
     }
 }