public Task <UserNotificationMessage> FormatUserMessageAsync(UserNotificationMessage message) { var result = CreateBasicFormattedUserNotificationMessage(message); ReviewContentNotificationModel reviewContent; try { reviewContent = _objectSerializer.Deserialize <ReviewContentNotificationModel>(message.Content); } catch (Exception) { reviewContent = new ReviewContentNotificationModel(); } if (reviewContent == null) { return(Task.FromResult(result)); } result.Subject = reviewContent.Title; if (!ContentReference.IsNullOrEmpty(reviewContent.ContentLink)) { result.Link = new Uri("epi.cms.contentdata:///" + reviewContent.ContentLink); } var userNameContainer = "<span class='epi-username external-review'>{0}</span>"; var userName = reviewContent.SenderDisplayName ?? "external editor"; userName = string.Format(userNameContainer, userName); result.Content = $"{userName} added new comment: \"'{reviewContent.Text?.Ellipsis(50)}'\""; return(Task.FromResult(result)); }
private void NotifyUser(string message) { if (!userNotificationTimer.IsEnabled) { DoubleAnimation da = new DoubleAnimation { From = 0, To = 1, Duration = new Duration(TimeSpan.FromSeconds(0.55)), AutoReverse = false }; UserNotificationMessage.Text = message; UserNotificationMessage.BeginAnimation(OpacityProperty, da); userNotificationTimer.Tick += NotificationMessageTimeout; userNotificationTimer.Start(); } else { userNotificationTimer.Stop(); UserNotificationMessage.Text = message; userNotificationTimer.Tick += NotificationMessageTimeout; userNotificationTimer.Start(); } }
/// <summary> /// Implements <see cref="IUserNotificationFormatter"/> /// Instant user notification. It's displayed in the Editor view (bell icon). /// </summary> /// <param name="message">Message to be formatted.</param> /// <returns>The formatted message.</returns> public UserNotificationMessage FormatUserMessage(UserNotificationMessage message) { var data = _objectSerializer.Deserialize <TweetedPageViewModel>(message.Content); message.Subject = $@"Your article ""{data.PageName}"" is going viral!"; message.Content = $"Your article has {data.ShareCount} tweets and retweets!"; message.Link = data.ContentLink; return(message); }
/// <summary> /// Formats the user message. /// </summary> /// <param name="notification">The notification.</param> /// <returns>UserNotificationMessage.</returns> public UserNotificationMessage FormatUserMessage(UserNotificationMessage notification) { if (notification != null) { notification.Content = "<div style=\"color:#f7542b\">" + notification.Content + "</div>"; } return(notification); }
private void NotificationMessageTimeout(object sender, EventArgs e) { DoubleAnimation da = new DoubleAnimation { From = 1, To = 0, Duration = new Duration(TimeSpan.FromSeconds(0.55)), AutoReverse = false }; da.Completed += RemoveTextInNotification; UserNotificationMessage.BeginAnimation(OpacityProperty, da); (sender as DispatcherTimer).Stop(); }
protected UserNotificationMessage CreateBasicFormattedUserNotificationMessage(UserNotificationMessage message) { return(new UserNotificationMessage { Id = message.Id, Posted = message.Posted, Sender = message.Sender, Recipient = message.Recipient, Read = message.Read }); }
public Task ServiceNotificationReceived(UserNotificationMessage message) { _log.WriteLine($"Notification message from service: {message.Message} ({message.NotificationId})"); SendMessage(new ServiceNotificationReceivedMessage(message.NotificationId, message.Message)); return(Task.CompletedTask); }