Example #1
0
 /// <summary>
 /// Determines if a warning should be sent based on if a warning of the same type has been sent.
 /// </summary>
 /// <param name="warning">Warning to be sent</param>
 /// <returns>Boolean indicating if a warning should be sent</returns>
 private bool WarningShouldSendType(LoadBalancingWarning warning)
 {
     return !(_sentWarningMessages.ContainsKey(warning.NodeName)
         && _sentWarningMessages[warning.NodeName].Contains(warning.WarningType));
 }
Example #2
0
        /// <summary>
        /// Queues a load balancing warning for future sending.
        /// Verifies that a message of the specified type has not been sent within NODE_WARNING_DELAY_HOURS.
        /// </summary>
        /// <param name="warning">Warning to be sent</param>
        protected void QueueWarningEmail(LoadBalancingWarning warning)
        {
            if (WarningShouldSendTime(warning) || WarningShouldSendType(warning))
            {
                _warningMessages.Add(warning);

                _nodeWarningSendTime[warning.NodeName] = DateTime.Now;
                if (!_sentWarningMessages.ContainsKey(warning.NodeName))
                    _sentWarningMessages.Add(warning.NodeName, new List<LoadBalancingWarning.WarningTypeEnum>());
                _sentWarningMessages[warning.NodeName].Add(warning.WarningType);
            }
        }
Example #3
0
 /// <summary>
 /// Determines if a warning should be sent based on the last time a warning was sent.
 /// </summary>
 /// <param name="warning">Warning to be sent</param>
 /// <returns>Boolean indicating if a warning should be sent</returns>
 private bool WarningShouldSendTime(LoadBalancingWarning warning)
 {
     bool shouldSendTime = true;
     if (_nodeWarningSendTime.ContainsKey(warning.NodeName))
     {
         TimeSpan lastEmailInterval = DateTime.Now.Subtract(_nodeWarningSendTime[warning.NodeName]);
         if (lastEmailInterval.TotalHours < NODE_WARNING_DELAY_HOURS)
             shouldSendTime = false;
         else
             _sentWarningMessages.Remove(warning.NodeName); //greater than NODE_WARNING_DELAY_HOURS, reset the sent warning messages
     }
     return shouldSendTime;
 }
Example #4
0
 private void RaiseSendWarning(LoadBalancingWarning warning)
 {
     if (OnSendWarning != null)
         OnSendWarning(warning);
 }