예제 #1
0
 private void SendSlackMessage(SlackMessage msg, HaleAlertSlackRecipient recipient)
 {
     try
     {
         using (WebClient client = new WebClient())
         {
             client.UploadString(recipient.Webhook, "POST", JsonConvert.SerializeObject(msg));
         }
     }
     catch
     {
         throw new Exception("Could not connect to the Slack Server. Check your settings.");
     }
 }
예제 #2
0
 private SlackMessage CreateSlackMessage(HaleAlertSlackRecipient recipient, AlertSettings settings)
 {
         SlackMessage msg = new SlackMessage()
         {
             Username = recipient.Username
         ,
             Markdown = true
         ,
             Icon = recipient.Icon
         ,
             Pretext = settings.Message
         ,
             Fields = new List<SlackField>()
         {
             new SlackField("Node", settings.SourceHost, false),
             new SlackField("Check", settings.SourceFunction, false)
         }
         ,
             Color = GetAlertLevel(settings)
         };
         return msg;
 }