コード例 #1
0
        private IEnumerable <IIMapServerSettings> LoadSmtpSettings()
        {
            var smtpRepostory = _dataRepositoryFactory.Create <ISmtpDetailRepository>();

            var settings = smtpRepostory.GetImapSettings(m => new ImapServerSettings
            {
                ImapServer         = m.Host,
                IsSecureSocket     = m.UseSSL == 1,
                Port               = m.Port,
                UserLogin          = m.Username,
                UserPassword       = m.Password,
                RequestingEntityId = m.SmtpDetailId
            });

            return(settings);
        }
コード例 #2
0
        private void Send(Email email)
        {
            if (String.IsNullOrEmpty(email.From))
            {
                throw new EmailFormatException("From field cannot be blank");
            }

            if (email.Recipients.Count <= 0)
            {
                throw new EmailFormatException("A minimum of one recipient is required");
            }

            if (String.IsNullOrEmpty(email.Body))
            {
                throw new EmailFormatException("The body of the mail cannot be blank");
            }

            foreach (var attachment in email.Attachments)
            {
                if (!File.Exists(attachment.FilePath))
                {
                    throw new EmailFormatException("The attached file at " + attachment.FilePath + " does not exist");
                }
            }

            _dataRepositoryFactory.Create <IOutboundEmailRepository>().Save((OutboundEmail)email);
        }
コード例 #3
0
ファイル: EmailSender.cs プロジェクト: karagulamos/ATS
        public void Execute()
        {
            var emails = _dataRepositoryFactory.Create <IOutboundEmailRepository>().GetOutboundEmailDetails();

            var emailCount = emails.Count;

            if (emailCount > 0)
            {
                foreach (var email in emails)
                {
                    var smptClient = _emailConfigurator.ConfigureSmtpClient(email);
                    var sendStatus = SendEmail(email, smptClient);
                    UpdateEmail(email, sendStatus);
                }
                ;
            }
        }
コード例 #4
0
        public void Execute()
        {
            int batchCount = Convert.ToInt32(ConfigurationManager.AppSettings["UnprocessedEmailBatchCount"]);
            var emails     = _dataRepositoryFactory.Create <IInboundEmailRepository>()
                             .GetUnprocessedInboundEmails(batchCount);

            foreach (var email in emails)
            {
                foreach (var attachment in email.InboundAttachments.TryGetValidCvsOrDefault(email.SenderName))
                {
                    var documentExtractor = _documentExtractorFactory.GetExtractor(attachment.FileType);
                    var parsedRows        = documentExtractor.GetRows(attachment.FilePath, ResumeFilterHelper.GetStopWords(), ResumeFilterHelper.GetSkipWords());

                    if (parsedRows.Count <= 0)
                    {
                        continue;
                    }

                    var candidate = _candidateBuilder.BuildFrom(parsedRows);

                    if (candidate.IsValidCandidate())
                    {
                        ValidateSenderDetails(candidate, parsedRows, email.SenderName, email.Sender);

                        candidate.InboundEmailId      = email.InboundEmailId;
                        candidate.InboundAttachmentId = attachment.InboundAttachmentId;

                        _dataRepositoryFactory.Create <ICandidateRepository>().Save(candidate);

                        var incompleteCandidateDetails = candidate.GetIncompleteCandidateDetails();

                        if (incompleteCandidateDetails.Count > 0)
                        {
                            SendIncompleteDetailsNotification(candidate, incompleteCandidateDetails);
                        }
                    }
                }

                email.Processed = 1;
                _dataRepositoryFactory.Create <IInboundEmailRepository>()
                .DetachAndUpdate(email.InboundEmailId, email);
            }
        }