示例#1
0
        private bool CheckForDuplicateError(ErrorInfo exception)
        {
            ErrorInfo current      = exception;
            DateTime  repeatWindow = DateTime.Now.AddSeconds(-2);

            while (current != null)
            {
                int hashCode = current.GetHashCode();
                Log.FormattedTrace(typeof(ExceptionlessClient), "Checking for duplicate exception: hash={0} type={1}", hashCode, current.Type);
                Log.FormattedTrace(typeof(ExceptionlessClient), "Error contents: {0}", current.ToString());

                // make sure that we don't process the same error multiple times within 2 seconds.
                if (_recentlyProcessedErrors.Any(s => s.Item1 == hashCode && s.Item2 >= repeatWindow))
                {
                    Log.FormattedInfo(typeof(ExceptionlessClient), "Ignoring duplicate exception: type={0}", current.Type);
                    return(true);
                }

                // add this exception to our list of recent errors that we have processed.
                _recentlyProcessedErrors.Enqueue(Tuple.Create(hashCode, DateTime.Now));

                // only keep the last 10 recent errors
                Tuple <int, DateTime> temp;
                while (_recentlyProcessedErrors.Count > 10)
                {
                    _recentlyProcessedErrors.TryDequeue(out temp);
                }

                current = current.Inner;
            }

            return(false);
        }
 public override int GetHashCode()
 {
     unchecked
     {
         return(ErrorInfo.GetHashCode());
     }
 }
示例#3
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (ErrorCode != 0)
            {
                hash ^= ErrorCode.GetHashCode();
            }
            if (ErrorInfo.Length != 0)
            {
                hash ^= ErrorInfo.GetHashCode();
            }
            if (Content.Length != 0)
            {
                hash ^= Content.GetHashCode();
            }
            return(hash);
        }
示例#4
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         int hashCode = 41;
         if (Error != null)
         {
             hashCode = hashCode * 59 + Error.GetHashCode();
         }
         hashCode = hashCode * 59 + RemainingTokens.GetHashCode();
         if (ErrorInfo != null)
         {
             hashCode = hashCode * 59 + ErrorInfo.GetHashCode();
         }
         if (WarningsInfo != null)
         {
             hashCode = hashCode * 59 + WarningsInfo.GetHashCode();
         }
         hashCode = hashCode * 59 + ContentRemoved.GetHashCode();
         hashCode = hashCode * 59 + VersionChanged.GetHashCode();
         hashCode = hashCode * 59 + NewFileSize.GetHashCode();
         return(hashCode);
     }
 }