/// <summary> /// Called when a notification is sent. /// </summary> /// <param name="notification">The notification.</param> internal static void OnNotificationSent(NotificationEventArgs notification) { if (Closed) { return; } Trace(notification.ToString()); NotificationSent?.ThreadSafeInvoke(null, notification); }
/// <summary> /// Gets a notification if one was sent. /// </summary> /// <returns>The sent notification.</returns> public Notification GetSentNotification() { NotificationSent notificationSent = this.raisedEvents.OfType <NotificationSent>().SingleOrDefault(); if (notificationSent == null) { throw new InvalidOperationException("A notification was not sent."); } return(notificationSent.Notification); }
public Task HandleAsync(SendNotification notification) { _repository.add(new Notification(notification.Email, notification.Text)); var notificationSent = new NotificationSent(notification.Email, notification.Text); Console.WriteLine($"Sending NotificationSent event: {@notification.Email} {notification.Text}"); _clientBus.PublishAsync(notificationSent, default(Guid), cfg => cfg.WithExchange(ex => ex.WithName("Events")).WithRoutingKey("notificationsent.#")); return(Task.CompletedTask); }
public bool AssignToUser(NotificationSent sentObj) { try { return(_service.provider.AssignToUsers(sentObj)); } catch (Exception ex) { _logger.LogError(ex, "AssignToUser"); throw new Exception("Unable to fetch"); } }
public bool AssignToUsers(NotificationSent list) { using (var conn = new SqlConnection(this.Connection)) { foreach (var oneuser in list.EmployeeIDs) { conn.Execute(@"INSERT INTO NotificationSent (NotificationID, SentTo, Status) SELECT @nid, @sentto, @status WHERE NOT EXISTS (SELECT NotificationID FROM NotificationSent WHERE NotificationID = nid2 AND SentTo = @sento2);", new { nid = list.NotificationID, sentto = oneuser, status = (int)NotificationStatus.Sent, nid2 = list.NotificationID, @sentto2 = oneuser }); } return(true); } }
private void AssertNotificationSentEventRaised(NotificationTest test, NotificationAccount <Guid> account, PushNotification expectedNotification) { NotificationSent notificationSent = test.RaisedEvents.OfType <NotificationSent>().SingleOrDefault(); notificationSent.Should().NotBeNull(); notificationSent.AccountId.ShouldBeEquivalentTo(account.AccountId.ToString()); notificationSent.Notification.NotificationType.ShouldBeEquivalentTo(NotificationType.Push); string expectedDeviceId = null; if (account.MobileDevices != null && account.MobileDevices.Any()) { MobileDevice device = account.MobileDevices.Single(); expectedDeviceId = device.DeviceId; } notificationSent.Destination.ShouldBeEquivalentTo(expectedDeviceId); notificationSent.EndpointName.ShouldBeEquivalentTo(Constants.PushNotificationEndPoint); this.AssertNotification((PushNotification)notificationSent.Notification, expectedNotification); }
public bool AssignToUsers(NotificationSent list) { return(provider.AssignToUsers(list)); }