Exemple #1
0
        public static void PostNotification(ProwlNotification notification_, bool bForAndroid = false)
        {
            string prowlUrlSb  = !bForAndroid ? @"https://prowl.weks.net/publicapi/add" : @"https://www.notifymyandroid.com/publicapi/notify";
            string sThisAPIKey = !bForAndroid ? sProwlAPIKey : sAndroidAPIKey;

            prowlUrlSb += "?apikey=" + HttpUtility.UrlEncode(sThisAPIKey) +
                          "&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();
                }
            }
        }
Exemple #2
0
        void IJob.DoJob(Operation operation)
        {
            // Construct Notification text
            string body = "Einsatz:\r\n";

            body += "Zeitstempel: " + operation.Timestamp.ToString() + "\r\n";
            body += "Stichwort: " + operation.Keyword + "\r\n";
            body += "Einsatznr: " + operation.OperationNumber + "\r\n";
            body += "Hinweis: " + operation.Comment + "\r\n";
            body += "Mitteiler: " + operation.Messenger + "\r\n";
            body += "Einsatzort: " + operation.Location + "\r\n";
            body += "Straße: " + operation.Street + " " + operation.StreetNumber + "\r\n";
            body += "Ort: " + operation.ZipCode + " " + operation.City + "\r\n";
            body += "Objekt: " + operation.Property + "\r\n";

            ProwlNotification notifi = new ProwlNotification();

            notifi.Priority    = ProwlNotificationPriority.Emergency;
            notifi.Event       = "Feuerwehr Einsatz";
            notifi.Description = body;

            //Send the Message
            try
            {
                pclient.PostNotification(notifi);
            }
            catch (Exception ex)
            {
                Logger.Instance.LogFormat(LogType.Error, this, "An error occurred while sending the Prowl Messages.");
                Logger.Instance.LogException(this, ex);
            }
        }
Exemple #3
0
        void IJob.Execute(IJobContext context, Operation operation)
        {
            // Construct Notification text
            string body = "Einsatz:\r\n";
            body += "Zeitstempel: " + operation.Timestamp.ToString() + "\r\n";
            body += "Stichwort: " + operation.Keywords.Keyword + "\r\n";
            body += "Meldebild: " + operation.Picture + "\r\n";
            body += "Einsatznr: " + operation.OperationNumber + "\r\n";
            body += "Hinweis: " + operation.Comment + "\r\n";
            body += "Mitteiler: " + operation.Messenger + "\r\n";
            body += "Einsatzort: " + operation.Einsatzort.Location + "\r\n";
            body += "Straße: " + operation.Einsatzort.Street + " " + operation.Einsatzort.StreetNumber + "\r\n";
            body += "Ort: " + operation.Einsatzort.ZipCode + " " + operation.Einsatzort.City + "\r\n";
            body += "Objekt: " + operation.Einsatzort.Property + "\r\n";

            ProwlNotification notifi = new ProwlNotification();
            notifi.Priority = ProwlNotificationPriority.Emergency;
            notifi.Event = "Feuerwehr Einsatz";
            notifi.Description = body;

            //Send the Message
            try
            {
                _client.PostNotification(notifi);
            }
            catch (Exception ex)
            {
                Logger.Instance.LogFormat(LogType.Error, this, "An error occurred while sending the Prowl Messages.", ex);
            }
        }
Exemple #4
0
        //public enum Priority { ProwlNotificationPriority.
        public static void Send(string msgDescription, string msgEvent, Priority msgPriority)
        {
            // Before posting a notification,
            // check out the [app.config] file to configure the Prowl client.
            try
            {
                // Create a notification.
                var notification = new ProwlNotification();

                notification.Description = msgDescription;
                notification.Event       = msgEvent;
                notification.Priority    = (ProwlNotificationPriority)msgPriority;
                // Create the Prowl client.
                // By default, the Prowl client will attempt to load configuration
                // from the configuration file (app.config).  You can use an overloaded constructor
                // to configure the client directly and bypass the configuration file.
                var clientCfg = new ProwlClientConfiguration();
                clientCfg.ApiKeychain     = API_KEY;
                clientCfg.ApplicationName = "Copper Hedge";

                var prowlClient = new ProwlClient(clientCfg);

                // Post the notification.
                prowlClient.PostNotification(notification);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
Exemple #5
0
        public static void PostNotification(ProwlNotification notification_, bool bForAndroid = false)
        {
            string prowlUrlSb = !bForAndroid ? @"https://prowl.weks.net/publicapi/add" : @"https://www.notifymyandroid.com/publicapi/notify";
            string sThisAPIKey = !bForAndroid ? sProwlAPIKey : sAndroidAPIKey;
            prowlUrlSb += "?apikey=" + HttpUtility.UrlEncode(sThisAPIKey) +
                          "&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();
            }
        }
Exemple #6
0
        private static void Main(string[] args)
        {
            var show_help = false;
            var apikey = "";
            var applicationName = "Default";
            var eventName = "Default";
            var show_timestamp = false;

            var p = new OptionSet
                    {
                        {
                            "a|apikey=", "the {APIKEY} for Prowl.", v =>
                            {
                                if (v == null)
                                {
                                    throw new OptionException("Missing api key for option -a", "-a");
                                }
                                apikey = v;
                            }
                        },
                        { "n|name=", "the {NAME} of the application that sends the notification.", v => applicationName = v },
                        { "e|event=", "the {EVENT} of the notification.", v => eventName = (v ?? "Default") },
                        { "d|datetime=", "shows a timestamp with the message.", v => show_timestamp = v != null },
                        { "h|help", "show this message and exit", v => show_help = v != null },
                    };

            List<string> extra;
            try
            {
                extra = p.Parse(args);
            }
            catch (OptionException e)
            {
                Console.Write("prowlNotifier: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try 'prowlNotifier --help' for more information.");
                return;
            }

            if (show_help || string.IsNullOrEmpty(apikey))
            {
                ShowHelp(p);
                return;
            }

            // Create and send the notification.
            var message = string.Join(" ", extra.ToArray());
            if (string.IsNullOrEmpty(message))
            {
                message = "Test";
            }

            if (show_timestamp) message = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + " " + message;

            var notification = new ProwlNotification { Description = message, Event = eventName, Priority = ProwlNotificationPriority.Normal };

            var client = new ProwlClient(new ProwlClientConfiguration { ApiKeychain = apikey, ApplicationName = applicationName });
            client.PostNotification(notification);
        }
        public void Send(string myevent, string mydesc, ProwlNotificationPriority priority = ProwlNotificationPriority.Normal)
        {
            var notification = new ProwlNotification();

            notification.Event       = myevent;
            notification.Description = mydesc;
            notification.Priority    = priority;
            m_prowl.PostNotification(notification);
        }
Exemple #8
0
        private void sendProwlMessage(string prowlEvent, string description, ProwlNotificationPriority priority = ProwlNotificationPriority.Normal)
        {
            var notification = new ProwlNotification();

            notification.Event       = prowlEvent;
            notification.Description = description;
            notification.Priority    = priority;
            _prowl.PostNotification(notification);
        }
Exemple #9
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);
 }
Exemple #10
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);
        }
Exemple #11
0
        public static void SendNotification(ProwlNotification notification)
        {
            //settings.bEnableProwl &&
            if (!String.IsNullOrEmpty(sProwlAPIKey))
            {
                var newNotification =
                        new ProwlNotification
                        {
                            Description = notification.Description,
                            Event = notification.Event,
                            Priority = notification.Priority
                        };
                try
                {
                    PostNotification(newNotification);
                }
                catch
                {

                }
            }//settings.bEnableAndroid &&
            if (!String.IsNullOrEmpty(sAndroidAPIKey))
            {
                var newNotification =
                        new ProwlNotification
                        {
                            Description = notification.Description,
                            Event = notification.Event,
                            Priority = notification.Priority
                        };
                try
                {
                    PostNotification(newNotification, true);
                }
                catch
                {

                }
            }
        }
Exemple #12
0
 public static void SendNotification(ProwlNotification notification)
 {//settings.bEnableProwl &&
     if (!String.IsNullOrEmpty(sProwlAPIKey))
     {
         var newNotification =
             new ProwlNotification
         {
             Description = notification.Description,
             Event       = notification.Event,
             Priority    = notification.Priority
         };
         try
         {
             PostNotification(newNotification);
         }
         catch
         {
         }
     }//settings.bEnableAndroid &&
     if (!String.IsNullOrEmpty(sAndroidAPIKey))
     {
         var newNotification =
             new ProwlNotification
         {
             Description = notification.Description,
             Event       = notification.Event,
             Priority    = notification.Priority
         };
         try
         {
             PostNotification(newNotification, true);
         }
         catch
         {
         }
     }
 }