Beispiel #1
0
        public int SendNotification(string notificationBody, bool sendWithHighPrio)
        {
            int    successfulNotifications = 0;
            string monitoringName          = String.Format("PM from {0}", monitoringConfig.Name);

            if (monitoringConfig.PushInterfaces != null)
            {
                foreach (KeyValuePair <string, Type> pushInterface in monitoringConfig.PushInterfaces)
                {
                    Notification notify = null;
                    logEntries.Add(new JournalEntry(String.Format("Notification via {0}...", pushInterface.Value.Name)));
                    if (pushInterface.Value == typeof(NotificationPushover))
                    {
                        notify = new NotificationPushover(pushInterface.Key, notificationBody, monitoringName, sendWithHighPrio, false);
                        if (notify.NotificationSuccessfulSend)
                        {
                            successfulNotifications++;
                        }
                    }
                    else if (pushInterface.Value == typeof(NotificationPushalot))
                    {
                        notify = new NotificationPushalot(pushInterface.Key, notificationBody, monitoringName, sendWithHighPrio, false);
                        if (notify.NotificationSuccessfulSend)
                        {
                            successfulNotifications++;
                        }
                    }
                    else if (pushInterface.Value == typeof(NotificationTelegram))
                    {
                        notify = new NotificationTelegram(pushInterface.Key, notificationBody, monitoringName, sendWithHighPrio, false);
                        if (notify.NotificationSuccessfulSend)
                        {
                            successfulNotifications++;
                        }
                    }

                    if (notify != null)
                    {
                        logEntries.AddRange(notify.Log);
                    }
                    logEntries.Add(new JournalEntry(String.Format("...was processed!"), !(notify != null && notify.NotificationSuccessfulSend)));
                }
            }

            return(successfulNotifications);
        }
        public int SendNotification(string notificationBody, bool sendWithHighPrio)
        {
            int    successfulNotifications = 0;
            string monitoringName          = String.Format("PM from {0}", monitoringConfig.Name);

            if (monitoringConfig.PushInterfaces != null)
            {
                foreach (KeyValuePair <string, Type> pushInterface in monitoringConfig.PushInterfaces)
                {
                    if (pushInterface.Value == typeof(NotificationPushover))
                    {
                        Notification notify = new NotificationPushover(pushInterface.Key, notificationBody, monitoringName, sendWithHighPrio, false);
                        if (notify.NotificationSuccessfulSend)
                        {
                            successfulNotifications++;
                        }
                    }
                    else if (pushInterface.Value == typeof(NotificationPushalot))
                    {
                        Notification notify = new NotificationPushalot(pushInterface.Key, notificationBody, monitoringName, sendWithHighPrio, false);
                        if (notify.NotificationSuccessfulSend)
                        {
                            successfulNotifications++;
                        }
                    }
                    else if (pushInterface.Value == typeof(NotificationTelegram))
                    {
                        Notification notify = new NotificationTelegram(pushInterface.Key, notificationBody, monitoringName, sendWithHighPrio, false);
                        if (notify.NotificationSuccessfulSend)
                        {
                            successfulNotifications++;
                        }
                    }
                }
            }

            return(successfulNotifications);
        }
        public int SendNotification(string notificationBody, bool sendWithHighPrio)
        {
            int successfulNotifications = 0;
            string monitoringName = String.Format("PM from {0}", monitoringConfig.Name);

            if (monitoringConfig.PushInterfaces != null)
            {
                foreach (KeyValuePair<string, Type> pushInterface in monitoringConfig.PushInterfaces)
                {
                    if (pushInterface.Value == typeof(NotificationPushover))
                    {
                        Notification notify = new NotificationPushover(pushInterface.Key, notificationBody, monitoringName, sendWithHighPrio, false);
                        if(notify.NotificationSuccessfulSend) { successfulNotifications++; }
                    }
                    else if (pushInterface.Value == typeof(NotificationPushalot))
                    {
                        Notification notify = new NotificationPushalot(pushInterface.Key, notificationBody, monitoringName, sendWithHighPrio, false);
                        if (notify.NotificationSuccessfulSend) { successfulNotifications++; }
                    }
                    else if (pushInterface.Value == typeof(NotificationTelegram))
                    {
                        Notification notify = new NotificationTelegram(pushInterface.Key, notificationBody, monitoringName, sendWithHighPrio, false);
                        if (notify.NotificationSuccessfulSend) { successfulNotifications++; }
                    }
                }
            }

            return successfulNotifications;
        }