public static void AddNewNotification( GenericNotificationItem notificationItem, bool dontOverwrite = false) { lock (GenericNotificationManager.syncNotificationsReadWrite) { try { SerializableDictionary<string, GenericNotificationItem> savedNotifications = GenericNotificationManager.GetSavedNotifications(); if (!dontOverwrite) { savedNotifications[notificationItem.Id] = notificationItem; GenericNotificationManager.SaveNotifications(savedNotifications); } else { if (savedNotifications.ContainsKey(notificationItem.Id)) return; savedNotifications[notificationItem.Id] = notificationItem; GenericNotificationManager.SaveNotifications(savedNotifications); } } catch (Exception ex) { Logger.Error("Failed to add notification id : {0} titled : {1} and msg : {2}... Err : {3}", (object) notificationItem.Id, (object) notificationItem.Title, (object) notificationItem.Message, (object) ex.ToString()); } } }
public static SerializableDictionary<string, GenericNotificationItem> MarkNotification( IEnumerable<string> ids, System.Action<GenericNotificationItem> setter) { lock (GenericNotificationManager.syncNotificationsReadWrite) { SerializableDictionary<string, GenericNotificationItem> lstItem = new SerializableDictionary<string, GenericNotificationItem>(); try { lstItem = GenericNotificationManager.GetSavedNotifications(); foreach (string index in ids.Where<string>((Func<string, bool>) (id => id != null && lstItem.ContainsKey(id)))) setter(lstItem[index]); GenericNotificationManager.SaveNotifications(lstItem); } catch (Exception ex) { Logger.Error("Failed to mark notification... Err : " + ex.ToString()); } return lstItem; } }