protected override async Task <OnCallDailyNotification> BuildNotification(
            SupportRequestRepository supportRequestRepository,
            DateTime referenceTime)
        {
            var onCallAlias = await _pagerDutyClient.GetPrimaryOnCallAsync();

            var targetEmailAddress = string.Format(_targetEmailAddressFormat, onCallAlias);

            List <SupportRequest> unresolvedIssues;

            using (var connection = await supportRequestRepository.OpenConnectionAsync())
            {
                unresolvedIssues = await supportRequestRepository.GetUnresolvedIssues(connection, onCallAlias);
            }

            return(new OnCallDailyNotification(referenceTime, unresolvedIssues, targetEmailAddress));
        }
示例#2
0
        protected SupportRequestsNotificationScheduledTask(
            InitializationConfiguration configuration,
            Func <Task <SqlConnection> > openSupportRequestSqlConnectionAsync,
            ILoggerFactory loggerFactory)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            _messagingService = new MessagingService(loggerFactory, configuration.SmtpUri);

            _supportRequestRepository = new SupportRequestRepository(loggerFactory, openSupportRequestSqlConnectionAsync);
        }
示例#3
0
        protected override async Task <WeeklySummaryNotification> BuildNotification(
            SupportRequestRepository supportRequestRepository,
            DateTime referenceTime)
        {
            SingleWeekSummary         lastWeekSummary;
            SingleWeekSummary         priorWeekSummary;
            List <SupportRequest>     unresolvedIssues;
            IDictionary <string, int> topSupportRequestReasonsLastWeek;

            var startDateUtcLastWeek  = referenceTime.AddDays(-7);
            var startDateUtcPriorWeek = referenceTime.AddDays(-14);

            using (var connection = await supportRequestRepository.OpenConnectionAsync())
            {
                unresolvedIssues = await supportRequestRepository.GetUnresolvedIssues(connection);

                lastWeekSummary = await supportRequestRepository.GetSingleWeekSummary(
                    connection,
                    startDateUtcLastWeek,
                    referenceTime,
                    unresolvedIssues);

                priorWeekSummary = await supportRequestRepository.GetSingleWeekSummary(
                    connection,
                    startDateUtcPriorWeek,
                    startDateUtcLastWeek,
                    unresolvedIssues);

                topSupportRequestReasonsLastWeek = await supportRequestRepository.GetTopSupportRequestReasonsLastWeek(
                    connection,
                    startDateUtcLastWeek,
                    referenceTime);
            }

            return(new WeeklySummaryNotification(
                       referenceTime,
                       unresolvedIssues,
                       _targetEmailAddress,
                       lastWeekSummary,
                       priorWeekSummary,
                       topSupportRequestReasonsLastWeek));
        }
示例#4
0
        protected SupportRequestsNotificationScheduledTask(
            IDictionary <string, string> jobArgsDictionary,
            ILoggerFactory loggerFactory)
        {
            if (jobArgsDictionary == null)
            {
                throw new ArgumentNullException(nameof(jobArgsDictionary));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            var smtpUri = jobArgsDictionary[JobArgumentNames.SmtpUri];

            _messagingService = new MessagingService(loggerFactory, smtpUri);

            var databaseConnectionString = jobArgsDictionary[JobArgumentNames.SourceDatabase];
            var sourceDatabase           = new SqlConnectionStringBuilder(databaseConnectionString);

            _supportRequestRepository = new SupportRequestRepository(loggerFactory, sourceDatabase);
        }
 protected abstract Task <TNotification> BuildNotification(SupportRequestRepository supportRequestRepository, DateTime referenceTime);
        protected SupportRequestsNotificationScheduledTask(
            InitializationConfiguration configuration,
            Func <Task <SqlConnection> > openSupportRequestSqlConnectionAsync,
            ILoggerFactory loggerFactory)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (loggerFactory == null)
            {
                throw new ArgumentNullException(nameof(loggerFactory));
            }

            var serializer     = new ServiceBusMessageSerializer();
            var topicClient    = new TopicClientWrapper(configuration.EmailPublisherConnectionString, configuration.EmailPublisherTopicName);
            var enqueuer       = new EmailMessageEnqueuer(topicClient, serializer, loggerFactory.CreateLogger <EmailMessageEnqueuer>());
            var messageService = new AsynchronousEmailMessageService(
                enqueuer,
                loggerFactory.CreateLogger <AsynchronousEmailMessageService>(),
                configuration);

            _messagingService = new MessagingService(messageService, loggerFactory.CreateLogger <MessagingService>());

            _supportRequestRepository = new SupportRequestRepository(loggerFactory, openSupportRequestSqlConnectionAsync);
        }