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; }
/* * Add a static method “GetPageComponents(PageAssemblyDto page, (?RespondentDataDto personalData?))” * to the static class Hp.Rfg.Web.Pages.ControlFactory. * The method will build the list of ASCX components to be included into the page or throw a UserCausedException * if a requested component is not available. */ public static List<WucPageElementBase> GetPageComponents(RfgExternalPage currentPage, PageAssemblyDto page) { List<WucPageElementBase> retval = new List<WucPageElementBase>(); foreach (PageElementAssemblyDto elem in page.Elements) { if (elem.Pageelement.PageElementType != PageElementType.RequiredHeadline) { string virtualPath; if (_mappings.TryGetValue(elem.Pageelement.PageElementType, out virtualPath)) { retval.Add(currentPage.LoadPageElement(virtualPath, elem)); } else { throw new UserCausedException(HP.Rfg.Common.Constants.UserCausedPageElementNotSupported); } } } foreach (PagePredefinedQuestionAssemblyDto elem in page.PredefinedQuestions) { string virtualPath; PageElementType pElementType = PageElementType.Unknown; pElementType = elem.Question.ElementType; if (_mappings.TryGetValue(pElementType, out virtualPath)) { retval.Add(currentPage.LoadPageElement(virtualPath, elem)); } else { throw new UserCausedException(HP.Rfg.Common.Constants.UserCausedPageElementNotSupported); } } retval.Sort( delegate(WucPageElementBase x, WucPageElementBase y) { if (x.PageElement != null) { if (y.PageElement != null && x.PageElement == y.PageElement) { return 0; } else if (x.PageElementType == PageElementType.PrivacyDataSection) return 1; else { if (y.PageElement != null) { if (y.PageElementType == PageElementType.PrivacyDataSection) return -1; else return x.PageElement.SortSequence.CompareTo(y.PageElement.SortSequence); } else if (y.PageQuestion != null) { return x.PageElement.SortSequence.CompareTo(y.PageQuestion.SortSequence); } } } else if (x.PageQuestion != null) { if (y.PageQuestion != null && x.PageQuestion == y.PageQuestion) { return 0; } else if (y.PageElement != null) { if (y.PageElementType == PageElementType.PrivacyDataSection) return -1; else return x.PageQuestion.SortSequence.CompareTo(y.PageElement.SortSequence); } else if (y.PageQuestion != null) { return x.PageQuestion.SortSequence.CompareTo(y.PageQuestion.SortSequence); } } return 0; } ); return retval; }
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; }