protected override void OnLoad(EventArgs e) { base.OnLoad(e); if (DataListView != null && DataListView.DataSource == null) { 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 <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(); }
private void GetSAPData(string oDataQuery) { // Always ensure there is a valid cached access token before querying GWM. // Pass this page object as the parameter. AADAuthHelper.EnsureValidAccessToken(this); using (WebClient client = new WebClient()) { client.Headers[HttpRequestHeader.Accept] = "application/json"; client.Headers[HttpRequestHeader.Authorization] = "Bearer " + AADAuthHelper.AccessToken.Item1; var jsonString = client.DownloadString(SAP_ODATA_URL + oDataQuery); var jsonValue = JObject.Parse(jsonString)["d"]["results"]; var dataCol = jsonValue.ToObject <List <DataModel> >(); var dataList = dataCol.Select((item) => { // replace the property names with names that match your data model class. return(item.Name + " " + item.Date + " " + item.Location); }).ToArray(); DataListView.DataSource = dataList; DataListView.DataBind(); } }