protected NotificationGatewayMessageBase(INotificationMessage notificationMessage, INotificationFormatter formatter) { Mandate.ParameterNotNull(formatter, "formatter"); Mandate.ParameterNotNull(notificationMessage, "message"); _notificationMessage = notificationMessage; _formatter = formatter; Initialize(); }
public FormattedNotificationMessage(INotificationMessage notificationMessage, IFormatter formatter) { Mandate.ParameterNotNull(formatter, "formatter"); Mandate.ParameterNotNull(notificationMessage, "message"); _notificationMessage = notificationMessage; _formatter = formatter; Initialize(); }
public NotificationResponse SendNotification(string channel, INotificationMessage notification) { if (ExceptionToThrow != null) throw ExceptionToThrow; NumberOfCalls++; NotificationChannel = channel; NotificationMessage = notification; return ResponseToReturn; }
internal static INotificationMessage ToNotificationMessage(this NotificationMessageDisplay notificationMessageDisplay, INotificationMessage destination) { if (notificationMessageDisplay.Key != Guid.Empty) destination.Key = notificationMessageDisplay.Key; destination.Name = notificationMessageDisplay.Name; destination.Description = notificationMessageDisplay.Description; destination.BodyText = notificationMessageDisplay.BodyText; destination.MaxLength = notificationMessageDisplay.MaxLength; ((NotificationMessage)destination).FromAddress = notificationMessageDisplay.FromAddress; destination.BodyTextIsFilePath = notificationMessageDisplay.BodyTextIsFilePath; destination.MonitorKey = notificationMessageDisplay.MonitorKey; destination.Recipients = notificationMessageDisplay.Recipients; destination.SendToCustomer = notificationMessageDisplay.SendToCustomer; destination.Disabled = notificationMessageDisplay.Disabled; destination.ReplyTo = notificationMessageDisplay.ReplyTo; return destination; }
private void TbDualCoinWallet_TextChanged(object sender, TextChangedEventArgs e) { CoinViewModel coin = Vm.MinerProfile.CoinVm?.CoinKernel?.CoinKernelProfile?.SelectedDualCoin; if (coin == null) { return; } if (!string.IsNullOrEmpty(coin.WalletRegexPattern)) { Regex regex = new Regex(coin.WalletRegexPattern); Match match = regex.Match(CbDualCoinWallet.Text ?? string.Empty); if (!match.Success) { if (_dualCoinWalletNm == null) { _dualCoinWalletNm = MainWindowViewModel.Current.Manager .CreateMessage() .Warning("双挖币钱包地址格式不正确。") .Dismiss().WithButton("忽略", null) .Queue(); } else { MainWindowViewModel.Current.Manager.Queue(_dualCoinWalletNm); } } else { if (_dualCoinWalletNm != null) { MainWindowViewModel.Current.Manager.Dismiss(_dualCoinWalletNm); } } } }
/// <summary> /// Saves a <see cref="INotificationMessage"/> /// </summary> /// <param name="message">The <see cref="INotificationMessage"/> to be saved</param> public void SaveNotificationMessage(INotificationMessage message) { GatewayProviderService.Save(message); _notificationMessages = null; }
/// <summary> /// Merge two notification messages, for batching. Override to handle notification subtypes. /// </summary> protected virtual INotificationMessage Merge(INotificationMessage earliermessage, INotificationMessage latermessage) { return(new VersionNotificationMessage() { Version = latermessage.Version }); }
public void Init() { if (!_provider.Activated) { MerchelloContext.Current.Gateways.Notification.ActivateProvider(_provider); } DbPreTestDataWorker.DeleteAllNotificationMethods(); //// Arrange var resource = _provider.ListResourcesOffered().FirstOrDefault(); Assert.NotNull(resource, "Smtp Provider returned null for GatewayResource"); var method = _provider.CreateNotificationMethod(resource, resource.Name, "SMTP Relayed Email"); _provider.SaveNotificationMethod(method); Assert.NotNull(method, "method was null"); //// Act _message = new NotificationMessage(method.NotificationMethod.Key, "Test email", "*****@*****.**") { Recipients = "*****@*****.**", BodyText = "Successful test?", MonitorKey = _monitorKey, SendToCustomer = true }; method.SaveNotificationMessage(_message); //// Assert Assert.IsTrue(_message.HasIdentity); }
internal static NotificationMessageDisplay ToNotificationMessageDisplay(this INotificationMessage message) { return(AutoMapper.Mapper.Map <NotificationMessageDisplay>(message)); }
public void PushBack(INotificationMessage message) { _log.InfoFormat("Notifying user about: {0} {1}", message.Title, message.Message); Messages.Add(message); }
public void PushToFront(INotificationMessage message) { Messages.Insert(0, message); }
protected override INotificationMessage Merge(INotificationMessage earlierMessage, INotificationMessage laterMessage) { var earlier = earlierMessage as UpdateNotificationMessage; var later = laterMessage as UpdateNotificationMessage; if (earlier != null && later != null && earlier.Origin == later.Origin && earlier.Version + later.Updates.Count == later.Version && earlier.Updates.Count + later.Updates.Count < _maxEntriesInNotifications) { return new UpdateNotificationMessage() { Version = later.Version, Origin = later.Origin, Updates = earlier.Updates.Concat(later.Updates).ToList(), ETag = later.ETag } } ; else { return(base.Merge(earlierMessage, laterMessage)); // keep only the version number } }
public void OnPushNotificationReceived(Context context, INotificationMessage message) { OnNotificationMessageReceivedAction?.Invoke(message); }
/// <summary> /// Executes the asynchronous action associated with this subscription /// </summary> /// <param name="message">The message.</param> public abstract Task <bool> InvokeAsync(INotificationMessage message);
public Validator IsLowerThan(int value, int comparer, string property, INotificationMessage notification) => IsLowerThan((decimal)value, (decimal)comparer, property, notification);
public Validator IsGreaterOrEqualTo(int value, int comparer, string property, INotificationMessage notification) => IsGreaterOrEqualTo((decimal)value, (decimal)comparer, property, notification);
private void InvokeNotificationEvent(INotificationMessage notification) { NotificationPosted?.Invoke(this, notification); }
public void Remove(INotificationMessage notification) { Messages.Remove(notification); }
public void PushToFront(INotificationMessage message) { _log.InfoFormat("Notifying user about: {0} {1}", message.Title, message.Message); Messages.Insert(0, message); }
/// <summary> /// Sends a <see cref="IFormattedNotificationMessage"/> /// </summary> /// <param name="notificationMessage">The <see cref="IFormattedNotificationMessage"/> to be sent</param> /// <param name="formatter">The <see cref="IFormatter"/> to use to format the message</param> public virtual void Send(INotificationMessage notificationMessage, IFormatter formatter) { PerformSend(new FormattedNotificationMessage(notificationMessage, formatter)); }
public Validator IsLowerOrEqualTo(DateTime value, DateTime comparer, string property, INotificationMessage notification) { if (value > comparer) { AddNotification(property, notification); } return(this); }
/// <summary> /// Deletes a <see cref="INotificationMessage"/> /// </summary> /// <param name="message">The <see cref="INotificationMessage"/> to be deleted</param> public void DeleteNotificationMessage(INotificationMessage message) { GatewayProviderService.Delete(message); _notificationMessages = null; }
public async Task PublishAsync(INotificationMessage notificationMessage) { Validate(notificationMessage); await Task.WhenAll(_publisher.ProduceAsync(notificationMessage)); }
/// <summary> /// Sends a <see cref="IFormattedNotificationMessage"/> /// </summary> /// <param name="notificationMessage">The <see cref="IFormattedNotificationMessage"/> to be sent</param> /// <param name="formatter">The <see cref="IFormatter"/> to use to format the message</param> public virtual void Send(INotificationMessage notificationMessage, IFormatter formatter) { Send(notificationMessage, formatter, null); }
/// <summary> /// Deletes a <see cref="INotificationMessage"/> /// </summary> /// <param name="message">The <see cref="INotificationMessage"/> to be deleted</param> public void Delete(INotificationMessage message) { _notificationMessageService.Delete(message); }
public NotificationResponse SendNotification(string channel, INotificationMessage notification) { return new NotificationResponse(200, "Received", "Connected", "Active"); }
/// <summary> /// Initializes a new instance of the <see cref="NotificationEventArgs"/> class. /// </summary> public NotificationEventArgs(INotificationMessage message) { Message = message; }
public static Task <ExecutionResult> DispatchMessage(this CloudQueue queue, INotificationMessage message) => _impl.DispatchMessage(queue, message);
/// <summary> /// Sends a <see cref="IFormattedNotificationMessage"/> /// </summary> /// <param name="notificationMessage">The <see cref="IFormattedNotificationMessage"/> to be sent</param> public virtual void Send(INotificationMessage notificationMessage) { Send(notificationMessage, new DefaultFormatter()); }
/// <summary> /// Sends a <see cref="IFormattedNotificationMessage"/> /// </summary> /// <param name="notificationMessage"> /// The <see cref="IFormattedNotificationMessage"/> to be sent /// </param> /// <param name="formatter"> /// The <see cref="IFormatter"/> to use to format the message /// </param> /// <param name="attachments"> /// The attachments. /// </param> public virtual void Send(INotificationMessage notificationMessage, IFormatter formatter, IEnumerable <Attachment> attachments) { PerformSend(new FormattedNotificationMessage(notificationMessage, formatter), attachments); }
public Task SendMessageAsync(INotificationMessage notificationMessage) { if (notificationMessage is null) { throw new ArgumentNullException(nameof(notificationMessage)); } return(Task .WhenAll(notificationMessage.Recipients.Select(recipient => SendEmailNotificationAsync(recipient, notificationMessage)))); async Task SendEmailNotificationAsync(INotificationRecipient recipient, INotificationMessage notificationMessage) { var exceptions = new List <Exception>(); var addresses = ResolveRecipientEmailAddressesAsync(recipient).ConfigureAwait(false); await foreach (var address in addresses) { try { var response = await emailFactory.Create() .To(address) .Subject(GetNotificationSubject(notificationMessage)) .Body(notificationMessage.Body, notificationMessage.Html) .SendAsync() .ConfigureAwait(false); if (!response.Successful) { exceptions.Add(new Exception($"Failed to send mail to user {address}: {string.Join(" / ", response.ErrorMessages)}")); } } catch (Exception exc) { exceptions.Add(exc); } } if (exceptions.Skip(1).Any()) { throw new AggregateException(exceptions); } else if (exceptions.Any()) { throw exceptions.Single(); } } string GetNotificationSubject(INotificationMessage notificationMessage) { var subject = default(string); if (notificationMessage.Html && string.IsNullOrWhiteSpace(notificationMessage.Subject)) { try { var document = new HtmlDocument(); document.LoadHtml(notificationMessage.Body); subject = document.DocumentNode.SelectSingleNode("//title")?.InnerText; } catch { // swallow exceptions } } return(string.IsNullOrWhiteSpace(subject) ? notificationMessage.Subject : subject); } }
internal static INotificationMessage ToNotificationMessage(this NotificationMessageDisplay notificationMessageDisplay, INotificationMessage destination) { if (notificationMessageDisplay.Key != Guid.Empty) { destination.Key = notificationMessageDisplay.Key; } destination.Name = notificationMessageDisplay.Name; destination.Description = notificationMessageDisplay.Description; destination.BodyText = notificationMessageDisplay.BodyText; destination.MaxLength = notificationMessageDisplay.MaxLength; ((NotificationMessage)destination).FromAddress = notificationMessageDisplay.FromAddress; destination.BodyTextIsFilePath = notificationMessageDisplay.BodyTextIsFilePath; destination.MonitorKey = notificationMessageDisplay.MonitorKey; destination.Recipients = notificationMessageDisplay.Recipients; destination.SendToCustomer = notificationMessageDisplay.SendToCustomer; destination.Disabled = notificationMessageDisplay.Disabled; destination.ReplyTo = notificationMessageDisplay.ReplyTo; return(destination); }
public Validator IsLowerOrEqualTo(float value, float comparer, string property, INotificationMessage notification) => IsLowerOrEqualTo((decimal)value, (decimal)comparer, property, notification);
/// <summary> /// Triggers the message dismissed event. /// </summary> /// <param name="message">The message.</param> private void TriggerMessageDismissed(INotificationMessage message) { this.OnMessageDismissed?.Invoke(this, new NotificationMessageManagerEventArgs(message)); }
public Validator AreEqual(float value, float comparer, string property, INotificationMessage notification) => AreEqual((decimal)value, (decimal)comparer, property, notification);
public virtual ActionResult Index(INotificationMessage message) { throw new NotImplementedException(); }
public Validator IsBetween(float value, float from, float to, string property, INotificationMessage notification) => IsBetween((decimal)value, (decimal)from, (decimal)to, property, notification);
public Validator IsGreaterThan(float value, float comparer, string property, INotificationMessage notification) => IsGreaterThan((decimal)value, (decimal)comparer, property, notification);
public Validator IsGreaterThan(DateTime value, DateTime comparer, string property, INotificationMessage notification) { if (value <= comparer) { AddNotification(property, notification); } return(this); }
/// <summary> /// Initializes a new instance of the <see cref="NotificationMessageManagerEventArgs"/> class. /// </summary> /// <param name="message">The message.</param> public NotificationMessageManagerEventArgs(INotificationMessage message) { this.Message = message; }
public Validator IsBetween(DateTime value, DateTime from, DateTime to, string property, INotificationMessage notification) { if (!(value > from && value < to)) { AddNotification(property, notification); } return(this); }
/// <summary> /// Saves a <see cref="INotificationMessage"/> /// </summary> /// <param name="message">The <see cref="INotificationMessage"/> to save</param> public void Save(INotificationMessage message) { _notificationMessageService.Save(message); }
/// <summary> /// Deletes a single instance of <see cref="INotificationMessage"/> /// </summary> /// <param name="notificationMessage">The <see cref="INotificationMessage"/> to be deleted</param> /// <param name="raiseEvents">Optional boolean indicating whether or not to raise events</param> public void Delete(INotificationMessage notificationMessage, bool raiseEvents = true) { if(raiseEvents) if (Deleting.IsRaisedEventCancelled(new DeleteEventArgs<INotificationMessage>(notificationMessage), this)) { ((NotificationMessage) notificationMessage).WasCancelled = true; return; } using (new WriteLock(Locker)) { var uow = _uowProvider.GetUnitOfWork(); using (var repository = _repositoryFactory.CreateNotificationMessageRepository(uow)) { repository.Delete(notificationMessage); uow.Commit(); } } if (raiseEvents) Deleted.RaiseEvent(new DeleteEventArgs<INotificationMessage>(notificationMessage), this); }
public void PushBack(INotificationMessage message) { Messages.Add(message); }