Exemplo n.º 1
0
 public static PrivacyResponseDto TestAddPrivacyResponseDto(QuestionnaireDto _currentQuestionnaire)
 {
     long responseKey = FormRegistry.ResponseDao.CreateSubmitResponse(Constants.UnknownCustomer, null, _currentQuestionnaire.QuestionnaireId, ViewType.CleanSheetOverlay).First;
     Assert.Greater(responseKey, 0);
     PrivacyResponseDto dto = new PrivacyResponseDto(responseKey, true, true, true, EmailPreferences.Html, true);
     Assert.IsTrue(FormRegistry.ResponseDao.Add(dto));
     return dto;
 }
Exemplo n.º 2
0
 public void Setup()
 {
     CreateNewQuestionnaire();
     CreateNewFormPage();
     long responseKey = FormRegistry.ResponseDao.CreateSubmitResponse(Constants.UnknownCustomer, null, _currentQuestionnaire.QuestionnaireId, ViewType.CleanSheetOverlay).First;            
     PersonalResponseDto dto = new PersonalResponseDto(responseKey, "address1", "address2", "address3", "bus", "businessSiebel63", "company name", "UK", "county", Constants.UnknownCustomer, "email", "firstname", "flex1", "flex10", "flex11", "flex12", "flex13", "flex14", "flex15", "flex2", "flex3", "flex4", "flex5", "flex6", "flex7", "flex8", "flex9", "job", "jobsiebel", "jobtitle", "lastname", "persontit", "postcode", "pwd", "telephone", "telephone2", "telephone3", "telephone4", "fax", "fax2", "fax3", "fax4", "mobile", "mobile2", "town", "wor", "world6", "United Kingdom", null, "prefLang", "companyWebsite", "companyRevenue");
     FormRegistry.ResponseDao.Add(dto);
     SpecificCrmResponseDto dto2 = new SpecificCrmResponseDto(responseKey, false, true, SpecificCrmResponseDto.ElementTypeRequestOptInOut, _currentPage.PageId, null, _currentPage.QuestionnaireId, "respdesc");
     FormRegistry.ResponseDao.Add(dto2);
     dto3 = new PrivacyResponseDto(responseKey, true, true, true, EmailPreferences.Html, true);
     FormRegistry.ResponseDao.Add(dto3);
     PrivacyDataSectionDto dto4 = new PrivacyDataSectionDto("privacy header", true, _currentPage.PageId, true,
         "privacy text", "email", "email pref", "email pref html", "email pref text", "post", "phone",
         "general opt out", "yeys", "no", "crm offer code", true);
     PrivacyDataSectionDto pers = FormRegistry.PrivacyDao.Create(dto4);
     PageElementType type = PageElementType.RequestedMoreInfo;
     PageElementReqDto dto5 = new PageElementReqDto("element text", true, type, _currentPage.PageId, 0, Migration.GetMaxLength(type), true);
     PageElementReqDto pers2 = FormRegistry.PageElementDao.Create(dto5);
 }
Exemplo n.º 3
0
 private void Write(DbCommand sp, PrivacyResponseDto dto)
 {
     _dbLayer.AddInParameter(sp, "@response_id", DbType.Int64, dto.ResponseKey);
     _dbLayer.AddInParameter(sp, "@contact_by_email", DbType.Boolean, dto.ContactByEmail);
     switch (dto.EmailPreferences)
     {
         case EmailPreferences.Html:
             _dbLayer.AddInParameter(sp, "@email_pref", DbType.String, "html");
             break;
         case EmailPreferences.Text:
             _dbLayer.AddInParameter(sp, "@email_pref", DbType.String, "text");
             break;
         //default: null
     }
     
     _dbLayer.AddInParameter(sp, "@contact_by_post", DbType.Boolean, dto.ContactByPost);
     _dbLayer.AddInParameter(sp, "@contact_by_phone", DbType.Boolean, dto.ContactByPhone);
     _dbLayer.AddInParameter(sp, "@mailstop_flag", DbType.Boolean, dto.MailStop);
 }
Exemplo n.º 4
0
        public bool Add(PrivacyResponseDto dto)
        {
            bool retval = false;
            DbCommand sp = null;
            DbConnection connection = null;
            IDataReader reader = null;
            try
            {
                connection = _dbLayer.GetConnection();
                sp = connection.CreateCommand();

                sp.CommandText = "insert_response_privacy";
                sp.CommandType = CommandType.StoredProcedure;
                _dbLayer.AddInParameter(sp, "@flag", DbType.String, PrivacyResponseCommand);
                Write(sp, dto);
                sp.ExecuteNonQuery();
                retval = true;
            }
            catch (DbException e)
            {
                Trace.WriteLine("ResponseDao.Add(" + dto + "): " + e.Message);
            }
            finally
            {
                if (reader != null && !reader.IsClosed)
                {
                    reader.Close();
                }

                if (sp != null)
                {
                    sp.Dispose();
                }

                if (connection != null)
                {
                    _dbLayer.ReturnConnection(connection);
                }
                else
                {
                    _dbLayer.ReturnConnection(connection, true);
                }

            }

            return retval;
        }
Exemplo n.º 5
0
        private void ReadPrivacy(IDataReader reader, PrivacyResponseDto privacy, int privacyOffset)
        {
            long? key = GetInt64(reader, privacyOffset + (int)fields_privacy_response.response_FK);
            privacy.ResponseKey = (key.HasValue) ? key.Value : 0;

            string temp;

            temp = GetString(reader, privacyOffset + (int)fields_privacy_response.contact_by_email);
            privacy.ContactByEmail = ConvertToBool(temp);
            
            temp = GetString(reader, privacyOffset + (int)fields_privacy_response.email_pref);
            privacy.EmailPreferences = ConvertToEmailPreferences(temp);

            temp = GetString(reader, privacyOffset + (int)fields_privacy_response.contact_by_post);
            privacy.ContactByPost = ConvertToBool(temp);

            temp = GetString(reader, privacyOffset + (int)fields_privacy_response.contact_by_phone);
            privacy.ContactByPhone = ConvertToBool(temp);

            temp = GetString(reader, privacyOffset + (int)fields_privacy_response.mailstop_flag);
            privacy.MailStop = ConvertToBool(temp);
        }
Exemplo n.º 6
0
        private void ReadPrivacy(IDataReader reader, PersonalResponseDto personal, int privacyOffset)
        {
            PrivacyResponseDto privacy = new PrivacyResponseDto();
            ReadPrivacy(reader, privacy, privacyOffset);

            personal.EmailPreferences = privacy.EmailPreferences;
        }
Exemplo n.º 7
0
 public void TestAddPrivacyResponseDto()
 {
     TestData.TestAddPrivacyResponseDto(_currentQuestionnaire);
     
     //test with emailPreferences = null
     long responseKey = FormRegistry.ResponseDao.CreateSubmitResponse(Constants.UnknownCustomer, null, _currentQuestionnaire.QuestionnaireId, ViewType.CleanSheetOverlay).First;
     Assert.Greater(responseKey, 0);
     PrivacyResponseDto dto = new PrivacyResponseDto(responseKey, true, true, true, null, true);
     Assert.IsTrue(FormRegistry.ResponseDao.Add(dto));                        
 }
Exemplo n.º 8
0
        public void SubmitPrivacySectionData()
        {
            PrivacyResponseDto PrivacySection = null;
            //20120524 | Tirumala Raju | RFG 2.7 | QC:5995 |Start
            //Submission via Webservice causes wrong data in RI file for privacy optins
            bool? IsEmailOption = null;
            bool? IsPhoneOption = null;
            bool? IsPostOption = null;
            bool? IsOptOut = null;
            //End

            string EmailPreference = string.Empty;

            FormSubmissionPrivacySectionLabels ObjPrivacyLabels = new FormSubmissionPrivacySectionLabels();

            if (HashPrivacyFields != null)
            {
                if (HashPrivacyFields.Count > 0)
                {
                    foreach (DictionaryEntry Items in HashPrivacyFields)
                    {
                        if (Items.Key.ToString() == "aid_o_" + ObjPrivacyLabels.Privacy_Email)
                        {
                            string[] ArrayEmail = new string[1];
                            string Email = string.Empty;
                            if (Items.Value != null)
                            {
                                if (Items.Value.ToString().Trim() != string.Empty.ToString())
                                {
                                    ArrayEmail = Items.Value.ToString().Split(',');
                                    if (ArrayEmail[0] != null)
                                        Email = ArrayEmail[0];
                                }
                            }

                            //if (Email.ToLower() == "yes")
                            //    IsEmailOption = true;
                            IsEmailOption = Email.ToLower().Trim().Equals("email_yes") ? true : false;

                        }
                        if (Items.Key.ToString() == "aid_o_" + ObjPrivacyLabels.Privacy_Phone)
                        {

                            string[] ArrayPhone = new string[1];
                            string Phone = string.Empty;
                            if (Items.Value != null)
                            {
                                if (Items.Value.ToString().Trim() != string.Empty.ToString())
                                {
                                    ArrayPhone = Items.Value.ToString().Split(',');
                                    if (ArrayPhone[0] != null)
                                        Phone = ArrayPhone[0];
                                }
                            }

                            //if (Phone.ToLower() == "yes")
                            //    IsPhoneOption = true; ;
                            IsPhoneOption = Phone.ToLower().Trim().Equals("phone_yes") ? true : false;
                        }
                        if (Items.Key.ToString() == "aid_o_" + ObjPrivacyLabels.Privacy_Post)
                        {

                            string[] ArrayPost = new string[1];
                            string Post = string.Empty;
                            if (Items.Value != null)
                            {
                                if (Items.Value.ToString().Trim() != string.Empty.ToString())
                                {
                                    ArrayPost = Items.Value.ToString().Split(',');
                                    if (ArrayPost[0] != null)
                                        Post = ArrayPost[0];
                                }
                            }

                            //if (Post.ToLower() == "yes")
                            //    IsPostOption = true;
                            IsPostOption = Post.ToLower().Trim().Equals("post_yes") ? true : false;
                        }
                        if (Items.Key.ToString() == "aid_o_" + ObjPrivacyLabels.Privacy_OptOut)
                        {
                            //if (Items.Value.ToString() == "Yes")
                            //    IsOptOut = true;
                            IsOptOut = Items.Value.ToString().ToLower().Equals("yes") ? true : false;
                        }
                        if (Items.Key.ToString() == "aid_o_" + ObjPrivacyLabels.Privacy_Email_Pref)
                        {

                            string[] ArrayEmailPref = new string[1];
                            string EmailPref = string.Empty;
                            if (Items.Value != null)
                            {
                                if (Items.Value.ToString().Trim() != string.Empty.ToString())
                                {
                                    ArrayEmailPref = Items.Value.ToString().Split(',');
                                    if (ArrayEmailPref[1] != null)
                                        EmailPref = ArrayEmailPref[1];
                                }
                            }

                            EmailPreference = EmailPref;
                        }
                    }
                }
            }

            if (String.IsNullOrEmpty(EmailPreference.Trim()))
            {
                EmailPreference = EmailPreferences.Html.ToString();
            }
            else if (EmailPreference == "html")
            {
                EmailPreference = EmailPreferences.Html.ToString();
            }
            else if (EmailPreference == "text")
            {
                EmailPreference = EmailPreferences.Text.ToString();
            }

            PrivacySection = new PrivacyResponseDto(Convert.ToInt64(ResponseID), IsEmailOption, IsPhoneOption, IsPostOption, (EmailPreferences)Enum.Parse(typeof(EmailPreferences), EmailPreference), IsOptOut);
            FormRegistry.ResponseDao.Add(PrivacySection);
            responses.Add(PrivacySection);

        }
        public override List<ResponseDto> GetResponseDto(long responseId)
        {
            HP.Rfg.Web.Pages.RfgExternalPage page = Page as HP.Rfg.Web.Pages.RfgExternalPage;
            if (page == null)
            {
                throw new BugException(GetType().Name + " is only supported within RFG pages");
            }

            bool? contactByEmail = null;
            bool? contactByPhone = null;
            bool? contactByPost = null;
            EmailPreferences? emailPrefs = null;
            bool? mailStop = null;

            if (!String.IsNullOrEmpty(_element.Email))
            {
                if (Ux_EmailOptIn.Checked)
                {
                    contactByEmail = true;
                }
                else
                {
                    if (Ux_EmailOptOut.Checked)
                    {
                        contactByEmail = false;
                    }
                }
            }

            if (!String.IsNullOrEmpty(_element.Phone))
            {
                if (Ux_PhoneOptIn.Checked)
                {
                    contactByPhone = true;
                }
                else
                {
                    if (Ux_PhoneOptOut.Checked)
                    {
                        contactByPhone = false;
                    }
                }
            }

            if (!String.IsNullOrEmpty(_element.Post))
            {
                if (Ux_PostOptIn.Checked)
                {
                    contactByPost = true;
                }
                else
                {
                    if (Ux_PostOptOut.Checked)
                    {
                        contactByPost = false;
                    }
                }
            }

            if (!String.IsNullOrEmpty(_element.EmailPreferences))
            {
                if (Ux_EmailPrefHtml.Checked)
                {
                    emailPrefs = EmailPreferences.Html;
                }
                else
                {
                    if (Ux_EmailPrefText.Checked)
                    {
                        emailPrefs = EmailPreferences.Text;
                    }
                }
            }

            if (!String.IsNullOrEmpty(_element.GeneralOptOut))
            {
                if (Ux_GeneralOptOut.Checked)
                {
                    mailStop = true;
                }
                else
                {
                    mailStop = false;
                }
            }

            PrivacyResponseDto response = new PrivacyResponseDto(responseId, contactByEmail, contactByPhone, contactByPost, emailPrefs, mailStop);
            List<ResponseDto> retval = new List<ResponseDto>();
            retval.Add(response);

            if (retval.Count > 0)
            {
                bool cidSubmit = true;
                bool crmSubmit = page.PageAssembly.Questionnaire.SendToCrm;
                string elementType = SpecificCrmResponseDto.ElementTypeRequestOptInOut;
                int pageId = page.PageAssembly.Page.PageId;
                //no questionId/ElementId is allowed for privacysection as insert_crm_record would fail then
                int? questionId = null;
                int questionnaireId = page.PageAssembly.Questionnaire.QuestionnaireId;
                //string respDesc = "Response to RFG web form - " + Page.Request.Url;
                string respDesc = "Response to RFG web form - qid " + questionnaireId;
                SpecificCrmResponseDto privacy = new SpecificCrmResponseDto(responseId, cidSubmit, crmSubmit, elementType, pageId, questionId, questionnaireId, respDesc);
                retval.Add(privacy);
            }

            return retval;
        }