Ejemplo n.º 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;
        }
Ejemplo n.º 2
0
        public List<string> SetOptInData(OptIn optIn, string sourceCode)
        {
            log4net.Config.XmlConfigurator.Configure();

            AuditTrail auditTrail = new AuditTrail();
            List<string> errors = null;
            HCPIndividual hcp;
            QuestionResponseSet questionResponseSet;
            RegistrationManager regMgr;
            EmailManager emailMgr;

            try
            {
                errors = Validate(optIn);

                if (errors.Count > 0)
                    return errors;

                if (Services.ServiceIsAvailable)
                {

                    EmailAddress emailAddress = new EmailAddress(optIn.Email.Email);
                    hcp = new HCPIndividual(String.Empty, optIn.Name.FName, optIn.Name.LName, String.Empty, emailAddress);

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

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

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

                    Configuration config = WebConfigurationManager.OpenWebConfiguration(System.Web.HttpContext.Current.Request.ApplicationPath+"/Unsubscribe/");
                    KeyValueConfigurationElement Appsetting = config.AppSettings.Settings["RTWebSiteID"];

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

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

                    questionResponseSet = new QuestionResponseSet();
                    questionResponseSet.QuestionResponses = questionResponses;

                    regMgr.PerformLiteRegistration(hcp, questionResponseSet);
                    if(String.Equals(regMgr.Status, "OK")) {
                        emailMgr = new EmailManager();
                        emailMgr.SendEmail(Int32.Parse(ConfigurationManager.AppSettings["RTWelcomEmailMAID"]), emailAddress.EmailAddressString);
                    }

                    errors = GetRegMgrErrors(regMgr, errors);

                    auditTrail.SetAuditTrail(optIn.Email.Email, AuditTrail.OperationType.OptIn_Success, "SetOptInData", regMgr.Status.ToUpper());
                    if (errors.Count > 0)
                        auditTrail.SetAuditTrail(optIn.Email.Email, AuditTrail.OperationType.OptIn_errors, "SetOptInData", errors.ToString());
                }
                else
                {
                    errors.Add("The PMM services are unavailable");
                }

            }
            catch (Exception e)
            {
                auditTrail.SetAuditTrail(" ", AuditTrail.OperationType.OptIn_Failure, e.Source, e.Message);
                throw e;
            }
            finally
            {
                hcp = null;
                questionResponseSet = null;
                regMgr = null;
                log.Info(auditTrail.GetAuditTrail());
                auditTrail = null;

            }

            return errors;
        }