public List<MoniverseNotification> GetNotificationsForGame(string gameId, MessageTopic Topic, NotificationLevel Level, DateTime start, DateTime end) { List<MoniverseNotification> notificationList = new List<MoniverseNotification>(); string topic; string level = "Info"; switch (Topic) { case MessageTopic.All: topic = "Error"; break; default: topic = Topic.ToString(); break; } string query = String.Format(@"select * from {5} WHERE GameID = '{0}' -- AND Topic = '{1}' -- AND Level = '{2}' AND CreatedAt BETWEEN '{3}' AND '{4}' ORDER BY CreatedAt DESC;", gameId, topic, level, start.ToString("yyyy-MM-dd HH:mm:ss"), end.ToString("yyyy-MM-dd HH:mm:ss"), NotificationTable ); notificationList = DBManager.Instance.Query<MoniverseNotification>(Datastore.Monitoring, query).ToList<MoniverseNotification>(); return notificationList; }
public async Task Publish(MessageTopic topic, ITraceable message, Guid correlationId) { message.CorrelationId = correlationId; var queueName = topic.ToString().ToLowerInvariant(); var queue = TableClient.GetQueueReference(queueName); bool retry; int attempts = 0; do { retry = false; attempts++; try { var msg = new CloudQueueMessage(JsonConvert.SerializeObject(message)); _logger.LogInformation($"Published message {queueName}:{message.CorrelationId}"); await queue.AddMessageAsync(msg); } catch (StorageException ex) { _logger.LogError(ex, $"Error publishing message {queueName}:{message.CorrelationId}"); var ri = ex.RequestInformation; if (ri.HttpStatusCode == 404) // if error response is 404 then queue does not exist { _logger.LogInformation($"Creating queue {queueName}"); await queue.CreateIfNotExistsAsync(); _logger.LogInformation($"Created queue {queueName} successfully"); retry = true; } else { throw; } } } while (retry && attempts < 4); }
public override string ToString() { return(String.Format("{0}.{1}.{2}", name, type.ToString(), topic.ToString())); }
public override string ToString() { return($"{_messageName}.{_messageType.ToString("G")}.{_messageTopic.ToString("G")}"); }