bool _FilterOperatorSingleRow; // false for Top/Bottom N and Percent; otherwise true public Filter(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p) { _FilterExpression = null; _FilterOperator = FilterOperatorEnum.Unknown; _FilterValues = null; // Loop thru all the child nodes foreach (XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) { continue; } switch (xNodeLoop.Name) { case "FilterExpression": _FilterExpression = new Expression(r, this, xNodeLoop, ExpressionType.Variant); break; case "Operator": _FilterOperator = Oranikle.Report.Engine.FilterOperator.GetStyle(xNodeLoop.InnerText); if (_FilterOperator == FilterOperatorEnum.Unknown) { OwnerReport.rl.LogError(8, "Unknown Filter operator '" + xNodeLoop.InnerText + "'."); } break; case "FilterValues": _FilterValues = new FilterValues(r, this, xNodeLoop); break; default: // don't know this element - log it OwnerReport.rl.LogError(4, "Unknown Filter element '" + xNodeLoop.Name + "' ignored."); break; } } if (_FilterExpression == null) { OwnerReport.rl.LogError(8, "Filter requires the FilterExpression element."); } if (_FilterValues == null) { OwnerReport.rl.LogError(8, "Filter requires the FilterValues element."); return; // some of the filter operator checks require values } _FilterOperatorSingleRow = true; switch (_FilterOperator) { case FilterOperatorEnum.Like: case FilterOperatorEnum.Equal: case FilterOperatorEnum.NotEqual: case FilterOperatorEnum.GreaterThan: case FilterOperatorEnum.GreaterThanOrEqual: case FilterOperatorEnum.LessThan: case FilterOperatorEnum.LessThanOrEqual: if (_FilterValues.Items.Count != 1) { OwnerReport.rl.LogError(8, "Filter Operator requires exactly 1 FilterValue."); } break; case FilterOperatorEnum.TopN: case FilterOperatorEnum.BottomN: case FilterOperatorEnum.TopPercent: case FilterOperatorEnum.BottomPercent: _FilterOperatorSingleRow = false; if (_FilterValues.Items.Count != 1) { OwnerReport.rl.LogError(8, "Filter Operator requires exactly 1 FilterValue."); } break; case FilterOperatorEnum.In: break; case FilterOperatorEnum.Between: if (_FilterValues.Items.Count != 2) { OwnerReport.rl.LogError(8, "Filter Operator Between requires exactly 2 FilterValues."); } break; default: OwnerReport.rl.LogError(8, "Valid Filter operator must be specified."); break; } }
bool _FilterOperatorSingleRow; // false for Top/Bottom N and Percent; otherwise true public Filter(ReportDefn r, ReportLink p, XmlNode xNode) : base(r, p) { _FilterExpression=null; _FilterOperator=FilterOperatorEnum.Unknown; _FilterValues=null; // Loop thru all the child nodes foreach(XmlNode xNodeLoop in xNode.ChildNodes) { if (xNodeLoop.NodeType != XmlNodeType.Element) continue; switch (xNodeLoop.Name) { case "FilterExpression": _FilterExpression = new Expression(r, this, xNodeLoop, ExpressionType.Variant); break; case "Operator": _FilterOperator = Oranikle.Report.Engine.FilterOperator.GetStyle(xNodeLoop.InnerText); if (_FilterOperator == FilterOperatorEnum.Unknown) OwnerReport.rl.LogError(8, "Unknown Filter operator '" + xNodeLoop.InnerText + "'."); break; case "FilterValues": _FilterValues = new FilterValues(r, this, xNodeLoop); break; default: // don't know this element - log it OwnerReport.rl.LogError(4, "Unknown Filter element '" + xNodeLoop.Name + "' ignored."); break; } } if (_FilterExpression == null) OwnerReport.rl.LogError(8, "Filter requires the FilterExpression element."); if (_FilterValues == null) { OwnerReport.rl.LogError(8, "Filter requires the FilterValues element."); return; // some of the filter operator checks require values } _FilterOperatorSingleRow = true; switch (_FilterOperator) { case FilterOperatorEnum.Like: case FilterOperatorEnum.Equal: case FilterOperatorEnum.NotEqual: case FilterOperatorEnum.GreaterThan: case FilterOperatorEnum.GreaterThanOrEqual: case FilterOperatorEnum.LessThan: case FilterOperatorEnum.LessThanOrEqual: if (_FilterValues.Items.Count != 1) OwnerReport.rl.LogError(8, "Filter Operator requires exactly 1 FilterValue."); break; case FilterOperatorEnum.TopN: case FilterOperatorEnum.BottomN: case FilterOperatorEnum.TopPercent: case FilterOperatorEnum.BottomPercent: _FilterOperatorSingleRow = false; if (_FilterValues.Items.Count != 1) OwnerReport.rl.LogError(8, "Filter Operator requires exactly 1 FilterValue."); break; case FilterOperatorEnum.In: break; case FilterOperatorEnum.Between: if (_FilterValues.Items.Count != 2) OwnerReport.rl.LogError(8, "Filter Operator Between requires exactly 2 FilterValues."); break; default: OwnerReport.rl.LogError(8, "Valid Filter operator must be specified."); break; } }