private void ParseRules(string xml) { var survey = SenseNet.ContentRepository.Content.Create(PortalContext.Current.ContextNode); var customFields = survey.Fields["FieldSettingContents"] as ReferenceField; var questions = customFields.OriginalValue as List <Node>; var pageBreaks = (from q in questions where q.NodeType.Name == "PageBreakFieldSetting" select q).Count(); var doc = new XmlDocument(); try { doc.LoadXml(xml); } catch { return; } _selectedQuestion = doc.DocumentElement.GetAttribute("Question"); if (_selectedQuestion == "-100") { DataListView.DataSource = null; DataListView.DataBind(); return; } foreach (XPathNavigator node in doc.DocumentElement.CreateNavigator().SelectChildren(XPathNodeType.Element)) { var answer = node.GetAttribute("Answer", ""); var answerId = node.GetAttribute("AnswerId", ""); var jumpToPage = node.Value; SurveyRulesList.Add(new SurveyRule(answer, answerId, jumpToPage, pageBreaks)); } var chfs = ChoiceFieldSettings.FirstOrDefault(fs => fs.Name == _selectedQuestion); var allowExtra = chfs != null && chfs.AllowExtraValue.HasValue && chfs.AllowExtraValue.Value; if (allowExtra && !SurveyRulesList.Any(sr => sr.AnswerId == SurveyRule.EXTRAVALUEID)) { SurveyRulesList.Add(new SurveyRule(SurveyRule.GetExtraValueText(), SurveyRule.EXTRAVALUEID, "", pageBreaks)); } else if (!allowExtra) { SurveyRulesList.RemoveAll(sr => sr.AnswerId == SurveyRule.EXTRAVALUEID); } DdlSurveyQuestions.SelectedValue = _selectedQuestion; DataListView.DataSource = SurveyRulesList; DataListView.DataBind(); }
private void ParseRules(string xml) { var survey = SenseNet.ContentRepository.Content.Create(PortalContext.Current.ContextNode); var customFields = survey.Fields["FieldSettingContents"] as ReferenceField; var questions = customFields.OriginalValue as List <SenseNet.ContentRepository.Storage.Node>; var pageBreaks = from q in questions where q.NodeType.Name == "PageBreakFieldSetting" select q; var doc = new XmlDocument(); try { doc.LoadXml(xml); } catch { return; } _selectedQuestion = doc.DocumentElement.GetAttribute("Question"); if (_selectedQuestion == "-100") { DataListView.DataSource = null; DataListView.DataBind(); return; } foreach (XPathNavigator node in doc.DocumentElement.CreateNavigator().SelectChildren(XPathNodeType.Element)) { var answer = node.GetAttribute("Answer", ""); var answerId = node.GetAttribute("AnswerId", ""); var jumpToPage = node.Value; SurveyRulesList.Add(new SurveyRule(answer, answerId, jumpToPage, pageBreaks.Count())); } DdlSurveyQuestions.SelectedValue = _selectedQuestion; DataListView.DataSource = SurveyRulesList; DataListView.DataBind(); }