public void RegisterNotification(Serialization.NotificationType type, string title, string message, Exception ex, string backupid, string action, Func <INotification, INotification[], INotification> conflicthandler) { lock (m_lock) { var notification = new Notification() { ID = -1, Type = type, Title = title, Message = message, Exception = ex == null ? "" : ex.ToString(), BackupID = backupid, Action = action ?? "", Timestamp = DateTime.UtcNow }; var conflictResult = conflicthandler(notification, GetNotifications()); if (conflictResult == null) { return; } if (conflictResult != notification) { DeleteFromDb("Notifications", conflictResult.ID); } OverwriteAndUpdateDb(null, null, null, new INotification[] { notification }, @"INSERT INTO ""Notifications"" (""Type"", ""Title"", ""Message"", ""Exception"", ""BackupID"", ""Action"", ""Timestamp"") VALUES (?,?,?,?,?,?,?)", x => new object[] { x.Type.ToString(), x.Title, x.Message, x.Exception, x.BackupID, x.Action, NormalizeDateTimeToEpochSeconds(x.Timestamp) } ); if (type == Duplicati.Server.Serialization.NotificationType.Error) { Program.DataConnection.ApplicationSettings.UnackedError = true; } else if (type == Duplicati.Server.Serialization.NotificationType.Warning) { Program.DataConnection.ApplicationSettings.UnackedWarning = true; } } System.Threading.Interlocked.Increment(ref Program.LastNotificationUpdateID); Program.StatusEventNotifyer.SignalNewEvent(); }
public void RegisterNotification(Serialization.NotificationType type, string title, string message, Exception ex, string backupid, string action, Func <INotification, INotification[], INotification> conflicthandler) { lock (m_lock) { var notification = new Notification() { ID = -1, Type = type, Title = title, Message = message, Exception = ex == null ? "" : ex.ToString(), BackupID = backupid, Action = action ?? "", Timestamp = DateTime.UtcNow }; var conflictResult = conflicthandler(notification, GetNotifications()); if (conflictResult == null) { return; } if (conflictResult != notification) { DeleteFromDb(typeof(Notification).Name, conflictResult.ID); } OverwriteAndUpdateDb(null, null, null, new Notification[] { notification }, false); if (type == Duplicati.Server.Serialization.NotificationType.Error) { Program.DataConnection.ApplicationSettings.UnackedError = true; } else if (type == Duplicati.Server.Serialization.NotificationType.Warning) { Program.DataConnection.ApplicationSettings.UnackedWarning = true; } } System.Threading.Interlocked.Increment(ref Program.LastNotificationUpdateID); Program.StatusEventNotifyer.SignalNewEvent(); }