public Notification(string notificationType, INotificationDetail detail, string userName, LogLevel logLevel) { this.notificationType = notificationType; this.detail = detail; this.userName = userName; this.logLevel = logLevel.ToString(); notificationDate = DateTime.Now; }
/// <summary> /// Send notification message to active clients /// </summary> /// <param name="notificationType">Type of notification</param> /// <param name="logLevel">Log level (UI display)</param> /// <param name="message">Message to display</param> /// <param name="data">Additional details (custom class)</param> public string Notify(string notificationType, INotificationDetail notificationDetail, LogLevel logLevel, IConvertible notificationId = null, bool broadcast = false) { string userName = (broadcast) ? null : UserIdentity.UserName; Notification notification = NotificationStore.AddUpdate(notificationId.ToString(), notificationType, notificationDetail, userName, logLevel); foreach (ConnectionInformation connectionInfo in ConnectionStore.GetAllConnections()) { connectionInfo.Notify(notification); } return(notificationId.ToString()); }
public Notification(string notificationId, string notificationType, INotificationDetail detail, string userName, LogLevel logLevel) : this(notificationType, detail, userName, logLevel) { this.notificationId = string.IsNullOrEmpty(notificationId) ? Guid.NewGuid().ToString() : notificationId; }
public Notification AddUpdate(string notificationId, string notificationType, INotificationDetail notificationDetail, string userName, LogLevel logLevel) { Notification notification = new Notification(notificationId, notificationType, notificationDetail, userName, logLevel); lock (_notificationLock) { IReadOnlyList <Notification> notifications = GetNotifications(_notifications, userName); Notification existingNotification = notifications.FirstOrDefault(n => n.notificationId.Equals(notification.notificationId)); if (existingNotification != null) { // Remove Existing Notification _notifications.Remove(existingNotification); } _notifications.Add(notification); } return(notification); }