Exemple #1
0
        string ISendJobG8Command.SendApplication(ICommunicationUser user, JobAdEntry jobAd, string resumeFileName, FileContents resumeContents, InternalApplication application, IEnumerable <ApplicationAnswer> answers)
        {
            var request = new UploadRequestMessage
            {
                Body = new UploadRequestBody
                {
                    ApplicationXml = Serialize(CreateApplicationResponse(user, jobAd, resumeFileName, resumeContents, application, answers))
                }
            };

            string result;
            var    service = _serviceManager.Create();

            try
            {
                var response = service.Send(request);
                result = response.Body.Result;
            }
            catch (Exception)
            {
                _serviceManager.Abort(service);
                throw;
            }
            _serviceManager.Close(service);

            return(result);
        }
Exemple #2
0
 private static void AssertEmail(MockEmail email, ICommunicationUser employer, int newCandidates)
 {
     email.AssertAddresses(Return, Return, employer);
     email.AssertSubject(GetSubject(newCandidates));
     email.AssertHtmlViewContains(employer.FirstName);
     email.AssertHtmlViewContains(GetBodySnippet(newCandidates));
 }
 public ContactCandidateEmail(ICommunicationUser member, string employerEmailAddress, IEmployer employer, string subject, string content)
     : base(member, GetEmployer(employer, employerEmailAddress))
 {
     _subject      = subject;
     _content      = content;
     _organisation = employer.Organisation;
 }
Exemple #4
0
        bool IUserEmailsQuery.ShouldSend(ICommunicationUser to, Definition definition, Category category, bool requiresActivation, bool ignoreChecks, DateTime?notIfLastSentLaterThanThis)
        {
            const string method = "ShouldSend";

            // If the user is disabled then they shouldn't get any email.

            if (!to.IsEnabled)
            {
                EventSource.Raise(Event.Warning, method, "Tried to send an email to a disabled user.", Event.Arg("Id", to.Id), Event.Arg("Definition", definition == null ? string.Empty : definition.Name));
                return(false);
            }

            // If the email requires activation and the user is not activated then don't send.

            if (requiresActivation && (!to.IsActivated || !to.IsEmailAddressVerified))
            {
                EventSource.Raise(Event.Warning, method, "Tried to send an email to a deactivated or unverified user.", Event.Arg("Id", to.Id), Event.Arg("Definition", definition == null ? string.Empty : definition.Name));
                return(false);
            }

            // Determine whether in fact this communication should be sent.

            if (!ignoreChecks)
            {
                // Check the users settings.

                var settings = GetEffectiveSettings(to, definition, category);
                if (!ShouldSend(settings, notIfLastSentLaterThanThis))
                {
                    return(false);
                }
            }

            return(true);
        }
Exemple #5
0
        public static SuggestedJobsEmail Create(ICommunicationUser to, IEnumerable <JobAd> jobAds, int totalMatches)
        {
            var emailItems = CreateEmailItems(jobAds);
            var email      = new SuggestedJobsEmail(to, totalMatches, emailItems);

            return(email);
        }
Exemple #6
0
        public EmailsCommand(
            ISettingsQuery settingsQuery,
            ISettingsCommand settingsCommand,
            ICommunicationEngine communicationEngine,
            ITemplateEngine templateEngine,
            IAffiliateEmailsQuery affiliateEmailsQuery,
            IUserEmailsQuery userEmailsQuery,
            string memberServicesAddress,
            string employerServicesAddress,
            string systemAddress,
            string returnAddress,
            string servicesDisplayName,
            string allStaffAddress,
            string allStaffDisplayName,
            string redStarResumeAddress,
            string redStarResumeDisplayName)
        {
            _settingsQuery        = settingsQuery;
            _settingsCommand      = settingsCommand;
            _communicationEngine  = communicationEngine;
            _templateEngine       = templateEngine;
            _affiliateEmailsQuery = affiliateEmailsQuery;
            _userEmailsQuery      = userEmailsQuery;

            _memberServicesUser   = new EmailUser(memberServicesAddress, servicesDisplayName, null);
            _employerServicesUser = new EmailUser(employerServicesAddress, servicesDisplayName, null);
            _systemUser           = new EmailUser(systemAddress, servicesDisplayName, null);
            _allStaffUser         = new EmailUser(allStaffAddress, allStaffDisplayName, null);
            _redStarResume        = new EmailUser(redStarResumeAddress, redStarResumeDisplayName, null);
            _returnUser           = new EmailUser(returnAddress, servicesDisplayName, null);
        }
 public NewEmployerWelcomeEmail(ICommunicationUser to, string loginId, string password, int candidates)
     : base(to)
 {
     _loginId    = loginId;
     _password   = password;
     _candidates = candidates;
 }
Exemple #8
0
 public MemberMessageSentEmail(ICommunicationUser to, ICommunicationUser from, Guid threadId, Guid messageId, string messageSubject, string messageText)
     : base(to, from)
 {
     _threadId       = threadId;
     _messageId      = messageId;
     _messageSubject = messageSubject;
     _messageText    = messageText;
 }
Exemple #9
0
 public JobApplicationEmail(ICommunicationUser from, InternalApplication jobApplication, JobAd jobAd, Stream resumeContents, string resumeFileName)
     : base(GetUnregisteredEmployer(jobAd.ContactDetails.EmailAddress), from)
 {
     _jobApplication = jobApplication;
     _jobAd          = jobAd;
     _resumeContents = resumeContents;
     _resumeFileName = resumeFileName;
 }
 CampaignEmail ICampaignEmailsCommand.CreateEmail(Campaign campaign, ICommunicationUser to)
 {
     if (campaign.Category == CampaignCategory.Employer)
     {
         return(new EmployerCampaignEmail(campaign, GetCommunicationDefinition(campaign.CommunicationDefinitionId), GetCommunicationCategory(campaign.CommunicationCategoryId, UserType.Employer), to, _from));
     }
     return(new MemberCampaignEmail(campaign, GetCommunicationDefinition(campaign.CommunicationDefinitionId), GetCommunicationCategory(campaign.CommunicationCategoryId, UserType.Member), to, _from));
 }
Exemple #11
0
 public FriendInvitationEmail(ICommunicationUser to, ICommunicationUser from, FriendInvitation invitation, EmailVerification emailVerification, IList <Job> currentJobs, int contactCount)
     : base(to, from)
 {
     _invitation        = invitation;
     _emailVerification = emailVerification;
     _currentJobs       = currentJobs;
     _contactCount      = contactCount;
 }
 public CampaignEmailsCommand(ICampaignsQuery campaignsQuery, ISettingsQuery settingsQuery, ISettingsCommand settingsCommand, IEmailsCommand emailsCommand, string returnAddress, string returnDisplayName)
 {
     _campaignsQuery  = campaignsQuery;
     _settingsQuery   = settingsQuery;
     _settingsCommand = settingsCommand;
     _emailsCommand   = emailsCommand;
     _from            = new EmailUser(returnAddress, returnDisplayName, null);
 }
Exemple #13
0
 private static IEmployer GetEmployer(ICommunicationUser user)
 {
     if (user is IEmployer)
     {
         return((IEmployer)user);
     }
     return(null);
 }
Exemple #14
0
        protected string GetBody(TemplateEmail email, ICommunicationUser to, string content)
        {
            var sb = new StringBuilder();

            GetBodyStart(sb);
            sb.Append(content);
            GetBodyEnd(email, to, sb);
            return(sb.ToString());
        }
Exemple #15
0
 public OrderReceiptEmail(ICommunicationUser to, Order order, IEnumerable <Product> orderProducts, IEnumerable <Credit> orderPrimaryCredits, IEnumerable <ProductCreditAdjustment> orderPrimaryAdjustments, PurchaseReceipt receipt)
     : base(to)
 {
     _order       = order;
     _products    = orderProducts.ToArray();
     _credits     = orderPrimaryCredits.ToArray();
     _adjustments = orderPrimaryAdjustments.ToArray();
     _receipt     = receipt;
 }
Exemple #16
0
        private void SendEmailWithResumeFile(InternalApplication application, ICommunicationUser member, JobAd jobAd)
        {
            var fileReference = _filesQuery.GetFileReference(application.ResumeFileId.Value);
            var stream        = _filesQuery.OpenFile(fileReference);

            // Send the email.

            _emailsCommand.TrySend(new JobApplicationEmail(member, application, jobAd, stream, fileReference.FileName));
        }
 public ContactInvitationEmail(ICommunicationUser inviter, NetworkingInvitation invitation, DonationRequest donationRequest, DonationRecipient donationRecipient, IList <Job> currentJobs, int contactCount)
     : base(GetUnregisteredMember(invitation.InviteeEmailAddress), inviter)
 {
     _invitation        = invitation;
     _donationRequest   = donationRequest;
     _donationRecipient = donationRecipient;
     _currentJobs       = currentJobs;
     _contactCount      = contactCount;
 }
Exemple #18
0
        private void MultipleLoginsTest(CampaignCategory category)
        {
            var administrator = _administratorAccountsCommand.CreateTestAdministrator(1);
            var campaign      = CreateCampaign(1, category, administrator);

            const int count    = 2;
            var       users    = new ICommunicationUser[count];
            var       loginIds = new string[count];

            if (category == CampaignCategory.Employer)
            {
                for (var index = 0; index < count; ++index)
                {
                    var employer = _employerAccountsCommand.CreateTestEmployer(index, _organisationsCommand.CreateTestOrganisation(index));
                    users[index]    = employer;
                    loginIds[index] = employer.GetLoginId();
                }
            }
            else
            {
                for (var index = 0; index < count; ++index)
                {
                    var member = _memberAccountsCommand.CreateTestMember(index);
                    users[index]    = member;
                    loginIds[index] = member.GetLoginId();
                }
            }

            // Login as administrator.

            LogIn(administrator);

            // Navigate to page and set the template.

            Get(GetEditTemplateUrl(campaign.Id));
            _subjectTextBox.Text = Subject;
            _bodyTextArea.Text   = Body;
            _saveButton.Click();

            // Send.

            _loginIdsTextBox.Text = string.Join(",", loginIds);
            _sendButton.Click();

            // Check.

            var emails = _emailServer.AssertEmailsSent(users.Length);

            for (var index = 0; index < users.Length; ++index)
            {
                var email = emails[index];
                email.AssertAddresses(Return, Return, users[index]);
                email.AssertSubject(Subject);
                Assert.IsTrue(email.GetHtmlView().Body.Contains(Body));
            }
        }
Exemple #19
0
        protected EmployerClientEmail(ICommunicationUser to, ICommunicationUser accountManager)
            : base(to, GetFromUser(accountManager))
        {
            if (accountManager == null)
            {
                throw new ArgumentNullException("accountManager");
            }

            AccountManager = accountManager;
        }
Exemple #20
0
        private ICommunicationUser GetReturnUser(Guid?affiliateId)
        {
            ICommunicationUser user = null;

            if (affiliateId != null)
            {
                user = _affiliateEmailsQuery.GetReturnUser(affiliateId);
            }
            return(user ?? _returnUser);
        }
Exemple #21
0
        private ICommunicationUser GetEmployerServicesUser(Guid?affiliateId)
        {
            ICommunicationUser user = null;

            if (affiliateId != null)
            {
                user = _affiliateEmailsQuery.GetEmployerServicesUser(affiliateId);
            }
            return(user ?? _employerServicesUser);
        }
Exemple #22
0
        private ICommunicationUser GetServicesUser(ICommunicationUser from, Guid?affiliateId)
        {
            ICommunicationUser user = null;

            if (affiliateId != null)
            {
                user = _affiliateEmailsQuery.GetServicesUser(from, affiliateId);
            }
            return(user ?? (from.UserType == UserType.Employer ? _employerServicesUser : _memberServicesUser));
        }
Exemple #23
0
 protected CreditsEmail(ICommunicationUser to, ICommunicationUser accountManager)
     : base(to)
 {
     if (accountManager != null)
     {
         _blindCopy = new List <ICommunicationUser> {
             accountManager
         }
     }
     ;
 }
        private void SendResumeFile(InternalApplication application, ICommunicationUser member, JobAdEntry jobAd, IEnumerable <ApplicationAnswer> answers)
        {
            // Open the file and send it.

            var resumeFileReference = _filesQuery.GetFileReference(application.ResumeFileId.Value);

            using (var stream = _filesQuery.OpenFile(resumeFileReference))
            {
                _sendJobG8Command.SendApplication(member, jobAd, resumeFileReference.FileName, new StreamFileContents(stream), application, answers);
            }
        }
        private static EmployerReportEmail CreateEmail(ICommunicationUser to, ICommunicationUser accountManager, Report report, IOrganisation organisation, DateTime startDate, DateTime endDate, ReportRunOutcome outcome, string result, int memberCount)
        {
            if (report is CandidateCareReport)
            {
                return(new CandidateCareReportEmail(to, accountManager, report, organisation, startDate, endDate, result));
            }

            return(report is ResumeSearchActivityReport && outcome == ReportRunOutcome.NoResults
                ? new NoSearchActivityEmail(to, accountManager, report, organisation, startDate, endDate, memberCount)
                : new EmployerReportEmail(to, accountManager, report, organisation, startDate, endDate));
        }
Exemple #26
0
 private void CheckCandidates(ICommunicationUser employer, int expected)
 {
     new EmailEmployerUsageTask(_emailsCommand, _resumeReportsQuery, _accountReportsQuery, _employersQuery).ExecuteTask();
     if (expected > 0)
     {
         AssertEmail(_emailServer.AssertEmailSent(), employer, expected);
     }
     else
     {
         _emailServer.AssertNoEmailSent();
     }
 }
        public ResumeSearchAlertEmail(ICommunicationUser to, MemberSearchCriteria criteria, IList <Industry> criteriaIndustries, MemberSearchResults results, EmployerMemberViews views, Guid savedSearchId)
            : base(to)
        {
            if (results == null)
            {
                throw new ArgumentNullException("results");
            }

            _results       = results;
            _views         = views;
            _criteriaText  = GetCriteriaText(criteria, criteriaIndustries);
            _savedSearchId = savedSearchId;
        }
        protected void AssertCreditsEmail(ICommunicationUser accountManager, ICommunicationUser[] recipients, string subject, string contains)
        {
            var emails = _emailServer.AssertEmailsSent(recipients.Length);

            foreach (var recipient in recipients)
            {
                var emailAddress = recipient.EmailAddress;
                var email        = (from e in emails where e.To[0].Address == emailAddress select e).Single();
                email.AssertAddresses(Return, Return, recipient, null, accountManager);
                email.AssertSubject(subject);
                email.AssertHtmlViewContains(contains);
            }
        }
Exemple #29
0
        protected ICommunicationUser GetServicesRecipient(ICommunicationUser recipient, Guid?affiliateId)
        {
            switch (recipient.UserType)
            {
            case UserType.Employer:
                return(GetEmployerServicesUser(affiliateId));

            case UserType.Custodian:
                return(_systemUser);

            default:
                return(GetMemberServicesUser(affiliateId));
            }
        }
Exemple #30
0
        private void SendAlert(ICommunicationUser user, Guid savedJobSearchId, JobAdSearchExecution execution, JobAdSearchCriteria criteria, JobAdSearchCriteria originalCriteria)
        {
            if (execution == null || execution.Results == null || execution.Results.JobAdIds.Count == 0)
            {
                return;
            }

            var emailResults = CreateEmailResults(execution.Results, criteria, MaximumResults);

            if (emailResults.Count > 0)
            {
                _emailsCommand.TrySend(new JobSearchAlertEmail(user, execution.Results.JobAdIds.Count, emailResults, originalCriteria, savedJobSearchId));
            }
        }