Пример #1
0
        public void TestEmailLinks()
        {
            var administrator = _administratorAccountsCommand.CreateTestAdministrator(1);
            var campaign      = CreateCampaign(administrator);
            var member        = _memberAccountsCommand.CreateTestMember(0);

            _userAccountsCommand.DeactivateUserAccount(member, Guid.NewGuid());

            // Send.

            var campaignEmail = _campaignEmailsCommand.CreateEmail(campaign, member);

            _campaignEmailsCommand.Send(new[] { campaignEmail }, campaign.Id, false);

            var email = _emailServer.AssertEmailSent();

            var links = email.GetHtmlView().GetLinks();

            Assert.AreEqual(12, links.Count);

            const string definition = "ReengagementEmail";

            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl("~/"), links[0]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl("~/search/jobs"), links[1]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl(true, "~/login"), links[2]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/profile"), links[3]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/profile"), links[4]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl("~/"), links[5]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl("~/members/resources"), links[6]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/profile"), links[7]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/profile"), links[8]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl("~/"), links[9]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/settings"), links[10]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl(true, "~/accounts/settings/unsubscribe", new ReadOnlyQueryString("userId", member.Id.ToString(), "category", "Campaign")), links[11]);

            links = email.GetPlainTextView().GetPlainTextLinks();
            Assert.AreEqual(9, links.Count);

            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl("~/search/jobs"), links[0]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl(true, "~/login"), links[1]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/profile"), links[2]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/profile"), links[3]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl("~/members/resources"), links[4]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/profile"), links[5]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/profile"), links[6]);
            AssertActivationLink(member, true, definition, new ReadOnlyApplicationUrl(true, "~/members/settings"), links[7]);
            AssertActivationLink(member, false, definition, new ReadOnlyApplicationUrl(true, "~/accounts/settings/unsubscribe", new ReadOnlyQueryString("userId", member.Id.ToString(), "category", "Campaign")), links[8]);
        }
Пример #2
0
        public void TestIosLaunchNewsletterEmailLinks()
        {
            var category = _settingsQuery.GetCategory("Campaign");
            var employer = _employerAccountsCommand.CreateTestEmployer(EmployerUserId, _organisationsCommand.CreateTestVerifiedOrganisation(0));

            // Send the email.

            AssertSettings(employer, category, Frequency.Immediately);

            var campaign = CreateCampaign();

            _campaignEmailsCommand.Send(new[] { _campaignEmailsCommand.CreateEmail(campaign, employer) }, campaign.Id, false);

            var email = _emailServer.AssertEmailSent();

            AssertUnsubscribeLink(employer, category, email.GetHtmlView().GetLinks()[4]);
        }
Пример #3
0
        protected void Send(Campaign campaign, IEnumerable <RegisteredUser> users, int?runs, int?batch, int?wait)
        {
            const string method = "Send";

            try
            {
                var totalCount = users.Count();
                var totalSent  = 0;
                _eventSource.Raise(Event.Flow, method, string.Format("Sending emails to {0} users for the '{1}' campaign.", totalCount, campaign.Name));

                var run     = 0;
                var runSent = 0;

                foreach (var user in users)
                {
                    var email = _campaignEmailsCommand.CreateEmail(campaign, user);
                    var sent  = _campaignEmailsCommand.Send(new[] { email }, campaign.Id, false);
                    runSent   += sent;
                    totalSent += sent;

                    if (batch != null && runSent == batch.Value)
                    {
                        // Finished the run.

                        runSent = 0;
                        ++run;
                        if (runs != null && run == runs.Value)
                        {
                            break;
                        }

                        if (wait != null)
                        {
                            Thread.Sleep(wait.Value * 1000);
                        }
                    }
                }

                _eventSource.Raise(Event.Flow, method, string.Format("{0} emails have been sent for the '{1}' campaign.", totalSent, campaign.Name));
            }
            catch (Exception ex)
            {
                _eventSource.Raise(Event.Error, method, string.Format("Failed to run the entire '{0}' campaign.", campaign.Name), ex, new StandardErrorHandler());
            }
        }
Пример #4
0
        private void SendToLoginIds(Guid id, Campaign campaign, string loginIds)
        {
            var emails = campaign.Category == CampaignCategory.Employer ? GetEmployerEmails(campaign, loginIds) : GetMemberEmails(campaign, loginIds);

            _campaignEmailsCommand.Send(emails, id, true);
        }