Ejemplo n.º 1
0
        public static void PostNotification(ProwlNotification notification_, bool android = false)
        {
            string prowlUrlSb = !android ?
                                @"https://prowl.weks.net/publicapi/add" :
                                @"https://www.notifymyandroid.com/publicapi/notify";
            string sThisAPIKey = !android ? GilesTrinity.Settings.Notification.IPhoneKey : GilesTrinity.Settings.Notification.AndroidKey;

            prowlUrlSb += "?apikey=" + HttpUtility.UrlEncode(sThisAPIKey.Trim()) +
                          "&application=" + HttpUtility.UrlEncode("GilesTrinity") +
                          "&description=" + HttpUtility.UrlEncode(notification_.Description) +
                          "&event=" + HttpUtility.UrlEncode(notification_.Event) +
                          "&priority=" + HttpUtility.UrlEncode(notification_.Priority.ToString());
            var updateRequest =
                (HttpWebRequest)WebRequest.Create(prowlUrlSb.ToString());

            updateRequest.ContentLength = 0;
            updateRequest.ContentType   = "application/x-www-form-urlencoded";
            updateRequest.Method        = "POST";
            //updateRequest.Timeout = 5000;
            var postResponse = default(WebResponse);

            try
            {
                postResponse = updateRequest.GetResponse();
            }
            finally
            {
                if (postResponse != null)
                {
                    postResponse.Close();
                }
            }
        }
Ejemplo n.º 2
0
        public static void AddNotificationToQueue(string description, string eventName, ProwlNotificationPriority priority)
        {
            // Queue the notification message
            var newNotification =
                new ProwlNotification
            {
                Description = description,
                Event       = eventName,
                Priority    = priority
            };

            pushQueue.Enqueue(newNotification);
        }
Ejemplo n.º 3
0
 public static void SendNotification(ProwlNotification notification)
 {
     if (GilesTrinity.Settings.Notification.IPhoneEnabled && !string.IsNullOrWhiteSpace(GilesTrinity.Settings.Notification.IPhoneKey))
     {
         var newNotification =
             new ProwlNotification
         {
             Description = notification.Description,
             Event       = notification.Event,
             Priority    = notification.Priority
         };
         try
         {
             PostNotification(newNotification);
         }
         catch
         {
         }
     }
     if (GilesTrinity.Settings.Notification.AndroidEnabled && !string.IsNullOrWhiteSpace(GilesTrinity.Settings.Notification.AndroidKey))
     {
         var newNotification =
             new ProwlNotification
         {
             Description = notification.Description,
             Event       = notification.Event,
             Priority    = notification.Priority
         };
         try
         {
             PostNotification(newNotification, true);
         }
         catch
         {
         }
     }
 }