private void Notify(QueueNotification notification) { if (NotificationReceived != null) { NotificationReceived(this, notification); } }
public async Task <IActionResult> Remove([FromBody] DequeuePosition item) { if (item is null || item.ServiceType == ServiceType.none) { return(new BadRequestResult()); } DequeuePositionResult result = await _queueService.RemoveFromQueue(item); if (result is null) { return(new NoContentResult()); } var notification = new QueueNotification { StationNumber = item.StationNumber, UserNumber = result.CustomerNumberInQueue }; try { string groupName = item.ServiceType.ToString(); await _hubContext.Clients.Group(groupName).SendQueueNotificationToGroup(notification); } catch (Exception) { } return(new OkObjectResult(result)); }
public void UpdateStation(QueueNotification notification) { App.Current.Dispatcher.Invoke(() => { var station = Stations.Where(s => s.StationNumber == notification.StationNumber).FirstOrDefault(); if (station != null) { station.PatientNumber = notification.UserNumber; } }); }
private void ProcessNotification(object sender, QueueNotification e) { #if DEBUG Console.WriteLine(e); #endif if (e == QueueNotification.SubscriptionConfirmed) { _subscribed = true; _subscriptionConfirmTime = DateTime.Now; } if (e == QueueNotification.NewMessage) { _messageFound = true; } }
public async Task Enqueue(IEvent @event, Action callback = null, TaskContinuationOptions taskContinuationOptions = TaskContinuationOptions.OnlyOnRanToCompletion) { Microsoft.Azure.ServiceBus.Message message = new Microsoft.Azure.ServiceBus.Message(UTF8Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(@event, new JsonSerializerSettings() { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }))); message.MessageId = Guid.NewGuid().ToString(); message.ContentType = "application/json"; if (callback != null) { await QueueNotification.SendAsync(message).ContinueWith((t, o) => { callback?.Invoke(); }, taskContinuationOptions); } else { await QueueNotification.SendAsync(message); } }
public async Task AddQueueNotification(NotificationTemplates template, int id, Guid userGuid, string queueName = null) { try { // Create Message. var message = new QueueNotification { TemplateName = template, Identifier = id, UserGuid = userGuid, TimestampOffset = DateTimeOffset.UtcNow }; var cloudQueueMessage = new CloudQueueMessage(JsonConvert.SerializeObject(message)); // Add to Queue. var queue = await GetQueue(queueName ?? ConfigurationManager.AppSettings["NotificationQueue"]); await queue.AddMessageAsync(cloudQueueMessage).ConfigureAwait(false); } catch (Exception ex) { Logger.LogException(ex); } }
public async Task SendQueueNotificationToGroup(ServiceType serviceType, QueueNotification notification) { await Clients.Groups(serviceType.ToString()).SendQueueNotificationToGroup(notification); }