コード例 #1
0
        protected NotificationGatewayMessageBase(INotificationMessage notificationMessage, INotificationFormatter formatter)
        {
            Mandate.ParameterNotNull(formatter, "formatter");
            Mandate.ParameterNotNull(notificationMessage, "message");

            _notificationMessage = notificationMessage;
            _formatter = formatter;

            Initialize();
        }
コード例 #2
0
        protected NotificationGatewayMessageBase(INotificationMessage notificationMessage, INotificationFormatter formatter)
        {
            Mandate.ParameterNotNull(formatter, "formatter");
            Mandate.ParameterNotNull(notificationMessage, "message");

            _notificationMessage = notificationMessage;
            _formatter           = formatter;

            Initialize();
        }
コード例 #3
0
        public NotificationsChannel(ICloudQueue[] queues, INotificationFormatter formatter)
        {
            Require.NotNull(queues, "queue");
            Require.NotNull(formatter, "formatter");

            m_queues     = queues;
            m_formatter  = formatter;
            m_queueCount = queues.Length;

            var random = new Random();

            m_incomingQueueIndex = random.Next(0, m_queueCount);
            m_outgoingQueueIndex = random.Next(0, m_queueCount);
        }
コード例 #4
0
        public NotificationController(
            [NotNull] ApplicationDbContext context,
            [NotNull] ILoggerFactory loggerFactory,
            [NotNull] INotificationSender notificationSender,
            [NotNull] INotificationFormatter formatter,
            [NotNull] INotificationSubmitter submitter)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            this.context            = context ?? throw new ArgumentNullException(nameof(context));
            this.formatter          = formatter ?? throw new ArgumentNullException(nameof(formatter));
            this.submitter          = submitter ?? throw new ArgumentNullException(nameof(submitter));
            this.notificationSender = notificationSender ?? throw new ArgumentNullException(nameof(notificationSender));

            logger = loggerFactory.CreateLogger <NotificationController>();
        }
コード例 #5
0
        /// <inheritdoc />
        public async Task SendAsync(
            INotificationFormatter notificationFormatter,
            INotificationSubmitter notificationSubmitter,
            Func <Task> saver)
        {
            if (notificationRepository == null)
            {
                throw new ArgumentNullException(nameof(notificationRepository));
            }

            using (logger.BeginScope("SendAsync"))
            {
                var pendingNotifications = await notificationRepository.GetPendingNotificationByUserAsync();

                foreach (var pendingNotificationsForRecipient in pendingNotifications)
                {
                    var recipient = pendingNotificationsForRecipient.Key;
                    if (!recipient.LastNotificationCheckAt.HasValue ||
                        recipient.LastNotificationCheckAt.Value.AddHours(
                            recipient.NotificationIntervalInHours) < SystemClock.Now)
                    {
                        using (logger.BeginScope($"Send notification to {pendingNotificationsForRecipient.Key}"))
                        {
                            var content = await notificationFormatter.FormatAsync(recipient, pendingNotificationsForRecipient);

                            if (!string.IsNullOrWhiteSpace(content))
                            {
                                await SubmitToRecipient(
                                    notificationSubmitter,
                                    pendingNotificationsForRecipient,
                                    recipient,
                                    content);
                            }

                            await UpdateDatabaseForRecipient(pendingNotificationsForRecipient, recipient, saver);
                        }
                    }
                }
            }
        }
コード例 #6
0
 public abstract void Send(INotificationGatewayMessage message, INotificationFormatter formatter);
コード例 #7
0
 public abstract void Send(INotificationGatewayMessage message, INotificationFormatter formatter);