void IGrowlSender.SendNotification(IGrowlJob growl, string headline, string text) { StringBuilder sb = new StringBuilder(); sb.Append("https://www.notifymyandroid.com/publicapi/notify?"); // API-Key(s) sb.AppendFormat("apikey={0}", string.Join(",", growl.GetApiKeys())); // Application name sb.AppendFormat("&application={0}", HttpUtility.UrlEncode(growl.ApplicationName)); // Event (max. 1000 chars) sb.AppendFormat("&event={0}", HttpUtility.UrlEncode(headline.Truncate(1000, true, true))); // Description (max. 10000 chars) sb.AppendFormat("&description={0}", HttpUtility.UrlEncode(text.Truncate(10000, true, true))); // Priority sb.AppendFormat("&priority={0}", EmergencyPriority); WebRequest notificationRequest = WebRequest.Create(sb.ToString()); WebResponse notificationResponse = notificationRequest.GetResponse(); NMAResponse logicalResponse = NMAResponse.ReadResponse(notificationResponse); if (!logicalResponse.IsSuccess) { Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.NMAApiKeyIsInvalid, logicalResponse.Message); } if (!logicalResponse.CanSendAnotherRequest) { Logger.Instance.LogFormat(LogType.Warning, this, Properties.Resources.NMANoRemainingRequestsLeft, logicalResponse.ResetTimer); } }
void IGrowlSender.SendNotification(IGrowlJob growl, string headline, string text) { StringBuilder sb = new StringBuilder(); sb.Append("https://www.notifymyandroid.com/publicapi/notify?"); // API-Key(s) sb.AppendFormat("apikey={0}", string.Join(",", growl.GetApiKeys())); // Application name sb.AppendFormat("&application={0}", HttpUtility.UrlEncode(growl.ApplicationName)); // Event (max. 1000 chars) sb.AppendFormat("&event={0}", HttpUtility.UrlEncode(headline.Truncate(1000, true, true))); // Description (max. 10000 chars) sb.AppendFormat("&description={0}", HttpUtility.UrlEncode(text.Truncate(10000, true, true))); // Priority sb.AppendFormat("&priority={0}", EmergencyPriority); WebRequest notificationRequest = WebRequest.Create(sb.ToString()); WebResponse notificationResponse = notificationRequest.GetResponse(); NMAResponse logicalResponse = NMAResponse.ReadResponse(notificationResponse); if (!logicalResponse.IsSuccess) { Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.NMAApiKeyIsInvalid, logicalResponse.Message); } if (!logicalResponse.CanSendAnotherRequest) { Logger.Instance.LogFormat(LogType.Warning, this, Properties.Resources.NMANoRemainingRequestsLeft, logicalResponse.ResetTimer); } }