static string GetSeverityIcon(NotificationSeverity severity) { switch (severity) { case NotificationSeverity.Error: return(Gui.Stock.Error); case NotificationSeverity.Information: return(Gui.Stock.Information); case NotificationSeverity.Warning: return(Gui.Stock.Warning); } LoggingService.LogError("Unknown NotificationSeverity value {0}", severity.ToString()); return(Gui.Stock.Information); }
//it cannot be a utility function, it just uses actual Controls to show notifications private void NotifyOnScreen(string message, NotificationSeverity how_important) { //TODO: notify by raising a bar like "remember password" in FF 3.6, not MessageBox MessageBox.Show(message, how_important.ToString()); }
/// <summary> /// Verifies if notifications of given severity need to be sent considering the configuration /// </summary> /// <param name="severity">Severity for which to check</param> /// <returns>True if it is time to send this severity and false otherwise</returns> internal async Task <bool> CheckIfNeedToSendAsync(NotificationSeverity severity) { if (await _context.Notifications.AnyAsync(ntf => ntf.IsSent && ntf.Severity == severity)) { var interval = new TimeSpan( 0, 0, Convert.ToInt32(_config[$"ServiceManager:NotificationService:Frequencies:{severity.ToString()}"]) ); var lastSentDate = (await _context .Notifications .Where(ntf => ntf.IsSent && ntf.Severity == severity) .OrderByDescending(ntf => ntf.DateSent) .FirstAsync()) .DateSent; return(lastSentDate < DateTime.UtcNow - interval); } return(true); }