コード例 #1
0
        public List<string> SetUnsubscribeDataAddress(FormEmail email, FormAddress address, string sourceCode)
        {
            AuditTrail auditTrail = new AuditTrail();
            List<string> errors = null;
            HCPIndividual hcp;
            QuestionResponseSet questionResponseSet;

            try
            {
                errors = ValidateAddress(address);
                errors.AddRange(ValidateEmail(email));
                if (errors.Count > 0)
                {
                    auditTrail.SetAuditTrail(email.Email, AuditTrail.OperationType.Unsubscribtion_error, "SetUnsubscribeDataAddress", errors.ToString());
                    return errors;
                }
                if (Services.ServiceIsAvailable)
                {
                    EmailAddress emailAddress = new EmailAddress(email.Email);
                    Address Address = new Address(address.Address1, address.Address2, address.City, address.State, address.Zip, "", "");

                    hcp = new HCPIndividual();
                    hcp.FirstName = address.FName;
                    hcp.LastName = address.LName;
                    hcp.MiddleName = address.MName;
                    hcp.Addresses = new List<Address>();
                    hcp.Addresses.Add(Address);
                    hcp.EmailAddresses = new List<EmailAddress>();
                    hcp.EmailAddresses.Add(emailAddress);

                    RegistrationManager regMgr = new RegistrationManager();
                    regMgr.Individual = hcp;

                    string sourceMCC = string.Empty;
                    if (!string.IsNullOrWhiteSpace(sourceCode) && !string.Equals(sourceCode, "0"))
                    {
                        sourceMCC = sourceCode;
                    }
                    else
                    {
                        sourceMCC = Convert.ToString(ConfigurationManager.AppSettings["MCCUnsubscribe"]);
                    }

                    List<QuestionResponse> questionResponses = new List<QuestionResponse>();
                    QuestionResponse questionResponse = new QuestionResponse(Int32.Parse(ConfigurationManager.AppSettings["RTIDExitMCC"]), Int32.Parse(ConfigurationManager.AppSettings["RTIDAnsOpen"]), ConfigurationManager.AppSettings["MCCUnsubscribe"]);
                    questionResponses.Add(questionResponse);

                    questionResponse = new QuestionResponse(Int32.Parse(ConfigurationManager.AppSettings["RTIDOptOutBEDDirectMail"]), Int32.Parse(ConfigurationManager.AppSettings["RTIDAnsYes"]));
                    questionResponses.Add(questionResponse);

                    questionResponse = new QuestionResponse(Int32.Parse(ConfigurationManager.AppSettings["RTIDSourceMCC"]), Int32.Parse(ConfigurationManager.AppSettings["RTIDAnsOpen"]), sourceMCC);
                    questionResponses.Add(questionResponse);

                    questionResponseSet = new QuestionResponseSet();
                    // questionResponseSet.QuestionSetID = long.MaxValue;
                    questionResponseSet.QuestionResponses = questionResponses;

                    regMgr.PerformLiteRegistration(hcp, questionResponseSet);
                    errors = GetRegMgrErrors(regMgr, errors);
                    auditTrail.SetAuditTrail(email.Email, AuditTrail.OperationType.Unsubscribtion_success, "SetUnsubscribeDataAddress", regMgr.Status.ToUpper());
                    if (errors.Count > 0)
                        auditTrail.SetAuditTrail(email.Email, AuditTrail.OperationType.Unsubscribtion_error, "SetUnsubscribeDataAddress", errors.ToString());
                }
                else
                {
                    errors.Add("The PMM services are unavailable");
                }
            }
            catch (Exception e)
            {
                auditTrail.SetAuditTrail(" ", AuditTrail.OperationType.Unsubscribtion_Failure, e.Source, e.Message);
                throw e;
            }
            finally
            {
                log.Info(auditTrail.GetAuditTrail());
                auditTrail = null;
            }

            return errors;
        }
コード例 #2
0
        private List<string> ValidateAddress(FormAddress address)
        {
            List<string> errors = new List<string>();
            ValueExists("FirstName", address.FName, errors);
            ValueExists("LastName", address.LName, errors);
            ValueExists("Address1", address.Address1, errors);
            ValueExists("City", address.City, errors);
            ValueExists("State", address.State, errors);

            ValueExists("Zip", address.Zip, errors);
            IsPatternValid("Zip", address.Zip, new Regex(@"^\d{5}"), errors);
            return errors;
        }