using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace TradeIdeas.TIProGUI.UserNotifications { public static class UserNotifications { // User Notifications queue public static List UserNotificationsQueue = new List(); /// /// Add a User Notification to the list. /// /// ID /// Date/time when message was created /// Message Subject /// Message status /// Message type /// Message in HTML /// URL to view /// Urgent message that is required to read public static void AddUserNotification(string id, DateTime? created, string subject, UserNotificationStatus? status, UserNotificationType? type, string message, string url, bool requiresAcknowledgement, DateTime? acknowledgedDate) { UserNotification userNotification = UserNotificationsQueue.Find(x => x.ID == id); if (userNotification == null) { UserNotificationsQueue.Add(new UserNotification { ID = id, Created = created, Subject = subject, Status = status, Type = type, Message = message, URL = url, RequiresAcknowledgement = requiresAcknowledgement, AcknowledgedDate = acknowledgedDate, Read = (status == UserNotificationStatus.read) }); } else { MessageBox.Show("Message already in list"); } } } public enum UserNotificationStatus { unread, read, deleted } public enum UserNotificationType { info, notification, outage } /// /// User Notification class for creating lists of messages /// public class UserNotification { public string ID; // unique ID public string Subject; // notification Subject public DateTime? Created; // Date/time when notification was created public UserNotificationStatus? Status; // Notification status public UserNotificationType? Type; // Notification type public string Message; // message in HTML public string URL; // link to message public bool RequiresAcknowledgement; // notification that requires acknowledgement public DateTime? AcknowledgedDate; // Date notification was acknowledged public bool Read; // whether or not the notification has been read } }