17 using System.Collections.Concurrent;
18 using System.Collections.Generic;
28 private const int RateLimit = 30;
31 private DateTime _resetTime;
33 private readonly
bool _liveMode;
34 private readonly
object _sync =
new object();
39 public ConcurrentQueue<Notification>
Messages {
get;
set; }
48 Messages =
new ConcurrentQueue<Notification>();
51 _resetTime =
default(DateTime);
62 public bool Email(
string address,
string subject,
string message,
string data, PyObject headers)
64 return Email(address, subject, message, data, headers.ConvertToDictionary<
string,
string>());
75 public bool Email(
string address,
string subject,
string message,
string data =
"", Dictionary<string, string> headers =
null)
93 public bool Sms(
string phoneNumber,
string message)
113 public bool Web(
string address,
object data, PyObject headers)
115 return Web(address, data, headers.ConvertToDictionary<
string,
string>());
124 public bool Web(
string address,
object data =
null, Dictionary<string, string> headers =
null)
144 public bool Telegram(
string id,
string message,
string token =
null)
166 public bool Ftp(
string hostname,
string username,
string password,
string filePath,
byte[] fileContent,
int? port =
null)
168 return Ftp(hostname, username, password, filePath, fileContent, secure:
false, port);
180 public bool Ftp(
string hostname,
string username,
string password,
string filePath,
string fileContent,
int? port =
null)
182 return Ftp(hostname, username, password, filePath, fileContent, secure:
false, port);
194 public bool Sftp(
string hostname,
string username,
string password,
string filePath,
byte[] fileContent,
int? port =
null)
196 return Ftp(hostname, username, password, filePath, fileContent, secure:
true, port);
208 public bool Sftp(
string hostname,
string username,
string password,
string filePath,
string fileContent,
int? port =
null)
210 return Ftp(hostname, username, password, filePath, fileContent, secure:
true, port);
224 public bool Sftp(
string hostname,
string username,
string privateKey,
string privateKeyPassphrase,
string filePath,
byte[] fileContent,
232 var ftp =
new NotificationFtp(hostname, username, privateKey, privateKeyPassphrase, filePath, fileContent, port);
249 public bool Sftp(
string hostname,
string username,
string privateKey,
string privateKeyPassphrase,
string filePath,
string fileContent,
257 var ftp =
new NotificationFtp(hostname, username, privateKey, privateKeyPassphrase, filePath, fileContent, port);
263 private bool Ftp(
string hostname,
string username,
string password,
string filePath,
byte[] fileContent,
bool secure =
true,
int? port =
null)
270 var ftp =
new NotificationFtp(hostname, username, password, filePath, fileContent, secure: secure, port);
276 private bool Ftp(
string hostname,
string username,
string password,
string filePath,
string fileContent,
bool secure =
true,
int? port =
null)
283 var ftp =
new NotificationFtp(hostname, username, password, filePath, fileContent, secure: secure, port);
302 var now = DateTime.UtcNow;
303 if (now > _resetTime)
308 _resetTime = now.Add(TimeSpan.FromHours(1));
311 if (_count < RateLimit)