SendNotification() 공개 메소드

public SendNotification ( INotification notification ) : NotificationResult
notification INotification
리턴 NotificationResult
예제 #1
0
        public virtual bool SendNotification(string title, string message, string apiKeys, NotificationPriority priority = NotificationPriority.Normal, string url = null)
        {
            try
            {
                var notification = new Notification
                                   {
                                       Application = "NzbDrone",
                                       Description = message,
                                       Event = title,
                                       Priority = priority,
                                       Url = url
                                   };

                foreach (var apiKey in apiKeys.Split(','))
                    notification.AddApiKey(apiKey.Trim());

                var client = new ProwlClient();

                Logger.Trace("Sending Prowl Notification");

                var notificationResult = client.SendNotification(notification);

                if (String.IsNullOrWhiteSpace(notificationResult.ErrorMessage))
                    return true;
            }

            catch (Exception ex)
            {
                Logger.TraceException(ex.Message, ex);
                Logger.Warn("Invalid API Key(s): {0}", apiKeys);
            }

            return false;
        }
예제 #2
0
        public void SendNotification(string title, string message, string apiKey, NotificationPriority priority = NotificationPriority.Normal, string url = null)
        {
            try
            {
                var notification = new Prowlin.Notification
                                   {
                                       Application = "Sonarr",
                                       Description = message,
                                       Event = title,
                                       Priority = priority,
                                       Url = url
                                   };

                notification.AddApiKey(apiKey.Trim());

                var client = new ProwlClient();

                _logger.Debug("Sending Prowl Notification");

                var notificationResult = client.SendNotification(notification);

                if (!string.IsNullOrWhiteSpace(notificationResult.ErrorMessage))
                {
                    throw new InvalidApiKeyException("API Key: " + apiKey + " is invalid");
                }
            }

            catch (Exception ex)
            {
                _logger.DebugException(ex.Message, ex);
                _logger.Warn("Invalid API Key: {0}", apiKey);
            }
        }