private string ProcessMessage(OpenPop.Mime.Message msg)
        {
            if (msg.Headers.ContentType.MediaType != "text/plain")
            {
                _logger.LogMessage("Skipped message with unexpected media type. Subject: " + msg.Headers.Subject);
                return("Skipped");
            }

            string        bodyText = msg.MessagePart.BodyEncoding.GetString(msg.MessagePart.Body);
            List <String> lines    = bodyText.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries).ToList();

            lines.RemoveAt(lines.IndexOf("Please see the intake referral from the website:"));
            int endIndex = lines.IndexOf("--");

            lines.RemoveRange(endIndex, lines.Count - endIndex);

            var referralInfo = new Dictionary <string, string>();

            foreach (string line in lines)
            {
                string[] items = line.Split(new string[] { ": " }, 2, StringSplitOptions.None);
                referralInfo.Add(items[0], items[1]);
            }


            var tmpContext = new AABC.Data.Models.CoreEntityModel();

            tmpContext.Referrals.Add(new Data.Models.Referral()
            {
                DateCreated                   = System.DateTime.Now,
                ReferralFirstName             = GetReferralInfo("Childs First Name", referralInfo),
                ReferralLastName              = GetReferralInfo("Childs Last Name", referralInfo),
                ReferralDateOfBirth           = GetDateOfBirth(GetReferralInfo("Date of Birth", referralInfo)),
                ReferralGender                = GetGender(GetReferralInfo("Gender", referralInfo)),
                ReferralPrimarySpokenLangauge = GetReferralInfo("Language", referralInfo),
                ReferralGuardianFirstName     = GetReferralInfo("Parent First Name", referralInfo),
                ReferralGuardianLastName      = GetReferralInfo("Parent Last Name", referralInfo),
                ReferralGuardianRelationship  = GetReferralInfo("Relationship to Child", referralInfo),
                ReferralAddress1              = GetReferralInfo("Address", referralInfo),
                ReferralAddress2              = GetReferralInfo("address", referralInfo),
                ReferralCity                  = GetReferralInfo("City", referralInfo),
                ReferralState                 = GetReferralInfo("State", referralInfo),
                ReferralZip                   = GetReferralInfo("Zip", referralInfo),
                ReferralPhone                 = GetReferralInfo("Phone", referralInfo),
                ReferralAreaOfConcern         = GetReferralInfo("Area of Concern", referralInfo),
                ReferralSourceName            = GetReferralInfo("Referred By", referralInfo),
                ReferralServicesRequested     = GetReferralInfo("Services interested in", referralInfo),
                ReferralInsuranceCompanyName  = GetReferralInfo("Insurance Name", referralInfo),
                ReferralInsuranceMemberID     = GetReferralInfo("Member ID", referralInfo),
                ReferralInsurancePrimaryCardholderDateOfBirth = GetInsuranceDOB(GetReferralInfo("Insurance primary holder and DOB", referralInfo)),
                ReferralInsuranceCompanyProviderPhone         = GetReferralInfo("Insurance Company Phone # for Providers to call", referralInfo)
            });

            tmpContext.SaveChanges();
            _logger.LogMessage("Created referral for message. Subject: " + msg.Headers.Subject);
            return("Processed");
        }
Beispiel #2
0
        static void testEmailSmtp()
        {
            AABC.Data.Models.CoreEntityModel _context;
            AABC.Domain.Email.SMTPAccount    _smtpAccount;
            string _errorEmail;


            _context    = new AABC.Data.Models.CoreEntityModel();
            _errorEmail = ConfigurationManager.AppSettings["ErrorEmail"];

            var smtpInfo = _context.SMTPAccounts.Where(x => x.AccountName == "Primary").SingleOrDefault();

            if (smtpInfo == null)
            {
                Console.WriteLine("FAIL: (smtp) Unable to load Primary smtp account");
                return;
            }

            _smtpAccount = new AABC.Domain.Email.SMTPAccount()
            {
                Username           = smtpInfo.AccountUsername,
                Password           = smtpInfo.AccountPassword,
                Server             = smtpInfo.AccountServer,
                Port               = smtpInfo.AccountPort.Value,
                UseSSL             = smtpInfo.AccountUseSSL.Value,
                AuthenticationMode = smtpInfo.AccountAuthMode.Value,
                FromAddress        = smtpInfo.AccountDefaultFromAddress,
                ReplyToAddress     = smtpInfo.AccountDefaultReplyAddress
            };

            try {
                AABC.DomainServices.Email.SMTP.Send(
                    _smtpAccount,
                    "Test Message", "This is a test message from auto referrals entry - please disregard.",
                    _errorEmail);
            } catch (Exception e) {
                Console.WriteLine("FAIL: (smtp)");
                Console.WriteLine(e.ToString());
                return;
            }

            Console.WriteLine("SUCCESS (smtp)");
        }
        public ReferralsFromEmail()
        {
            _context = new AABC.Data.Models.CoreEntityModel();
            _logger  = new Logger();

            _popServer = ConfigurationManager.AppSettings["PopServer"];
            _popPort   = int.Parse(ConfigurationManager.AppSettings["PopPort"]);
            _popSSL    = bool.Parse(ConfigurationManager.AppSettings["PopSSL"]);

            _popUser     = ConfigurationManager.AppSettings["PopUser"];
            _popPassword = ConfigurationManager.AppSettings["PopPassword"];

            _seedMode = bool.Parse(ConfigurationManager.AppSettings["SeedMode"]);

            var smtpInfo = _context.SMTPAccounts.Where(x => x.AccountName == "Primary").SingleOrDefault();

            if (smtpInfo == null)
            {
                throw new ArgumentNullException("Primary SMTP Account info has not been configured.");
            }

            _smtpAccount = new AABC.Domain.Email.SMTPAccount()
            {
                Username           = smtpInfo.AccountUsername,
                Password           = smtpInfo.AccountPassword,
                Server             = smtpInfo.AccountServer,
                Port               = smtpInfo.AccountPort.Value,
                UseSSL             = smtpInfo.AccountUseSSL.Value,
                AuthenticationMode = smtpInfo.AccountAuthMode.Value,
                FromAddress        = smtpInfo.AccountDefaultFromAddress,
                ReplyToAddress     = smtpInfo.AccountDefaultReplyAddress
            };

            _validationEmail = ConfigurationManager.AppSettings["ValidationEmail"];
            _errorEmail      = ConfigurationManager.AppSettings["ErrorEmail"];
        }
 public HoursMultiNotes()
 {
     this.context = new Data.Models.CoreEntityModel();
 }