public static GetNodeQueryXml ( string guiQuery ) : string | ||
guiQuery | string | |
Результат | string |
//========================================================================= FieldControl functions public override object GetData() { ResetListData(); if (LuceneTextBox != null && !string.IsNullOrEmpty(LuceneTextBox.Text)) { return(LuceneTextBox.Text); } if (this.ExpInfoList.Count == 0 || (this.ExpInfoList.Count == 1 && this.ExpInfoList[0].IsEmpty)) { return(string.Empty); } _query = new Query(); //EXPLIST: a and b or c and d or e //QUERY : (a & b) | (c & d) | (d & e) try { ShiftOperatorsDown(); if (this.ExpInfoList.Count == 1) { _query.Root = GetExpressionItem(this.ExpInfoList[0]); _query.Root.LogicalOperator = LogicalOperator.None; } else { var co = ContainsOr(this.ExpInfoList); var root = new Group { LogicalOperator = (co ? LogicalOperator.Or : LogicalOperator.None) }; var current = co ? new Group { LogicalOperator = LogicalOperator.And } : root; foreach (var expInfo in this.ExpInfoList) { switch (expInfo.LogicalOperator) { case LogicalOperator.And: break; case LogicalOperator.Or: //add current and open new block if (current.Items.Count > 1) { root.Items.Add(current); } else { root.Items.Add(current.Items[0]); } current = new Group { LogicalOperator = LogicalOperator.And }; break; } current.Items.Add(GetExpressionItem(expInfo)); } //the last block if (root != current) { if (current.Items.Count > 1) { root.Items.Add(current); } else { root.Items.Add(current.Items[0]); } } _query.Root = root; } } catch (Exception ex) { throw new FieldControlDataException(this, "InvalidQuery", ex.Message); } var xs = new XmlSerializer(typeof(Query)); var sw = new StringWriter(); var xw = new XmlTextWriter(sw); xs.Serialize(xw, _query); var result = sw.ToString(); xw.Close(); var nodeQueryXml = Query.GetNodeQueryXml(result); //this is for validation NodeQuery.Parse(nodeQueryXml); return(result); }