Ejemplo n.º 1
0
 /// <summary>
 /// Determines whether if the specified notification has been send.
 /// </summary>
 /// <param name="id">The notification identifier.</param>
 /// <param name="requestId">The request identifier.</param>
 /// <param name="parameter">The parameter value to search</param>
 /// <returns>
 ///   <c>true</c> if the specified notifications was send; otherwise, <c>false</c>.
 /// </returns>
 public bool ContainsNotification(NotificationIdEnum id, Guid requestId, string parameter)
 {
     lock (_lock)
     {
         return(_notifications.Any(n => n.Id == id && n.RequestId == requestId && n.Parameter == parameter));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Determines whether if the specified notification has been send.
 /// </summary>
 /// <param name="id">The notification identifier.</param>
 /// <param name="requestId">The request identifier.</param>
 /// <returns>
 ///   <c>true</c> if the specified notifications was send; otherwise, <c>false</c>.
 /// </returns>
 public bool ContainsNotification(NotificationIdEnum id, Guid requestId)
 {
     lock (_lock)
     {
         return(_notifications.Any(n => n.Id == id && n.RequestId == requestId));
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Sends the notification.
 /// </summary>
 /// <param name="notificationId">The notification identifier.</param>
 public void SendNotification(NotificationIdEnum notificationId)
 {
     Add(new NotificationInfo(notificationId));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Sends the notification.
 /// </summary>
 /// <param name="notificationId">The notification identifier.</param>
 /// <param name="requestId">The request identifier.</param>
 public void SendNotification(NotificationIdEnum notificationId, Guid requestId)
 {
     Add(new NotificationInfo(notificationId, requestId));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Sends the notification.
 /// </summary>
 /// <param name="notificationId">The notification identifier.</param>
 /// <param name="parameter">The parametr.</param>
 public void SendNotification(NotificationIdEnum notificationId, string parameter)
 {
     Add(new NotificationInfo(notificationId, Guid.Empty, parameter));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Sends the notification.
 /// </summary>
 /// <param name="notificationId">The notification identifier.</param>
 /// <param name="parameter">The parameter.</param>
 /// <param name="requestId">The request identifier.</param>
 public void SendNotification(NotificationIdEnum notificationId, string parameter, Guid requestId)
 {
     Add(new NotificationInfo(notificationId, requestId, parameter));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Waits the notification send.
 /// </summary>
 /// <param name="notificationId">The notification identifier.</param>
 /// <param name="requestId">The request identifier associated to the request.</param>
 /// <param name="parameter">The request parameter of the notification</param>
 protected void WaitNotificationSend(NotificationIdEnum notificationId, Guid requestId, string parameter)
 {
     Assert.That(() => _notificationsSender.ContainsNotification(notificationId, requestId, parameter), Is.True.After(5 * ONE_SECOND, ONE_SECOND / 4), "Failed to received expected notification '{0}' for request '{1}' with parameter '{2}'.", notificationId, requestId, parameter);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Logs the exception.
        /// </summary>
        /// <param name="notificationUrl">The notification URL.</param>
        /// <param name="exception">The exception.</param>
        /// <param name="requestId">The request identifier.</param>
        /// <param name="id">The notification identifier send.</param>
        private void LogException(string notificationUrl, Exception exception, Guid requestId, NotificationIdEnum id, string parameters)
        {
            TraceType traceType = _previousExceptions.IsFirstOccurrence(notificationUrl ?? string.Empty, exception) ? TraceType.ERROR : TraceType.DEBUG;

            if (LogManager.IsTraceActive(traceType))
            {
                if (IsPredictableException(exception))
                {
                    string messageFormat = (string.IsNullOrEmpty(parameters)) ? Properties.Resources.SendNotificationPredictableMessageWithoutParameter : Properties.Resources.SendNotificationPredictableMessage;
                    string errorMessage  = string.Format(CultureInfo.CurrentCulture, messageFormat, notificationUrl, id, exception.Message, requestId, parameters);
                    LogManager.WriteLog(traceType, errorMessage, "PIS.Ground.GroundCore.Common.NotificationSender", null, EventIdEnum.SendNotification);
                }
                else
                {
                    string messageFormat = (string.IsNullOrEmpty(parameters)) ? Properties.Resources.SendNotificationErrorMessageWithoutParameter : Properties.Resources.SendNotificationErrorMessage;
                    string errorMessage  = string.Format(CultureInfo.CurrentCulture, messageFormat, notificationUrl, id, requestId, parameters);
                    LogManager.WriteLog(traceType, errorMessage, "PIS.Ground.GroundCore.Common.NotificationSender", exception, EventIdEnum.SendNotification);
                }
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Waits the notification send.
 /// </summary>
 /// <param name="notificationId">The notification identifier.</param>
 /// <param name="parameter">The notification parameter</param>
 protected void WaitNotificationSend(NotificationIdEnum notificationId, string parameter)
 {
     WaitNotificationSend(notificationId, Guid.Empty, parameter);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Waits the notification send.
 /// </summary>
 /// <param name="notificationId">The notification identifier.</param>
 protected void WaitNotificationSend(NotificationIdEnum notificationId)
 {
     WaitNotificationSend(notificationId, Guid.Empty);
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NotificationInfo"/> class.
 /// </summary>
 /// <param name="id">The notification identifier.</param>
 /// <param name="requestId">The request identifier.</param>
 /// <param name="parameter">Additional parameter</param>
 public NotificationInfo(NotificationIdEnum id, Guid requestId, string parameter)
 {
     Id        = id;
     RequestId = requestId;
     Parameter = parameter;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NotificationInfo"/> class.
 /// </summary>
 /// <param name="id">The notification identifier.</param>
 /// <param name="requestId">The request identifier.</param>
 public NotificationInfo(NotificationIdEnum id, Guid requestId)
     : this(id, requestId, null)
 {
     /* No logic body */
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NotificationInfo"/> class.
 /// </summary>
 /// <param name="id">The notification identifier.</param>
 public NotificationInfo(NotificationIdEnum id)
     : this(id, Guid.Empty, null)
 {
     /* No logic body */
 }