Esempio n. 1
0
 void IActionPerformer.LogAndClearCaughtExceptions()
 {
     if (((IActionPerformer)this).HasCaughtExceptions)
     {
         StringBuilder logBuilder = new StringBuilder();
         logBuilder.Append(string.Format(CultureInfo.CurrentCulture, "Actionperformer has caught {0} exceptions:{1}", _taskPerformerExceptionList.Count, Environment.NewLine));
         ActionPerformerException previousExeption = null;
         lock (_lockExceptionList)
         {
             int exceptionCount = 0;
             foreach (ActionPerformerException ex in _taskPerformerExceptionList)
             {
                 string message;
                 if (ExceptionsAreSame(previousExeption, ex))
                 {
                     message = "Same as previous exception...";
                 }
                 else
                 {
                     message = ex.ToString();
                 }
                 logBuilder.Append(string.Format(CultureInfo.CurrentCulture, "{0})\t{1}{2}", ++exceptionCount, message, Environment.NewLine));
                 previousExeption = ex;
             }
             _taskPerformerExceptionList.Clear();
         }
         Log.Error(logBuilder.ToString());
     }
 }
Esempio n. 2
0
        private static bool ExceptionsAreSame(ActionPerformerException previousExeption, ActionPerformerException newException)
        {
            if (previousExeption == null || newException == null)
            {
                return(false);
            }
            bool equalActionName     = previousExeption.ActionName.Equals(newException.ActionName, StringComparison.OrdinalIgnoreCase);
            bool equalInnerException = previousExeption.InnerException.Message.Equals(newException.InnerException.Message, StringComparison.OrdinalIgnoreCase);

            return(equalActionName && equalInnerException);
        }
Esempio n. 3
0
 private void PerformAction(INamedAction namedAction, int retryCount)
 {
     try
     {
         Log.Debug("Invoking action.");
         namedAction.Action.Invoke();
     }
     catch (Exception ex)
     {
         ActionPerformerException exception = new ActionPerformerException(ex, namedAction.ActionName, retryCount, ((IActionPerformer)this).NumberOfRetries, ((IActionPerformer)this).RetryDelay);
         lock (_lockExceptionList)
             ((IActionPerformer)this).Exceptions.Add(exception);
         throw exception;
     }
 }
Esempio n. 4
0
 private void PerformAction(INamedAction namedAction, int retryCount)
 {
     try
     {
         Log.Debug("Invoking action.");
         namedAction.Action.Invoke();
     }
     catch (Exception ex)
     {
         ActionPerformerException exception = new ActionPerformerException(ex, namedAction.ActionName, retryCount, ((IActionPerformer)this).NumberOfRetries, ((IActionPerformer)this).RetryDelay);
         lock (_lockExceptionList)
             ((IActionPerformer)this).Exceptions.Add(exception);
         throw exception;
     }
 }
Esempio n. 5
0
 private static bool ExceptionsAreSame(ActionPerformerException previousExeption, ActionPerformerException newException)
 {
     if (previousExeption == null || newException == null)
         return false;
     bool equalActionName = previousExeption.ActionName.Equals(newException.ActionName, StringComparison.OrdinalIgnoreCase);
     bool equalInnerException = previousExeption.InnerException.Message.Equals(newException.InnerException.Message, StringComparison.OrdinalIgnoreCase);
     return equalActionName && equalInnerException;
 }