2018-10-26 01:27:20 +00:00
|
|
|
|
using log4net;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Reflection;
|
2018-10-13 21:28:47 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace OmniLinkBridge.Notifications
|
|
|
|
|
{
|
|
|
|
|
public static class Notification
|
|
|
|
|
{
|
2018-10-26 01:27:20 +00:00
|
|
|
|
private static ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
|
|
2018-10-13 21:28:47 +00:00
|
|
|
|
private static readonly List<INotification> providers = new List<INotification>()
|
|
|
|
|
{
|
|
|
|
|
new EmailNotification(),
|
|
|
|
|
new ProwlNotification(),
|
|
|
|
|
new PushoverNotification()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static void Notify(string source, string description, NotificationPriority priority = NotificationPriority.Normal)
|
|
|
|
|
{
|
|
|
|
|
Parallel.ForEach(providers, (provider) =>
|
|
|
|
|
{
|
2018-10-26 01:27:20 +00:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
provider.Notify(source, description, priority);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
log.Error("Failed to send notification", ex);
|
|
|
|
|
}
|
2018-10-13 21:28:47 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|