예제 #1
0
 public void Initialize(OmnitureDto omniture, QuestionnaireDto quesitonnaire, PageDto page)
 {
     _omniture = omniture;
     _questionnaire = quesitonnaire;
     _page = page;
     Load += new EventHandler(WucMetaBase_Load);
 }
예제 #2
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;
 }
예제 #3
0
 public static ShippingAddressResponseDto TestAddShippingAddressResponseDto(QuestionnaireDto _currentQuestionnaire)
 {
     long responseKey = FormRegistry.ResponseDao.CreateSubmitResponse(Constants.UnknownCustomer, null, _currentQuestionnaire.QuestionnaireId, ViewType.CleanSheetOverlay).First;
     Assert.Greater(responseKey, 0);
     ShippingAddressResponseDto dto = new ShippingAddressResponseDto(responseKey, "address1", "address2", "address3", "UK", "county", Constants.UnknownCustomer, "emailaddress", "postcode", "town", false, "United Kingdom");
     Assert.IsTrue(FormRegistry.ResponseDao.Add(dto));
     return dto;
 }
예제 #4
0
 public static QuestionResponseDto TestAddQuestionResponseDto(QuestionnaireDto _currentQuestionnaire, PageElementChoiceDto pers)
 {
     long responseKey = FormRegistry.ResponseDao.CreateSubmitResponse(Constants.UnknownCustomer, null, _currentQuestionnaire.QuestionnaireId, ViewType.CleanSheetOverlay).First;
     Assert.Greater(responseKey, 0);
     QuestionResponseDto dto = new QuestionResponseDto(responseKey, pers.ChoiceId, "choiceText", null, "ckmfieldid_tirumala");
     Assert.IsTrue(FormRegistry.ResponseDao.Add(dto));
     return dto;
 }
예제 #5
0
        protected override bool RealValidate(IResponsePredefinedQuestionProvider elementToValidate, QuestionnaireDto questionnaire, ref Boolean isLengthCorrect, ref string incorrectLengthMsg)
        {
            bool hasElement = false;
            bool hasEmptyElements = false;
            List<ResponseDto> responses = elementToValidate.GetResponseDto(-1);
            List<int> validationHints = null;
            if (responses != null && responses.Count > 0)
            {
                foreach (ResponseDto response in responses)
                {
                    PredefinedQuestionResponseDto questionResponse = response as PredefinedQuestionResponseDto;

                    if (questionResponse != null)
                    {
                        hasElement = true;
                        if (String.IsNullOrEmpty(questionResponse.ChoiceText))
                        {
                            hasEmptyElements = true;
                            break;
                        }
                        else
                        {
                            if (questionResponse.ChoiceText.Length > 4000)
                            {
                                validationHints = new List<int>();
                                validationHints.Add(PageElementWithErrorDto.InvalidInputTooLong);
                            }
                        }
                    }
                    else
                    {
                        throw new UserCausedException(Constants.UserCausedDataFormatIncorrectElementMissmatch, "Choices validator does not accept a response of type \"" + response.GetType().Name + "\"");
                    }
                }
            }
            bool retval = false;

            if (validationHints == null)
            {
                if (elementToValidate.PageQuestion.Required)
                {
                    if (!hasEmptyElements && hasElement)
                    {
                        retval = true;
                    }
                }
                else
                {
                    retval = true;
                }
            }
            else
            {
                elementToValidate.SetValidationHints(validationHints);
            }
            elementToValidate.IsValid = retval;
            return retval;
        }
예제 #6
0
 public void Test1()
 {
     _messageId = Constants.UserCausedDataFormatIncorrectElementNull;
     ChoicesValidator validator = new ChoicesValidator(PageElementType.BandedHeader);
     TestResponseElementProvider element = new TestResponseElementProvider();
     element.TestPageElementType = PageElementType.BandedHeader;
     PageElementChoiceDto choiceElement = new PageElementChoiceDto(1, "choice label", 2, 3, 4, false, null, "lov", PageElementChoiceDto.EmptyKeys);
     QuestionnaireDto questionnaire = new QuestionnaireDto();
     Assert.IsTrue(validator.Validate(element, questionnaire));
 }
예제 #7
0
 public void CreateNewQuestionnairePage()
 {
     _validCampaign = CreateNewCampaign();
     _validQuestionnaire = CreateNewQuestionnaire();
     _validPage = CreateNewFormPage();
     CreateNewPage(PageType.ClosurePage);
     _inValidQuestionnaire = CreateNewQuestionnaire(false);
     _inValidPage = CreateNewFormPage();
     CreateNewPage(PageType.ClosurePage);
     //if(setup)CreateNewQuestionairePage(out _validCampaign, out _validQuestionnaire, out _validPage, false);
     //if (setup) CreateNewQuestionairePage(out _inValidCampaign, out _inValidQuestionnaire, out _inValidPage, true);
 }
예제 #8
0
        //private List<KeyValuePair<PageElementDto, List<PageElementChoiceDto>>> _elements;
        //public List<KeyValuePair<PageElementDto, List<PageElementChoiceDto>>> Elements
        //{
        //    get { return _elements; }
        //    set { _elements = value; }
        //}

        public PageAssemblyDto(QuestionnaireDto questionnaire, PageDto page, OmnitureDto omniture, List<PageElementAssemblyDto> elements, List<PagePredefinedQuestionAssemblyDto> predefinedQuestions)
        {
            if (questionnaire == null || page == null || omniture == null || elements == null)
            {
                throw new ArgumentNullException("PageAssemblyDto requires all parameters to be not null");
            }
            _questionnaire = questionnaire;
            _page = page;
            _omniture = omniture;
            _elements = elements;
            _predeinedQuestions = predefinedQuestions;
        }
예제 #9
0
 protected override bool RealValidate(IResponseElementProvider elementToValidate, QuestionnaireDto questionnaire)
 {
     bool hasElements = false;
     bool hasMissingTexts = false;
     List<ResponseDto> responses = elementToValidate.GetResponseDto(-1);
     if (responses != null && responses.Count > 0)
     {
         hasElements = true;
         foreach (ResponseDto response in responses)
         {
             QuestionResponseDto questionResponse = response as QuestionResponseDto;
             if (questionResponse != null)
             {
                 PageElementChoiceDto choice = elementToValidate.Choices.Find(delegate(PageElementChoiceDto cur) { return cur.ChoiceId == questionResponse.ChoiceId; });
                 if (choice != null)
                 {
                     if (choice.HasExtraTextField  && String.IsNullOrEmpty(questionResponse.ChoiceText))
                     {
                         hasMissingTexts = true;
                     }
                 }
                 else
                 {
                     throw new UserCausedException(Constants.UserCausedDataFormatIncorrectElementMissmatch, "Choices validator found response (" + questionResponse.ChoiceId + ") which does not have a corresponding choice");
                 }
             }
             else
             {
                 throw new BugException("Choices validator does not accept a response of type \"" + response.GetType().Name + "\"");
             }
         }
     }
     bool retval = false;
     if (!hasMissingTexts)
     {
         if (elementToValidate.PageElement.IsRequired)
         {
             if (hasElements)
             {
                 retval = true;
             }
         }
         else
         {
             retval = true;
         }
     }
     elementToValidate.IsValid = retval;
     return retval;
 }
예제 #10
0
        protected override bool RealValidate(IResponseElementProvider elementToValidate, QuestionnaireDto questionnaire)
        {
            List<ResponseDto> responses = elementToValidate.GetResponseDto(-1);
            List<int> validationHints = null;
            PersonalDataSectionDto elementDto = elementToValidate.PageElement as PersonalDataSectionDto;
            if (elementDto != null)
            {
                validationHints = new List<int>();
                validationHints1 = new List<int>();
                if (responses != null && responses.Count == 1)
                {
                    PersonalResponseDto response = responses[0] as PersonalResponseDto;
                    if (response != null)
                    {
                        MakeFunnyThingsHappen(elementDto, response, validationHints);

                    }
                    else
                    {
                        throw new UserCausedException(Constants.UserCausedDataFormatIncorrectElementMissing, "Personal validator did not receive a single personal response");
                    }
                }
                else
                {
                    MakeFunnyThingsHappen(elementDto, null, validationHints);
                }
            }
            else
            {
                throw new UserCausedException(Constants.UserCausedDataFormatIncorrectElementMissing, "Personal validator did not receive a page element");
            }
            bool retval = true;
            if (validationHints.Count > 0 || validationHints1.Count > 0)
            {
                retval = false;
                if (validationHints.Count > 0)
                    elementToValidate.SetValidationHints(validationHints);

             if (validationHints1.Count > 0)
              elementToValidate.SetValidationNumberHints(validationHints1);
            }
            elementToValidate.IsValid = retval;

            return retval;
        }
예제 #11
0
        internal static PersonalResponseDto TestAddPersonalResponseDto(QuestionnaireDto _currentQuestionnaire, bool uniqueEmail)
        {
            string email = "email";

            if (uniqueEmail)
            {
                const string source = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
                const int NumOfChars = 50; // email is nvarchar(60)

                Random rnd = new Random();
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < NumOfChars; i++)
                {
                    sb.Append(source[rnd.Next(source.Length)]);
                }
                email = sb.ToString();
            }
            long responseKey = FormRegistry.ResponseDao.CreateSubmitResponse(Constants.UnknownCustomer, null, _currentQuestionnaire.QuestionnaireId, ViewType.CleanSheetOverlay).First;
            Assert.Greater(responseKey, 0);
            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", "cre");
            Assert.IsTrue(FormRegistry.ResponseDao.Add(dto));
            return dto;
        }        
예제 #12
0
 protected override bool RealValidate(IResponsePredefinedQuestionProvider elementToValidate, QuestionnaireDto questionnaire, ref Boolean isLengthCorrect, ref string incorrectLengthMsg)
 {
     return true;
 }
예제 #13
0
 protected override bool RealPhoneValidate(IResponseElementProvider elementToValidate, QuestionnaireDto questionnaire)            
  {
      return true;
  }
예제 #14
0
        private void SendUnsubscribeEmail(QuestionnaireDto questionnaire, PersonalResponseDto customer, string rid)
        {
            List<ResponseDto> responses = new List<ResponseDto>();
            CompleteResponseDTO complete = new CompleteResponseDTO(customer.CustomerId, rid, responses,
                new FormSubmissionFacade.IResponseServiceClass(questionnaire, this.PageAssembly.Page, questionnaire.CountryCode, questionnaire.LanguageCode, true),
                customer.ResponseKey);

            responses.Add(customer);

            EmailFacade.SendUnsubscribeEmail(complete, customer.EmailAddress);
        }
예제 #15
0
 private QuestionnaireDto ReadQuestionnaire(IDataReader reader, ref bool alreadyRead)
 {
     QuestionnaireDto retval = new QuestionnaireDto();
     retval.QuestionnaireId = reader.GetInt32(0);
     retval.QidTitle = reader.GetString(6);
     retval.CampaignCode = reader.GetString(3);
     alreadyRead = reader.Read();
     return retval;
 }
예제 #16
0
        protected override bool RealValidate(IResponsePredefinedQuestionProvider elementToValidate, QuestionnaireDto questionnaire, ref Boolean isLengthCorrect, ref string incorrectLengthMsg)
        {
            bool hasElements = false;
            bool hasMissingTexts = false;
            isLengthCorrect = true;
            List<ResponseDto> responses = elementToValidate.GetResponseDto(-1);
            if (responses != null && responses.Count > 0)
            {
                List<PagePredefinedQuestionChoiceDto> choices = elementToValidate.PageQuestionChoices;

                if (choices == null || choices.Count < 1)
                {
                    throw new UserCausedException(Constants.UserCausedDataFormatIncorrectElementMissing, "Drop down validator requires choices to validate");
                }
                if (responses != null && responses.Count > 0)
                {
                    foreach (ResponseDto response in responses)
                    {
                        PredefinedQuestionResponseDto questionResponse = response as PredefinedQuestionResponseDto;
                        if (questionResponse != null)
                        {
                            hasElements = true;                            
                            PredefinedLocalizedChoiceDto pChoice = PredefinedQuestionFacade.GetPredefinedLocalizedChoiceByPagePredefinedChoiceId(questionResponse.ChoiceId);
                            if (pChoice != null && pChoice.PChoiceDto != null)
                            {
                                if (pChoice.PChoiceDto.SortSequence == -1 && elementToValidate.PageQuestion.Required)
                                {
                                    hasMissingTexts = true;                                    
                                }

                                if (pChoice.PChoiceDto.SortSequence == 999 && !String.IsNullOrEmpty(pChoice.OtherText) && !String.IsNullOrEmpty(pChoice.ErrorMessage))
                                {
                                    if (String.IsNullOrEmpty(questionResponse.ChoiceText))
                                    {
                                        hasMissingTexts = true;
                                    }
                                    else
                                    {
                                        if (questionResponse.ChoiceText.Length > 4000)
                                        {
                                            incorrectLengthMsg = pChoice.ErrorMessage;
                                            hasMissingTexts = true;
                                            isLengthCorrect = false;
                                        }
                                    }
                                }
                            }                            
                        }
                        else
                        {
                            throw new UserCausedException(Constants.UserCausedDataFormatIncorrectElementMissmatch, "Choices validator does not accept a response of type \"" + response.GetType().Name + "\"");
                        }
                    }
                }
            }


            bool retval = false;
            if (elementToValidate.PageQuestion.Required)
            {
                if (hasElements)
                {
                    if (!hasMissingTexts && isLengthCorrect)
                    {
                        retval = true;
                    }
                }
            }
            else
            {
                if (!(hasMissingTexts) && isLengthCorrect)
                {
                    retval = true;
                }                
            }
            elementToValidate.IsValid = retval;

            return retval;
        }
예제 #17
0
        protected override bool RealValidate(IResponseElementProvider elementToValidate, QuestionnaireDto questionnaire)
        {
            bool hasElements = false;
            int firstElement = 0;
            bool hasMissingTexts = false;
            List<ResponseDto> responses = elementToValidate.GetResponseDto(-1);
            if (responses != null && responses.Count > 0)
            {
                List<PageElementChoiceDto> choices = elementToValidate.Choices;

                if (choices == null || choices.Count < 1)
                {
                    throw new UserCausedException(Constants.UserCausedDataFormatIncorrectElementMissing, "Drop down validator requires choices to validate");
                }
                firstElement = choices[0].ChoiceId;
                if (responses != null && responses.Count > 0)
                {
                    foreach (ResponseDto response in responses)
                    {
                        QuestionResponseDto questionResponse = response as QuestionResponseDto;
                        if (questionResponse != null)
                        {
                            hasElements = true;
                            if (questionResponse.ChoiceId == firstElement)
                            {
                                hasMissingTexts = true;
                            }

                            if (isExtraText(elementToValidate.PageElement.ElementId, questionResponse.ChoiceId))
                            {
                                    if(questionResponse.ChoiceText != null)
                                    {
                                        if (String.IsNullOrEmpty(questionResponse.ChoiceText))
                                            hasMissingTexts = true;

                                    }
                            }

                        }
                        else
                        {
                            throw new UserCausedException(Constants.UserCausedDataFormatIncorrectElementMissmatch, "Choices validator does not accept a response of type \"" + response.GetType().Name + "\"");
                        }
                    }
                }
            }

            
            bool retval = false;
            if (elementToValidate.PageElement.IsRequired)
            {
                if (hasElements)
                {
                    if (!hasMissingTexts)
                    {
                        retval = true;
                    }
                }
            }
            else
            {
                if (!(hasMissingTexts))
                {
                    retval = true;
                }
                else
                {
                    retval = false;
                }
            }
            elementToValidate.IsValid = retval;

            return retval;
        }
예제 #18
0
        public static QuestionnaireUrlDto GetUrl(QuestionnaireDto questionnaire, ViewType viewType)
        {
            QuestionnaireUrlDto retval = null;

            //QuestionnaireDto questionnaire = FormRegistry.QuestionnaireDao.Get((int)questionnaireId, QuestionnaireType.Questionnaire, viewType);

            if (questionnaire != null)
            {
                string closurePageUrl = questionnaire.ExternalClosurePage;
                string expirePageUrl = questionnaire.ExpireRedirect;
                string offlinePageUrl = questionnaire.OfflineRedirect;

                retval = new QuestionnaireUrlDto(questionnaire.QuestionnaireId, closurePageUrl, expirePageUrl, offlinePageUrl);
            }

            return retval;
        }
예제 #19
0
 protected override bool RealValidate(IResponseElementProvider elementToValidate, QuestionnaireDto questionnaire)
 {
     List<ResponseDto> responses = elementToValidate.GetResponseDto(-1);
     List<int> validationHints = new List<int>();
     if (responses != null && responses.Count == 2)
     {
         PrivacyResponseDto response = responses[0] as PrivacyResponseDto;
         if (response != null)
         {
             PrivacyDataSectionDto elementDto = elementToValidate.PageElement as PrivacyDataSectionDto;
             if (elementDto != null)
             {
                 if (!String.IsNullOrEmpty(elementDto.Email))
                 {
                     if (!response.ContactByEmail.HasValue)
                     {
                         validationHints.Add(PrivacyDataSectionDto.InvalidEmail);
                     }
                     else
                     {
                         if (response.ContactByEmail.Value)
                         {
                             if (!String.IsNullOrEmpty(elementDto.EmailPreferences))
                             {
                                 if (!response.EmailPreferences.HasValue)
                                 {
                                     validationHints.Add(PrivacyDataSectionDto.InvalidEmailPreferences);
                                 }
                             }
                         }
                     }
                 }
                 if (!String.IsNullOrEmpty(elementDto.Phone))
                 {
                     if (!response.ContactByPhone.HasValue)
                     {
                         validationHints.Add(PrivacyDataSectionDto.InvalidPhone);
                     }
                 }
                 if (!String.IsNullOrEmpty(elementDto.Post))
                 {
                     if (!response.ContactByPost.HasValue)
                     {
                         validationHints.Add(PrivacyDataSectionDto.InvalidPost);
                     }
                 }
             }
             else
             {
                 throw new UserCausedException(Constants.UserCausedDataFormatIncorrectElementMissing, "Privacy validator did not receive a page element");
             }
         }
         else
         {
             throw new UserCausedException(Constants.UserCausedDataFormatIncorrectElementMissing, "Privacy validator did not receive a single privacy response");
         }
     }
     else
     {
         throw new UserCausedException(Constants.UserCausedDataFormatIncorrectElementMissing, "Privacy validator did not receive a single privacy response");
     }
     bool retval = true;
     if (validationHints.Count > 0)
     {
         retval = false;
         elementToValidate.SetValidationHints(validationHints);
     }
     elementToValidate.IsValid = retval;
     return retval;
 }
예제 #20
0
 /// <summary>
 /// only use this method if page and formpage are not present before
 /// </summary>
 /// <param name="questionnaire"></param>
 /// <param name="pageId"></param>
 /// <param name="navigationType"></param>
 /// <param name="throwException"></param>
 /// <returns></returns>
 private static List<NavigationElementDto> GetNavigationElementsByQuestionnaireIdAndPageId(QuestionnaireDto questionnaire, int pageId, NavigationType navigationType, bool throwException)
 {
     PageAssemblyDto pg = QuestionnaireFacade.GetPageByPageId(questionnaire, pageId, ViewType.Undefined, false);
     PageAssemblyDto formPage = QuestionnaireFacade.GetFormPage(questionnaire, false, ViewType.Undefined, throwException);
     
     return GetNavigationElementsByQuestionnaireIdAndPageId(questionnaire, pg, formPage, navigationType, throwException);
 }
예제 #21
0
        public static PageAssemblyDto GetPage(QuestionnaireDto questionnaire, bool forDisplay, PageType type, ViewType viewType, bool throwException)
        {
            PageAssemblyDto retval = null;

            //first get the questionnaire if there is no questionnaire then the page will also be null...
            //The QuestionnaireDto can be accessed via FormRegistry.QuestionnaireDao.Get  (…).
            
            if (questionnaire != null)
            {
                //The PageDto can be accessed via FormRegistry.PageDao.Get(…).
                PageDto page = FormRegistry.PageDao.Get(questionnaire.QuestionnaireId, type);
                if (page != null)
                {

                    //The QuestionnaireDto can be accessed via FormRegistry.QuestionnaireDao.Get  (…).
                    //QuestionnaireDto questionnaire = FormRegistry.QuestionnaireDao.Get((int)questionnaireId, QuestionnaireType.Questionnaire, viewType);
                    if (forDisplay) CheckQuestionnaire(questionnaire, type, viewType);

                    OmnitureDto omniture = FormRegistry.OmnitureDao.Get(questionnaire.QuestionnaireId, viewType);

                    //The PageElementDtos can be accessed via FormRegistry.PageElementDao.GetPageElement(…)
                    List<PageElementReqDto> pageElements = FormRegistry.PageElementDao.GetElements(page.PageId);

                    //The PageElementChoiceDtos per page element can be accessed via FormRegistry.PageElementDao.List (parentElementId)
                    List<PageElementAssemblyDto> assemblyElements = new List<PageElementAssemblyDto>();
                    List<PagePredefinedQuestionDto> predefinedQuestions = FormRegistry.PredefinedQuestionDao.GetPagePredefinedQuestion(null, page.PageId, null);
                    List<PagePredefinedQuestionAssemblyDto> assemblyPredefinedQuestions = new List<PagePredefinedQuestionAssemblyDto>();

                    if (pageElements != null)
                    {
                        pageElements.RemoveAll(delegate(PageElementReqDto cur) { if (cur != null) return !cur.IsActive; return false; });
                        foreach (PageElementReqDto ped in pageElements)
                        {
                            PageElementAssemblyDto pead = new PageElementAssemblyDto(ped, FormRegistry.PageElementDao.List(ped.ElementId));
                            Trace.WriteLine("Element found:" + ped.PageElementType.ToString());
                            assemblyElements.Add(pead);
                        }
                    }

                    if (predefinedQuestions != null)
                    {
                        predefinedQuestions.RemoveAll(q => q.StatusActive.HasValue && q.StatusActive.Value == 0);
                        foreach (PagePredefinedQuestionDto q in predefinedQuestions)
                        {
                            PagePredefinedQuestionAssemblyDto ppqa = new PagePredefinedQuestionAssemblyDto();
                            ppqa.Question = q;
                            ppqa.Choices = FormRegistry.PredefinedQuestionDao.GetPagePredefinedQuestionChoices(q.PagePredefinedQuestionId, null);
                            assemblyPredefinedQuestions.Add(ppqa);
                        }
                    }

                    PrivacyDataSectionDto privacy = FormRegistry.PrivacyDao.GetByPageId(page.PageId);
                    PersonalDataSectionDto personal = FormRegistry.PersonalDao.GetByPageId(page.PageId);
                    if (personal != null)
                    {
                        assemblyElements.Add(new PageElementAssemblyDto(personal, null));
                    }
                    else
                    {
                        assemblyElements.Add(new PageElementAssemblyDto(new PersonalDataSectionDto(page.PageId), null));
                    }
                    assemblyElements.Sort(delegate(PageElementAssemblyDto x, PageElementAssemblyDto y) { return x.Pageelement.SortSequence.CompareTo(y.Pageelement.SortSequence); });
                    assemblyPredefinedQuestions.Sort(delegate(PagePredefinedQuestionAssemblyDto x, PagePredefinedQuestionAssemblyDto y) { return x.Question.SortSequence.CompareTo(y.Question.SortSequence); });
                    if (privacy != null)
                    {
                        assemblyElements.Add(new PageElementAssemblyDto(privacy, null));
                    }
                    retval = new PageAssemblyDto(questionnaire, page, omniture, assemblyElements, assemblyPredefinedQuestions);
                }
                else if (throwException)
                {
                    throw new Com.SunnySystems.Util.Base.UserCausedException(HP.Rfg.Common.Constants.UserCausedPageNotFound);
                }
            }
            else if (throwException)
            {
                throw new Com.SunnySystems.Util.Base.UserCausedException(HP.Rfg.Common.Constants.UserCausedQuestionnaireNotFound);
            }

            return retval;
        }
예제 #22
0
        public static List<NavigationElementDto> GetNavigationElementsByQuestionnaireIdAndPageId(QuestionnaireDto questionnaire, PageAssemblyDto pg, PageAssemblyDto formPage, NavigationType navigationType, bool throwException)
        {
            List<NavigationElementDto> retval = FormRegistry.QuestionnaireDao.GetNavigationElements(pg.Page.PageId, navigationType);
            //PageAssemblyDto formPage = QuestionnaireFacade.GetFormPage(questionnaire, false, ViewType.Undefined, throwException);

            if (formPage != null && formPage.Page != null &&
                pg != null && pg.Page != null && pg.Page.PageId != formPage.Page.PageId)
            {
                List<NavigationElementDto> listOfElementsForFormpage = QuestionnaireFacade.GetNavigationElementsToEditByPageId(formPage.Page.PageId, NavigationType.NavigationTab);
                foreach (NavigationElementDto dto in listOfElementsForFormpage)
                {
                    if (dto.ElementType == NavigationElementType.ExternalLinkTab)
                    {
                        NavigationElementDto elementToAdd = new NavigationElementDto();
                        elementToAdd.ElementId = dto.ElementId;
                        elementToAdd.ElementType = NavigationElementType.ExternalLinkTab;
                        elementToAdd.Name = dto.Name;
                        elementToAdd.PageId = formPage.Page.PageId;
                        elementToAdd.SortSequence = dto.SortSequence;
                        elementToAdd.Url = dto.Url;
                        retval.Add(elementToAdd);
                    }
                }
            }

            retval.Sort(delegate(NavigationElementDto x, NavigationElementDto y)
            {
                return x.SortSequence.CompareTo(y.SortSequence);
            });

            return retval;
        }
예제 #23
0
 public static QuestionnaireStatus GetStatus(QuestionnaireDto questionnaire, ViewType viewType)
 {
     string cc = null, ll = null;
     
     return GetStatus(questionnaire, viewType, ref cc, ref ll);
 }
예제 #24
0
 public static QuestionnaireStatus CheckIfClassic(QuestionnaireDto questionnaire, ViewType viewType)
 {
     QuestionnaireStatus retval = QuestionnaireStatus.NotFound;
     
     if (questionnaire != null)
     {
     
         if (questionnaire.UseClassicDesign)
             retval = QuestionnaireStatus.DesignRedirect_Classic;
     }
     return retval;
 }
예제 #25
0
        protected override bool RealValidate(IResponseElementProvider elementToValidate, QuestionnaireDto questionnaire)
        {
            bool invalidPhone = true;
            bool invalidCallback = true;
            bool hasPhone = false;

            List<ResponseDto> responses = elementToValidate.GetResponseDto(-1);
            if (responses != null && responses.Count > 0)
            {
                PageElementChoiceDto callBack = null;
                PageElementChoiceDto phone = null;
                foreach (PageElementChoiceDto dto in elementToValidate.Choices)
                {
                    if (dto.LovKey == "resp_phone")
                    {
                        phone = dto;
                    }
                    else if (dto.LovKey == "callback_time")
                    {
                        callBack = dto;
                    }
                }
                if (phone != null)
                {
                    QuestionResponseDto phoneResponse = responses.Find(delegate(ResponseDto cur)
                        {
                            QuestionResponseDto me = cur as QuestionResponseDto;
                            return me != null && me.ChoiceId == phone.ChoiceId;
                        }) as QuestionResponseDto;
                    if (phoneResponse != null)
                    {
                        hasPhone = true;
                        invalidPhone = !DataValidation.ValidatePhoneNumberCRM(phoneResponse.ChoiceText, true);
                    }
                }
                if (callBack != null)
                {
                    QuestionResponseDto callResponse = responses.Find(delegate(ResponseDto cur)
                    {
                        QuestionResponseDto me = cur as QuestionResponseDto;
                        return me != null && me.ChoiceId == callBack.ChoiceId;
                    }) as QuestionResponseDto;
                    if (callResponse != null)
                    {
                        invalidCallback = !callResponse.ListOfValuesId.HasValue;
                    }
                }
                if (!invalidCallback && !invalidPhone)
                {
                    SpecificCrmResponseDto crm = responses.Find(delegate(ResponseDto cur)
                    {
                        return cur is SpecificCrmResponseDto;
                    }) as SpecificCrmResponseDto;
                    if (crm != null)
                    {
                        if (crm.ElementType == SpecificCrmResponseDto.ElementTypeRequestCallback
                            && crm.QuestionId == elementToValidate.PageElement.ElementId
                            && crm.PageId == elementToValidate.PageElement.PageId
                            && crm.CrmSubmit == questionnaire.SendToCrm
                            && crm.CidSubmit == false
                            && crm.QuestionnaireId == questionnaire.QuestionnaireId
                            && !String.IsNullOrEmpty(crm.RespDesc))
                        {
                        }
                        else
                        {
                            throw new UserCausedException(Constants.UserCausedDataFormatIncorrect, "crm callback requires a valid specific crm response");
                        }
                    }
                    else
                    {
                        throw new UserCausedException(Constants.UserCausedDataFormatIncorrectElementMissing, "crm callback requires a specific crm response");
                    }

                }
            }
            bool retval = true;//!invalidCallback && !invalidPhone;
            if (elementToValidate.PageElement.IsRequired || hasPhone)
            {
                List<int> validationHints = new List<int>();
                if (invalidPhone)
                {
                    validationHints.Add(PageElementReqDto.InvalidTelephoneNumber);
                    retval = false;
                }
                if (invalidCallback)
                {
                    validationHints.Add(PageElementReqDto.InvalidCallBackTime);
                    retval = false;
                }
                if (!retval)
                {
                    elementToValidate.SetValidationHints(validationHints);
                }
            }
            elementToValidate.IsValid = retval;
            return retval;
        }
예제 #26
0
 protected override bool RealMobileValidate(IResponseElementProvider elementToValidate, QuestionnaireDto questionnaire)
 {
     elementToValidate.IsValid = true;
     return true;
 }
예제 #27
0
        public static QuestionnaireStatus GetStatus(QuestionnaireDto questionnaire, ViewType viewType, ref string countryCode, ref string languageCode)
        { 
            QuestionnaireStatus retval = QuestionnaireStatus.NotFound;

            if (questionnaire != null)
            {
                languageCode = questionnaire.LanguageCode;
                countryCode = questionnaire.CountryCode;

                if (questionnaire.IsActive)
                {
                    if (questionnaire.PublishDate != null)
                    {
                        if (questionnaire.PublishDate < DateTime.Now)
                        {
                            retval = QuestionnaireStatus.Active;
                        }
                        else
                        {
                            retval = QuestionnaireStatus.Inactive;
                        }
                    }
                    else
                    {
                        retval = QuestionnaireStatus.Active;
                    }

                    if (CheckIsOffline(questionnaire))
                    {
                        retval = QuestionnaireStatus.Offline;
                    }

                    if (questionnaire.ExpireDate < DateTime.Now)
                    {
                        retval = QuestionnaireStatus.Expired;
                    }
                }
                else
                {
                    retval = QuestionnaireStatus.Inactive;
                }
            }
            return retval;
        }
예제 #28
0
        public static PageAssemblyDto GetClosurePage(QuestionnaireDto questionnaire, bool forDisplay, ViewType viewType, bool throwException)
        {
            return GetPage(questionnaire, forDisplay, PageType.ClosurePage, viewType, throwException);

        }
예제 #29
0
        public void CreateNewQuestionnairePage(out CampaignDto currentCampaign, out QuestionnaireDto currentQuestionnaire, out PageDto currentPage, bool registeredPersonalized)
        {

            List<PageTagDto> listOfPageTags = FormRegistry.QuestionnaireDao.GetPageTags();
            PageTagDto metaUserProfile = listOfPageTags.Find(pt => !String.IsNullOrEmpty(pt.TagGroup) && pt.TagGroup.Equals("user_profile") &&
                    pt.TagValue.Equals("Non-targeted"));
            _campaignCode = GetNewCampaignName();
            _creatorEmailAddress = TestUser;

            currentCampaign = FormRegistry.CampaignDao.Create(new CampaignDto(_campaignCode, _creatorEmailAddress));
            
            QuestionnaireType type = QuestionnaireType.Questionnaire;
            string creatorEmailAddress = TestUser;
            string campaignCode = currentCampaign.CampaignCode;
            string countryCode = "UK";
            string languageCode = "EN";
            string qidTitle = "qidt" + GetNewStamp();
            bool isActive = true;
            DateTime expireDate = DateTime.Today.AddDays(10);
            string expireRedirect = "expire redirect";
            bool sendToCrm = true;
            string crmMrmCode = "crm mrm code";
            string crmWaveCode = "crm wave code";
            string treatmentCode = "treatment code";
            bool anyAsset = false;
            bool hppEnabled = false;
            bool personalized = false;
            //bool registeredPersonalized = false;
            bool hasClosurePage = true;
            string externalClosurePage = "external closure page";
            bool hasThankYouEmail = true;
            bool hasNotificationEmail = true;
            string themeColor = "#000000";
            string mainImage = "main image";
            string leftNavHtml = "left nav";
            string comments = "comments";
            int metaPageContent = 1;
            int metaSegment = 1;
            DateTime creationDate = DateTime.Today;
            string businessOwner = currentCampaign.CreatorEmailAddress;
            string urlLayoutForm = "url layout form";
            bool hasNotificationEmailAstro2 = true;
            DateTime? offlineStart = DateTime.Today.AddDays(7);
            DateTime? offlineEnd = DateTime.Today.AddDays(8);
            int? offlineMode = 1;
            DateTime? offlineRecurEnd = DateTime.Today.AddDays(9);
            string offlineRedirect = "offline redirect";
            string region = "EMEA";
            DateTime? datePublished = DateTime.Today.AddDays(10);
            DateTime? dateModified = DateTime.Today.AddDays(11);
            string metaPageContentValue = "meta content value";
            string metaSegmentValue = "meta segment value";
            string htmlLang = "html lang";
            int userProfile = metaUserProfile.TagId;
            string userProfileValue = metaUserProfile.TagValue;
            bool isGofaForm = false;
            DateTime? publishDate = DateTime.Today.AddDays(12);
            QuestionnaireDto dto = new QuestionnaireDto(type, creatorEmailAddress, campaignCode, countryCode, languageCode, qidTitle, isActive, expireDate, expireRedirect, sendToCrm, crmMrmCode, personalized, registeredPersonalized, hasClosurePage, externalClosurePage, hasThankYouEmail, hasNotificationEmail, themeColor, mainImage, leftNavHtml, comments, metaPageContent, metaSegment, creationDate, businessOwner, urlLayoutForm, hasNotificationEmailAstro2, offlineStart, offlineEnd, offlineMode, offlineRecurEnd, offlineRedirect, region, datePublished, dateModified, metaPageContentValue, metaSegmentValue, htmlLang, publishDate, crmWaveCode, hppEnabled, anyAsset, treatmentCode, userProfile, userProfileValue,isGofaForm,0,0,false,-1,0,null,0,0,0,1);
            currentQuestionnaire = FormRegistry.QuestionnaireDao.Create(dto, "insert");

            PageType pageType = PageType.FormPage;
            int questionnaireId = currentQuestionnaire.QuestionnaireId;
            string pageTitle = "test page";
            int? mdaId = null;
            string mdaFileName = null;
            string introduction = "intro";
            string requiredSentence = "required sentence";
            string buttonText = "save button";
            string leftNavHtml2 = "left nav html2";
            string pageTagline = "page tagline";
            string privacySentence = "privacy sentence";
            currentPage = FormRegistry.PageDao.Create(new PageDto(pageType, questionnaireId, pageTitle, mdaId, mdaFileName, introduction, requiredSentence, buttonText, leftNavHtml2, pageTagline, privacySentence));

        }
예제 #30
0
        private static bool CheckIsOffline(QuestionnaireDto questionnaire)
        {
            bool retval = false;

            if (questionnaire.OfflineMode != null)
            {
                bool datediff = false;

                DateTime start = DateTime.MinValue;
                DateTime end = DateTime.MinValue;
                DateTime recureEnd = DateTime.MinValue;

                if (questionnaire.OfflineStart != null)
                {
                    start = questionnaire.OfflineStart.Value;
                }

                if (questionnaire.OfflineEnd != null)
                {
                    end = questionnaire.OfflineEnd.Value;
                }

                if (questionnaire.OfflineRecurEnd != null)
                {
                    recureEnd = questionnaire.OfflineRecurEnd.Value;
                }

                DateTime now = DateTime.Now;

                switch (questionnaire.OfflineMode)
                {
                    case 0:
                        if ((start < now) && (now < end))
                        {
                            datediff = true;
                        }
                        break;

                    case 1:
                        if ((start < now) && (now < recureEnd))
                        {
                            datediff = true;
                        }
                        break;

                    case 2:
                        if ((start < now) && (now < recureEnd) && (start.DayOfWeek == now.DayOfWeek))
                        {
                            datediff = true;
                        }
                        break;

                    case 3:
                        if ((start < now) && (now < end) && (start.Day == now.Day))
                            datediff = true;
                        break;

                    default: datediff = false;
                        break;
                }

                if (datediff)
                {
                    if ((start.TimeOfDay < DateTime.Now.TimeOfDay))
                    {
                        retval = true;
                    }
                    if (DateTime.Now.Date < end.Date)
                    {
                        retval = true;
                    }
                    else
                    {
                        if (DateTime.Now.Date > end.Date)
                        {
                            retval = false;
                        }
                        else if (DateTime.Now.TimeOfDay < end.TimeOfDay)
                        {
                            retval = true;
                        }
                        else
                        {
                            retval = false;
                        }
                    }
                }
            }
            return retval;
        }