/// <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)); } }
/// <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)); } }
/// <summary> /// Sends the notification. /// </summary> /// <param name="notificationId">The notification identifier.</param> public void SendNotification(NotificationIdEnum notificationId) { Add(new NotificationInfo(notificationId)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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); }
/// <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); } } }
/// <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); }
/// <summary> /// Waits the notification send. /// </summary> /// <param name="notificationId">The notification identifier.</param> protected void WaitNotificationSend(NotificationIdEnum notificationId) { WaitNotificationSend(notificationId, Guid.Empty); }
/// <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; }
/// <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 */ }
/// <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 */ }