예제 #1
0
        /// <summary>
        /// Logs a message into the background service log
        /// </summary>
        /// <param name="logMessage"></param>
        public static void LogEvent(string logMessage, BackgroundLogMessageType messageType, String serviceName)
        {
            int retries = 100;

            do
            {
                try
                {
                    using (TransactionScope t = new TransactionScope(TransactionScopeOption.Suppress))
                    {
                        using (Connection c = new Connection())
                        {
                            OBackgroundServiceLog log = TablesLogic.tBackgroundServiceLog.Create();
                            log.ServiceName = GlobalService.ServiceName + ": " + serviceName;
                            log.MessageType = (int)messageType;
                            log.Message = logMessage;
                            log.Save();
                            c.Commit();
                            return;
                        }
                    }
                }
                catch (Exception e)
                {
                    //ensure that this method does not throw any kind of exception.
                    if (retries <= 0) throw e;
                    else Thread.Sleep(1000); //wait for 1 second before retrying
                }
            } while (retries-- > 0);

        }
예제 #2
0
 /// <summary>
 /// Logs a message into the background service log
 /// </summary>
 /// <param name="logMessage"></param>
 public static void LogEvent(string logMessage, BackgroundLogMessageType messageType)
 {
     using (TransactionScope t = new TransactionScope(TransactionScopeOption.Suppress))
     {
         using (Connection c = new Connection())
         {
             OBackgroundServiceLog log = TablesLogic.tBackgroundServiceLog.Create();
             log.ServiceName = GlobalService.ServiceName + ": " + "SmsCommunication";
             log.MessageType = (int)messageType;
             log.Message = logMessage;
             log.Save();
             c.Commit();
         }
     }
 }
예제 #3
0
 /// <summary>
 /// Logs a message into the background service log
 /// </summary>
 /// <param name="logMessage"></param>
 public void LogEvent(string logMessage, BackgroundLogMessageType messageType)
 {
     Common.LogEvent(logMessage, messageType, this.ServiceName);
 }