private int PagePrefill() { int retval = 1; PageAssemblyDto formpage = QuestionnaireFacade.GetFormPage(Int64.Parse(questionnaireIdFromSession), false, ViewType.Undefined, false); if (formpage != null) { 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; listOfNavigationElements.Add(elementToAdd); } else if (dto.ElementType == NavigationElementType.FormpageTab) { retval = dto.SortSequence; } } } return retval; }
private void LoadListOfNavigationElements(PageType pagType, int initialFormOrder) { List<NavigationElementDto> tempList = QuestionnaireFacade.GetNavigationElementsToEditByPageId(int.Parse(pageIdFromSession), NavigationType.NavigationTab); if (tempList != null && tempList.Count > 0) listOfNavigationElements.AddRange(tempList); if (listOfNavigationElements == null || listOfNavigationElements.Count == 0 || (page.PageType == pagType && listOfNavigationElements.Find(n=> n.ElementType == Migration.ConvertPageTypeToNavigationElementType(page.PageType)) == null)) { NavigationElementDto mainElement = new NavigationElementDto(); mainElement.ElementType = Migration.ConvertPageTypeToNavigationElementType(page.PageType); mainElement.PageId = int.Parse(pageIdFromSession); mainElement.SortSequence = initialFormOrder; mainElement.Url = null; listOfNavigationElements.Add(mainElement); } listOfNavigationElements.Sort(delegate(NavigationElementDto x, NavigationElementDto y) { return x.SortSequence .CompareTo(y.SortSequence); }); already_added_elements_repeater.DataSource = listOfNavigationElements; already_added_elements_repeater.DataBind(); }
protected void addElement_Click(object sender, EventArgs e) { bool valid = true; InitializePanels(); if(String.IsNullOrEmpty(name_add_txt.Text)) { incorrect_element_lbl.Text += "Please insert name of element! <br />"; incorrectElemntPanel.Visible = true; valid = false; } if (String.IsNullOrEmpty(url_add_txt.Text)) { incorrect_element_lbl.Text += "Please insert url of element! <br />"; incorrectElemntPanel.Visible = true; valid = false; } else { string urlRegex = utility.getParameter("regex_url"); if (!(Regex.IsMatch(url_add_txt.Text, urlRegex))) { incorrect_element_lbl.Text += "Please insert url of element in correct format! <br />"; incorrectElemntPanel.Visible = true; valid = false; } } if (listOfNavigationElements.Count >= MAX_NUMBER_OF_TAB) { incorrect_element_lbl.Text += "Maximal number of tabs was reached! <br />"; incorrectElemntPanel.Visible = true; valid = false; } if (valid) { NavigationElementDto newElement = new NavigationElementDto(); newElement.ElementType = NavigationElementType.ExternalLinkTab; newElement.Name = name_add_txt.Text; newElement.PageId = int.Parse(pageIdFromSession); newElement.SortSequence = listOfNavigationElements.Count + 1; newElement.Url = url_add_txt.Text; listOfNavigationElements.Add(newElement); ResetAddElement(); already_added_elements_repeater.DataSource = listOfNavigationElements; already_added_elements_repeater.DataBind(); } }
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; }
public static NavigationElementDto CreateNavigationElements(NavigationElementDto dto) { return FormRegistry.QuestionnaireDao.Create(dto); }
private void Write(DbCommand sp, NavigationElementDto dto) { if (dto.ElementId.HasValue) { _dbLayer.AddInParameter(sp, "@element_id", DbType.Int32, dto.ElementId); } _dbLayer.AddInParameter(sp, "@page_FK", DbType.Int32, dto.PageId); _dbLayer.AddInParameter(sp, "@element_type", DbType.String, Migration.ConvertToNavigationElementType(dto.ElementType)); _dbLayer.AddInParameter(sp, "@name", DbType.String, dto.Name); _dbLayer.AddInParameter(sp, "@url", DbType.String, dto.Url); _dbLayer.AddInParameter(sp, "@sort_sequence", DbType.Int32, dto.SortSequence); }
public NavigationElementDto Create(NavigationElementDto dto) { NavigationElementDto retval = null; DbCommand sp = null; DbConnection connection = null; IDataReader reader = null; try { connection = _dbLayer.GetConnection(); sp = connection.CreateCommand(); sp.CommandText = "update_navigation_elements"; sp.CommandType = CommandType.StoredProcedure; Write(sp, dto); _dbLayer.AddReturnParameter(sp); reader = sp.ExecuteReader(); retval = new NavigationElementDto(); if (reader.Read()) { bool alreadyRead = true; retval = ReadNavigationElement(reader, ref alreadyRead); } else { int err = _dbLayer.GetReturnValue(sp); Trace.WriteLine("QuestionnaireDao.Create(" + dto + ") returned " + err); } } catch (DbException e) { Trace.WriteLine("QuestionnaireDao.Create(" + 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; }
private NavigationElementDto ReadNavigationElement(IDataReader reader, ref bool alreadyRead) { NavigationElementDto retval = new NavigationElementDto(); retval.ElementId = reader.GetInt32(0); retval.PageId = reader.GetInt32(1); retval.ElementType = Migration.ConvertToNavigationElementType(reader.GetString(2)); retval.Name = reader.GetString(3); retval.Url = GetString(reader, 4); retval.SortSequence = reader.GetInt32(5); alreadyRead = reader.Read(); return retval; }
public void TestCreateGetDeleteRightNavigation() { CreateNewQuestionnaire(); CreateNewFormPage(); PageAssemblyDto retval = QuestionnaireFacade.GetPageByPageId(_currentQuestionnaire.QuestionnaireId, _currentPage.PageId, ViewType.Undefined, false); Assert.IsNotNull(retval); Assert.AreEqual(PageType.FormPage, retval.Page.PageType); NavigationElementDto navElement = new NavigationElementDto() { ElementType = NavigationElementType.Divider, Name = String.Empty, PageId = retval.Page.PageId, SortSequence = 1, Url = null }; NavigationElementDto ret = QuestionnaireFacade.CreateNavigationElements(navElement); Assert.NotNull(ret); navElement.ElementId = ret.ElementId; Assert.AreEqual(navElement, ret); List<NavigationElementDto> elementsSaved = QuestionnaireFacade.GetNavigationElementsToEditByPageId(_currentPage.PageId, NavigationType.NavigationAdditional); Assert.True(elementsSaved.Find(el => el.Equals(ret)) != null); QuestionnaireFacade.DeleteNavigationElement(ret.ElementId.Value); elementsSaved = QuestionnaireFacade.GetNavigationElementsToEditByPageId(_currentPage.PageId, NavigationType.NavigationAdditional); Assert.True(elementsSaved.Find(el => el.Equals(ret)) == null); }
protected void addElement_Click(object sender, EventArgs e) { bool valid = true; InitializePanels(); if (elementTypeList.SelectedIndex == 0) { incorrect_element_lbl.Text += "Please select element type from the list! <br />"; incorrectElemntPanel.Visible = true; valid = false; } if (String.IsNullOrEmpty(name_add_txt.Text) && !(elementTypeList.SelectedValue.Equals("Divider"))) { incorrect_element_lbl.Text += "Please insert element name! <br />"; incorrectElemntPanel.Visible = true; valid = false; } if (String.IsNullOrEmpty(url_add_txt.Text) && !(elementTypeList.SelectedValue.Equals("Divider")) && !(elementTypeList.SelectedValue.Equals("Non - clickable headline"))) { incorrect_element_lbl.Text += "Please insert element url! <br />"; incorrectElemntPanel.Visible = true; valid = false; } if (!String.IsNullOrEmpty(url_add_txt.Text)) { string urlRegex = utility.getParameter("regex_url"); if (!(Regex.IsMatch(url_add_txt.Text, urlRegex))) { incorrect_element_lbl.Text += "Please insert element url in correct format! <br />"; incorrectElemntPanel.Visible = true; valid = false; } } if (valid) { NavigationElementDto newElement = new NavigationElementDto(); switch(elementTypeList.SelectedValue) { case "Non - clickable headline": newElement.ElementType = NavigationElementType.NonClickableHeadline; break; case "Clickable headline": newElement.ElementType = NavigationElementType.ClickableHeadline; break; case "Link": newElement.ElementType = NavigationElementType.Link; break; case "Divider": newElement.ElementType = NavigationElementType.Divider; break; } newElement.Name = name_add_txt.Text; newElement.PageId = int.Parse(pageIdFromSession); newElement.SortSequence = listOfNavigationElements.Count + 1; newElement.Url = url_add_txt.Text; listOfNavigationElements.Add(newElement); ResetAddElement(); already_added_elements_repeater.DataSource = listOfNavigationElements; already_added_elements_repeater.DataBind(); } }