예제 #1
0
        public async Task Notify(NotificationMessage message)
        {
            var serviceEndPoint = new Uri(GetOptions().Teams.WebhookUri);

            var client = new HttpClient();

            var request = new HttpRequestMessage(HttpMethod.Post, serviceEndPoint)
            {
                Content = new StringContent(
                    _messageBuilder.CreateMessage(message).ToString(),
                    Encoding.UTF8,
                    "application/json")
            };

            try
            {
                var response = await client.SendAsync(request);

                GetLogger().LogTrace($"Message sent. {response.StatusCode} -> {response.Content}");
            }
            catch (AggregateException e)
            {
                foreach (var exception in e.Flatten().InnerExceptions)
                {
                    GetLogger().LogError(exception, $"Failed to send message. {exception.Message}");
                }

                throw;
            }
        }
예제 #2
0
        public async Task Notify(NotificationMessage message)
        {
            var serviceEndPoint = new Uri(GetOptions().Slack.WebhookUri);
            var client          = new HttpClient();

            var request = new HttpRequestMessage(HttpMethod.Post, serviceEndPoint)
            {
                Content = new StringContent(
                    _messageBuilder.CreateMessage(message).ToString(),
                    Encoding.UTF8,
                    "application/json")
            };

            var response = await client.SendAsync(request);

            GetLogger().LogTrace($"Message sent. {response.StatusCode} -> {response.Content}");
        }