Esempio n. 1
0
        public async Task SendOrganizationHourlyOverageNoticeAsync() {
            var user = UserData.GenerateSampleUser();
            var organization = OrganizationData.GenerateSampleOrganization(_billingManager, _plans);

            await _mailer.SendOrganizationNoticeAsync(user, organization, false, true);
            await RunMailJobAsync();
        }
Esempio n. 2
0
        public async Task SendOrganizationHourlyOverageNotificationAsync()
        {
            await _mailer.SendOrganizationNoticeAsync(Settings.Current.TestEmailAddress, new OrganizationNotificationModel {
                Organization      = OrganizationData.GenerateSampleOrganization(),
                IsOverHourlyLimit = true
            });

            await RunMailJobAsync();
        }
Esempio n. 3
0
        private async Task SendOverageNotificationsAsync(Organization organization, bool isOverHourlyLimit, bool isOverMonthlyLimit)
        {
            var results = await _userRepository.GetByOrganizationIdAsync(organization.Id).AnyContext();

            foreach (var user in results.Documents)
            {
                if (!user.IsEmailAddressVerified)
                {
                    _logger.Info("User {0} with email address {1} has not been verified.", user.Id, user.EmailAddress);
                    continue;
                }

                if (!user.EmailNotificationsEnabled)
                {
                    _logger.Info().Message("User {0} with email address {1} has email notifications disabled.", user.Id, user.EmailAddress);
                    continue;
                }

                _logger.Trace("Sending email to {0}...", user.EmailAddress);
                await _mailer.SendOrganizationNoticeAsync(user.EmailAddress, new OrganizationNotificationModel {
                    Organization       = organization,
                    IsOverHourlyLimit  = isOverHourlyLimit,
                    IsOverMonthlyLimit = isOverMonthlyLimit
                }).AnyContext();
            }

            _logger.Trace().Message("Done sending email.");
        }
        private async Task SendOverageNotificationsAsync(Organization organization, bool isOverHourlyLimit, bool isOverMonthlyLimit)
        {
            var results = await _userRepository.GetByOrganizationIdAsync(organization.Id).AnyContext();

            foreach (var user in results.Documents)
            {
                if (!user.IsEmailAddressVerified)
                {
                    Log.LogInformation("User {user} with email address {EmailAddress} has not been verified.", user.Id, user.EmailAddress);
                    continue;
                }

                if (!user.EmailNotificationsEnabled)
                {
                    Log.LogInformation("User {user} with email address {EmailAddress} has email notifications disabled.", user.Id, user.EmailAddress);
                    continue;
                }

                Log.LogTrace("Sending email to {EmailAddress}...", user.EmailAddress);
                await _mailer.SendOrganizationNoticeAsync(user, organization, isOverMonthlyLimit, isOverHourlyLimit).AnyContext();
            }

            Log.LogTrace("Done sending email.");
        }