public async void ProcessUserNotifications(UserInfo userInfo) { //userInfo. userInfo.NotificationProcessingCompleted = false; while (!userInfo.NotificationsQueue.IsEmpty) { NotificationItem notificationItem = new NotificationItem();; bool isSuccessful = userInfo.NotificationsQueue.TryDequeue(out notificationItem); if (isSuccessful) { switch (notificationItem.NotificationType) { case Enums.NotificationType.Send: await SendNotification(notificationItem.ChatId, notificationItem.Data); break; case Enums.NotificationType.Remove: try { if (notificationItem.Data != "") { int messageIdUser; messageIdUser = int.Parse(notificationItem.Data); //= notificationItem.Data; await RemoveNotification(notificationItem.ChatId, messageIdUser); } else { await RemoveNotification(notificationItem.ChatId); } } catch (Exception ex) { _logHelper.Log("FD8S9JK3K3KN5", "Cannot remove a message", LogLevel.Error); } break; default: break; } } } userInfo.NotificationProcessingCompleted = true; }
public void RouteNotification(NotificationItem notificationItem) { _logHelper.Log("JK543K34NL34L", $"Routing notification: chatId: {notificationItem.ChatId}; type: {notificationItem.NotificationType}", LogLevel.Information); _users.UserInfo[notificationItem.ChatId].NotificationsQueue.Enqueue(notificationItem); }