/// <summary> /// Create a new APRptFilterDef. /// </summary> /// <param name="serial">Serial of filter.</param> /// <param name="columnId">ID of APRptColumn.</param> /// <param name="comparator">Comparator of filter.</param> /// <param name="values">Values of filter.</param> public APRptFilterDef(string serial, string columnId, APRptFilterComparator comparator, string values) { Serial = serial; ColumnId = columnId; Comparator = comparator; Values = values; }
/// <summary> /// Parse query where phrase. /// </summary> /// <param name="comparator">Comparator.</param> /// <param name="values">Values.</param> /// <returns>An APSqlWherePhrase.</returns> /// <exception cref="APRptFilterParseException">Throw exception on parse error.</exception> public override APSqlWherePhrase ParseQueryWherePhrase(APRptFilterComparator comparator, params string[] values) { if (values.Length == 0) { throw APRptFilterParseException.ValuesCountCannotBeZero(); } if (values.Length > 1) { throw APRptFilterParseException.UnsupportMultiValues(comparator); } if (comparator == APRptFilterComparator.Equals) { return(GetQueryWherePhrase(APSqlConditionOperator.Equals, values[0])); } else if (comparator == APRptFilterComparator.NotEqual) { return(GetQueryWherePhrase(APSqlConditionOperator.NotEqual, values[0])); } throw APRptFilterParseException.UnsupportFilterComparator(GetType(), comparator); }
/// <summary> /// Create a new APRptFilter. /// </summary> /// <param name="column">The column defined</param> /// <param name="comparator">Comparator.</param> /// <param name="values">Values</param> public APRptFilter(APRptColumn column, APRptFilterComparator comparator, params string[] values) { if (values.Length == 0) throw new ArgumentException("values"); _column = column; _comparator = comparator; _values = values; }
/// <summary> /// Create a new APRptFilter. /// </summary> /// <param name="column">The column defined</param> /// <param name="comparator">Comparator.</param> /// <param name="values">Values</param> public APRptFilter(APRptColumn column, APRptFilterComparator comparator, params string[] values) { if (values.Length == 0) { throw new ArgumentException("values"); } _column = column; _comparator = comparator; _values = values; }
/// <summary> /// Parse query where phrase. /// </summary> /// <param name="comparator">Comparator.</param> /// <param name="values">Values.</param> /// <returns>An APSqlWherePhrase.</returns> /// <exception cref="APRptFilterParseException">Throw exception on parse error.</exception> public override APSqlWherePhrase ParseQueryWherePhrase(APRptFilterComparator comparator, params string[] values) { if (values.Length == 0) throw APRptFilterParseException.ValuesCountCannotBeZero(); if (values.Length > 1) throw APRptFilterParseException.UnsupportMultiValues(comparator); if (comparator == APRptFilterComparator.Equals) return GetQueryWherePhrase(APSqlConditionOperator.Equals, values[0]); else if (comparator == APRptFilterComparator.NotEqual) return GetQueryWherePhrase(APSqlConditionOperator.NotEqual, values[0]); throw APRptFilterParseException.UnsupportFilterComparator(GetType(), comparator); }
/// <summary> /// Parse query where phrase. /// Can parse special date value, include:<br/> /// /// <b>YESTERDAY</b><br/> /// Starts at 12:00:00 a.m. on the day before the current day and continues for 24 hours.<br/> /// <b>TODAY</b><br/> /// Starts at 12:00:00 a.m. on the current day and continues for 24 hours.<br/> /// <b>TOMORROW</b><br/> /// Starts at 12:00:00 a.m. on the day after the current day and continues for 24 hours.<br/> /// <b>LAST WEEK</b><br/> /// Starts at 12:00:00 a.m. on the first day of the week before the current week and continues for seven days.<br/> /// <b>THIS WEEK</b><br/> /// Starts at 12:00:00 a.m. on the first day of the current week and continues for seven days.<br/> /// <b>NEXT WEEK</b><br/> /// Starts at 12:00:00 a.m. on the first day of the week after the current week and continues for seven days.<br/> /// <b>LAST MONTH</b><br/> /// Starts at 12:00:00 a.m. on the first day of the month before the current month and continues for all the days of that month.<br/> /// <b>THIS MONTH</b><br/> /// Starts at 12:00:00 a.m. on the first day of the current month and continues for all the days of that month.<br/> /// <b>NEXT MONTH</b><br/> /// Starts at 12:00:00 a.m. on the first day of the month after the current month and continues for all the days of that month.<br/> /// <b>LAST 90 DAYS</b><br/> /// Starts at 12:00:00 a.m. 90 days before the current day and continues up to the current second. (The range includes today.)<br/> /// <b>NEXT 90 DAYS</b><br/> /// Starts at 12:00:00 a.m. on the day after the current day and continues for 90 days. (The range does not include today.)<br/> /// <b>LAST n DAYS</b><br/> /// Starts at 12:00:00 a.m. n days before the current day and continues up to the current second. (The range includes today.)<br/> /// <b>NEXT n DAYS</b><br/> /// Starts at 12:00:00 a.m. on the next day and continues for the next n days. (The range does not include today.)<br/> /// <b>LAST n MONTHS</b><br/> /// Starts at 12:00:00 a.m. on the first day of the month n months ago and continues to the end of the month before the current month. (The range does not include the current month.)<br/> /// <b>NEXT n MONTHS</b><br/> /// Starts at 12:00:00 a.m. on the first day of the month after the current month and continues to the end of the month n months in the future. (The range does not include the current month.)<br/> /// <b>LAST QUARTER</b><br/> /// Starts at 12:00:00 a.m. on the first day of the quarter before the current quarter and continues to the end of that quarter.<br/> /// <b>THIS QUARTER</b><br/> /// Starts at 12:00:00 a.m. on the first day of the current quarter and continues to the end of the quarter.<br/> /// <b>NEXT QUARTER</b><br/> /// Starts at 12:00:00 a.m. on the first day of the quarter after the current quarter and continues to the end of that quarter.<br/> /// <b>LAST n QUARTERS</b><br/> /// Starts at 12:00:00 a.m. on the first day of the quarter n quarters ago and continues to the end of the quarter before the current quarter. (The range does not include the current quarter.)<br/> /// <b>NEXT n QUARTERS</b><br/> /// Starts at 12:00:00 a.m. on the first day of the quarter after the current quarter and continues to the end of the quarter n quarters in the future. (The range does not include the current quarter.)<br/> /// <b>LAST YEAR</b><br/> /// Starts at 12:00:00 a.m. on January 1 of the year before the current year and continues through the end of December 31 of that year.<br/> /// <b>THIS YEAR</b><br/> /// Starts at 12:00:00 a.m. on January 1 of the current year and continues through the end of December 31 of the current year.<br/> /// <b>NEXT YEAR</b><br/> /// Starts at 12:00:00 a.m. on January 1 of the year after the current year and continues through the end of December 31 of that year.<br/> /// <b>LAST n YEARS</b><br/> /// Starts at 12:00:00 a.m. on January 1 of the year n years ago and continues through December 31 of the year before the current year.<br/> /// <b>NEXT n YEARS</b><br/> /// Starts at 12:00:00 a.m. on January 1 of the year after the current year and continues through the end of December 31 of the nth year.<br/> /// </summary> /// <param name="comparator">Comparator.</param> /// <param name="values">Values.</param> /// <returns>An APSqlWherePhrase.</returns> /// <exception cref="APRptFilterParseException">Throw exception on parse error.</exception> public override APSqlWherePhrase ParseQueryWherePhrase(APRptFilterComparator comparator, params string[] values) { if (values.Length == 0) { throw APRptFilterParseException.ValuesCountCannotBeZero(); } APSqlOperateExpr expr = SelectExpr; if (comparator == APRptFilterComparator.Equals) { if (values.Length == 1) { object v = TryGetFilterValue(values[0]); if (v is DateRange) { DateRange dr = (DateRange)v; return(new APSqlConditionPhrase(expr, APSqlConditionOperator.GreaterThanOrEqual, dr.Start) & new APSqlConditionPhrase(expr, APSqlConditionOperator.LessThan, dr.End)); } else if (v is DateTime) { DateTime dt = (DateTime)v; return(new APSqlConditionPhrase(expr, APSqlConditionOperator.Equals, dt)); } throw APRptFilterParseException.InvalidDatetime(); } else { List <APSqlWherePhrase> list = new List <APSqlWherePhrase>(); foreach (string value in values) { object v = TryGetFilterValue(value); if (v is DateTime) { list.Add(new APSqlConditionPhrase(expr, APSqlConditionOperator.Equals, v)); } else if (v is DateRange) { throw APRptFilterParseException.UnsupportSpecialDateValueOrOnlyOne(comparator); } else { throw APRptFilterParseException.InvalidDatetime(); } } return(new APSqlConditionOrPhrase(list)); } } else if (comparator == APRptFilterComparator.NotEqual) { if (values.Length == 1) { object v = TryGetFilterValue(values[0]); if (v is DateRange) { DateRange dr = (DateRange)v; return(new APSqlConditionPhrase(expr, APSqlConditionOperator.LessThan, dr.Start) | new APSqlConditionPhrase(expr, APSqlConditionOperator.GreaterThanOrEqual, dr.End)); } else if (v is DateTime) { DateTime dt = (DateTime)v; return(new APSqlConditionPhrase(expr, APSqlConditionOperator.NotEqual, dt)); } throw APRptFilterParseException.InvalidDatetime(); } else { List <APSqlWherePhrase> list = new List <APSqlWherePhrase>(); foreach (string value in values) { object v = TryGetFilterValue(value); if (v is DateTime) { list.Add(new APSqlConditionPhrase(expr, APSqlConditionOperator.NotEqual, v)); } else if (v is DateRange) { throw APRptFilterParseException.UnsupportSpecialDateValueOrOnlyOne(comparator); } else { throw APRptFilterParseException.InvalidDatetime(); } } return(new APSqlConditionAndPhrase(list)); } } else if (comparator == APRptFilterComparator.LessThan || comparator == APRptFilterComparator.LessOrEqual || comparator == APRptFilterComparator.GreaterThan || comparator == APRptFilterComparator.GreaterOrEqual) { if (values.Length > 1) { throw APRptFilterParseException.UnsupportMultiValues(comparator); } object v = TryGetFilterValue(values[0]); if (v is DateTime) { return(new APSqlConditionPhrase(expr, (APSqlConditionOperator)comparator, v)); } else if (v is DateRange) { throw APRptFilterParseException.UnsupportSpecialDateValueOrOnlyOne(comparator); } else { throw APRptFilterParseException.InvalidDatetime(); } } else if (comparator == APRptFilterComparator.Between) { if (values.Length != 2) { throw APRptFilterParseException.BetweenMustHaveTwoValues(); } object v1 = TryGetFilterValue(values[0]); object v2 = TryGetFilterValue(values[1]); if (v1 == DBNull.Value || v2 == DBNull.Value) { throw APRptFilterParseException.UnsupportDBNull(); } if (v1 is DateRange) { v1 = (v1 as DateRange).Start; } if (v2 is DateRange) { v2 = (v2 as DateRange).Start; } if (v1 is DateTime && v2 is DateTime) { return(new APSqlConditionPhrase(expr, APSqlConditionOperator.Between, new object[2] { v1, v2 })); } throw APRptFilterParseException.InvalidDatetime(); } throw APRptFilterParseException.UnsupportFilterComparator(GetType(), comparator); }
/// <summary> /// Parse query where phrase. /// </summary> /// <param name="comparator">Comparator.</param> /// <param name="values">Values.</param> /// <returns>An APSqlWherePhrase.</returns> /// <exception cref="APRptFilterParseException">Throw exception on parse error.</exception> public abstract APSqlWherePhrase ParseQueryWherePhrase(APRptFilterComparator comparator, params string[] values);
/// <summary> /// Parse query where phrase. /// </summary> /// <param name="comparator">Comparator.</param> /// <param name="values">Values.</param> /// <returns>An APSqlWherePhrase.</returns> /// <exception cref="APRptFilterParseException">Throw exception on parse error.</exception> public override APSqlWherePhrase ParseQueryWherePhrase(APRptFilterComparator comparator, params string[] values) { if (values.Length == 0) { throw APRptFilterParseException.ValuesCountCannotBeZero(); } APSqlOperateExpr expr = SelectExpr; if (comparator == APRptFilterComparator.Equals) { if (values.Length == 1) { return(GetQueryWherePhrase(APSqlConditionOperator.Equals, values[0])); } // Change operator to 'IN' return(new APSqlConditionPhrase(expr, APSqlConditionOperator.In, GetFilterValues(values))); } else if (comparator == APRptFilterComparator.NotEqual) { if (values.Length == 1) { return(GetQueryWherePhrase(APSqlConditionOperator.NotEqual, values[0])); } // Change operator to 'NOT IN' return(new APSqlConditionPhrase(expr, APSqlConditionOperator.NotIn, GetFilterValues(values))); } else if (comparator == APRptFilterComparator.LessThan || comparator == APRptFilterComparator.LessOrEqual || comparator == APRptFilterComparator.GreaterThan || comparator == APRptFilterComparator.GreaterOrEqual) { if (values.Length > 1) { throw APRptFilterParseException.UnsupportMultiValues(comparator); } return(GetQueryWherePhrase((APSqlConditionOperator)comparator, values[0])); } // todo: here use APDatabase.Provider.Wildcard, when multi-providers may by error wildcard char. else if (comparator == APRptFilterComparator.StartsWith) { if (values.Length == 1) { object v = TryGetFilterValue(values[0]); if (v == DBNull.Value) { throw APRptFilterParseException.UnsupportDBNull(); } string likeString = (v as String) + APDalProvider.Wildcard; return(new APSqlConditionPhrase(expr, APSqlConditionOperator.Like, likeString)); } List <APSqlWherePhrase> list = new List <APSqlWherePhrase>(); foreach (string s in values) { object v = TryGetFilterValue(s); if (v == DBNull.Value) { throw APRptFilterParseException.UnsupportDBNull(); } string likeString = (v as String) + APDalProvider.Wildcard; list.Add(new APSqlConditionPhrase(expr, APSqlConditionOperator.Like, likeString)); } return(new APSqlConditionOrPhrase(list)); } else if (comparator == APRptFilterComparator.Contains || comparator == APRptFilterComparator.DoesNotContain) { if (values.Length == 1) { object v = TryGetFilterValue(values[0]); if (v == DBNull.Value) { throw APRptFilterParseException.UnsupportDBNull(); } string likeString = APDalProvider.Wildcard + (v as String) + APDalProvider.Wildcard; if (comparator == APRptFilterComparator.Contains) { return(new APSqlConditionPhrase(expr, APSqlConditionOperator.Like, likeString)); } else { return(new APSqlConditionPhrase(expr, APSqlConditionOperator.NotLike, likeString)); } } List <APSqlWherePhrase> list = new List <APSqlWherePhrase>(); foreach (string s in values) { object v = TryGetFilterValue(s); if (v == DBNull.Value) { throw APRptFilterParseException.UnsupportDBNull(); } string likeString = APDalProvider.Wildcard + (v as String) + APDalProvider.Wildcard; list.Add(new APSqlConditionPhrase(expr, APSqlConditionOperator.NotLike, likeString)); } if (comparator == APRptFilterComparator.Contains) { return(new APSqlConditionOrPhrase(list)); } return(!new APSqlConditionOrPhrase(list)); } throw APRptFilterParseException.UnsupportFilterComparator(GetType(), comparator); }
/// <summary> /// Parse query where phrase. /// Can parse special date value, include:<br/> /// /// <b>YESTERDAY</b><br/> /// Starts at 12:00:00 a.m. on the day before the current day and continues for 24 hours.<br/> /// <b>TODAY</b><br/> /// Starts at 12:00:00 a.m. on the current day and continues for 24 hours.<br/> /// <b>TOMORROW</b><br/> /// Starts at 12:00:00 a.m. on the day after the current day and continues for 24 hours.<br/> /// <b>LAST WEEK</b><br/> /// Starts at 12:00:00 a.m. on the first day of the week before the current week and continues for seven days.<br/> /// <b>THIS WEEK</b><br/> /// Starts at 12:00:00 a.m. on the first day of the current week and continues for seven days.<br/> /// <b>NEXT WEEK</b><br/> /// Starts at 12:00:00 a.m. on the first day of the week after the current week and continues for seven days.<br/> /// <b>LAST MONTH</b><br/> /// Starts at 12:00:00 a.m. on the first day of the month before the current month and continues for all the days of that month.<br/> /// <b>THIS MONTH</b><br/> /// Starts at 12:00:00 a.m. on the first day of the current month and continues for all the days of that month.<br/> /// <b>NEXT MONTH</b><br/> /// Starts at 12:00:00 a.m. on the first day of the month after the current month and continues for all the days of that month.<br/> /// <b>LAST 90 DAYS</b><br/> /// Starts at 12:00:00 a.m. 90 days before the current day and continues up to the current second. (The range includes today.)<br/> /// <b>NEXT 90 DAYS</b><br/> /// Starts at 12:00:00 a.m. on the day after the current day and continues for 90 days. (The range does not include today.)<br/> /// <b>LAST n DAYS</b><br/> /// Starts at 12:00:00 a.m. n days before the current day and continues up to the current second. (The range includes today.)<br/> /// <b>NEXT n DAYS</b><br/> /// Starts at 12:00:00 a.m. on the next day and continues for the next n days. (The range does not include today.)<br/> /// <b>LAST n MONTHS</b><br/> /// Starts at 12:00:00 a.m. on the first day of the month n months ago and continues to the end of the month before the current month. (The range does not include the current month.)<br/> /// <b>NEXT n MONTHS</b><br/> /// Starts at 12:00:00 a.m. on the first day of the month after the current month and continues to the end of the month n months in the future. (The range does not include the current month.)<br/> /// <b>LAST QUARTER</b><br/> /// Starts at 12:00:00 a.m. on the first day of the quarter before the current quarter and continues to the end of that quarter.<br/> /// <b>THIS QUARTER</b><br/> /// Starts at 12:00:00 a.m. on the first day of the current quarter and continues to the end of the quarter.<br/> /// <b>NEXT QUARTER</b><br/> /// Starts at 12:00:00 a.m. on the first day of the quarter after the current quarter and continues to the end of that quarter.<br/> /// <b>LAST n QUARTERS</b><br/> /// Starts at 12:00:00 a.m. on the first day of the quarter n quarters ago and continues to the end of the quarter before the current quarter. (The range does not include the current quarter.)<br/> /// <b>NEXT n QUARTERS</b><br/> /// Starts at 12:00:00 a.m. on the first day of the quarter after the current quarter and continues to the end of the quarter n quarters in the future. (The range does not include the current quarter.)<br/> /// <b>LAST YEAR</b><br/> /// Starts at 12:00:00 a.m. on January 1 of the year before the current year and continues through the end of December 31 of that year.<br/> /// <b>THIS YEAR</b><br/> /// Starts at 12:00:00 a.m. on January 1 of the current year and continues through the end of December 31 of the current year.<br/> /// <b>NEXT YEAR</b><br/> /// Starts at 12:00:00 a.m. on January 1 of the year after the current year and continues through the end of December 31 of that year.<br/> /// <b>LAST n YEARS</b><br/> /// Starts at 12:00:00 a.m. on January 1 of the year n years ago and continues through December 31 of the year before the current year.<br/> /// <b>NEXT n YEARS</b><br/> /// Starts at 12:00:00 a.m. on January 1 of the year after the current year and continues through the end of December 31 of the nth year.<br/> /// </summary> /// <param name="comparator">Comparator.</param> /// <param name="values">Values.</param> /// <returns>An APSqlWherePhrase.</returns> /// <exception cref="APRptFilterParseException">Throw exception on parse error.</exception> public override APSqlWherePhrase ParseQueryWherePhrase(APRptFilterComparator comparator, params string[] values) { if (values.Length == 0) throw APRptFilterParseException.ValuesCountCannotBeZero(); APSqlOperateExpr expr = SelectExpr; if (comparator == APRptFilterComparator.Equals) { if (values.Length == 1) { object v = TryGetFilterValue(values[0]); if (v is DateRange) { DateRange dr = (DateRange)v; return new APSqlConditionPhrase(expr, APSqlConditionOperator.GreaterThanOrEqual, dr.Start) & new APSqlConditionPhrase(expr, APSqlConditionOperator.LessThan, dr.End); } else if (v is DateTime) { DateTime dt = (DateTime)v; return new APSqlConditionPhrase(expr, APSqlConditionOperator.Equals, dt); } throw APRptFilterParseException.InvalidDatetime(); } else { List<APSqlWherePhrase> list = new List<APSqlWherePhrase>(); foreach (string value in values) { object v = TryGetFilterValue(value); if (v is DateTime) list.Add(new APSqlConditionPhrase(expr, APSqlConditionOperator.Equals, v)); else if (v is DateRange) throw APRptFilterParseException.UnsupportSpecialDateValueOrOnlyOne(comparator); else throw APRptFilterParseException.InvalidDatetime(); } return new APSqlConditionOrPhrase(list); } } else if (comparator == APRptFilterComparator.NotEqual) { if (values.Length == 1) { object v = TryGetFilterValue(values[0]); if (v is DateRange) { DateRange dr = (DateRange)v; return new APSqlConditionPhrase(expr, APSqlConditionOperator.LessThan, dr.Start) | new APSqlConditionPhrase(expr, APSqlConditionOperator.GreaterThanOrEqual, dr.End); } else if (v is DateTime) { DateTime dt = (DateTime)v; return new APSqlConditionPhrase(expr, APSqlConditionOperator.NotEqual, dt); } throw APRptFilterParseException.InvalidDatetime(); } else { List<APSqlWherePhrase> list = new List<APSqlWherePhrase>(); foreach (string value in values) { object v = TryGetFilterValue(value); if (v is DateTime) list.Add(new APSqlConditionPhrase(expr, APSqlConditionOperator.NotEqual, v)); else if (v is DateRange) throw APRptFilterParseException.UnsupportSpecialDateValueOrOnlyOne(comparator); else throw APRptFilterParseException.InvalidDatetime(); } return new APSqlConditionAndPhrase(list); } } else if (comparator == APRptFilterComparator.LessThan || comparator == APRptFilterComparator.LessOrEqual || comparator == APRptFilterComparator.GreaterThan || comparator == APRptFilterComparator.GreaterOrEqual) { if (values.Length > 1) throw APRptFilterParseException.UnsupportMultiValues(comparator); object v = TryGetFilterValue(values[0]); if (v is DateTime) return new APSqlConditionPhrase(expr, (APSqlConditionOperator)comparator, v); else if (v is DateRange) throw APRptFilterParseException.UnsupportSpecialDateValueOrOnlyOne(comparator); else throw APRptFilterParseException.InvalidDatetime(); } else if (comparator == APRptFilterComparator.Between) { if (values.Length != 2) throw APRptFilterParseException.BetweenMustHaveTwoValues(); object v1 = TryGetFilterValue(values[0]); object v2 = TryGetFilterValue(values[1]); if (v1 == DBNull.Value || v2 == DBNull.Value) throw APRptFilterParseException.UnsupportDBNull(); if (v1 is DateRange) v1 = (v1 as DateRange).Start; if (v2 is DateRange) v2 = (v2 as DateRange).Start; if (v1 is DateTime && v2 is DateTime) return new APSqlConditionPhrase(expr, APSqlConditionOperator.Between, new object[2] { v1, v2 }); throw APRptFilterParseException.InvalidDatetime(); } throw APRptFilterParseException.UnsupportFilterComparator(GetType(), comparator); }
/// <summary> /// Parse query where phrase. /// </summary> /// <param name="comparator">Comparator.</param> /// <param name="values">Values.</param> /// <returns>An APSqlWherePhrase.</returns> /// <exception cref="APRptFilterParseException">Throw exception on parse error.</exception> public override APSqlWherePhrase ParseQueryWherePhrase(APRptFilterComparator comparator, params string[] values) { return(_relationShowColumn.ParseQueryWherePhrase(comparator, values)); }
/// <summary> /// Gets a APRptFilterParseException by UnsupportMultiValues. /// </summary> /// <param name="comparator">Comparator.</param> /// <returns>APRptFilterParseException.</returns> public static APRptFilterParseException UnsupportMultiValues(APRptFilterComparator comparator) { return(new APRptFilterParseException(APResource.GetString(APResource.APRptFilter_UnsupportMultiValues, comparator))); }
/// <summary> /// Parse query where phrase. /// </summary> /// <param name="comparator">Comparator.</param> /// <param name="values">Values.</param> /// <returns>An APSqlWherePhrase.</returns> /// <exception cref="APRptFilterParseException">Throw exception on parse error.</exception> public override APSqlWherePhrase ParseQueryWherePhrase(APRptFilterComparator comparator, params string[] values) { if (values.Length == 0) { throw APRptFilterParseException.ValuesCountCannotBeZero(); } APSqlOperateExpr expr = SelectExpr; if (comparator == APRptFilterComparator.Equals) { if (values.Length == 1) { return(GetQueryWherePhrase(APSqlConditionOperator.Equals, values[0])); } // Change operator to 'IN' return(new APSqlConditionPhrase(expr, APSqlConditionOperator.In, GetFilterValues(values))); } else if (comparator == APRptFilterComparator.NotEqual) { if (values.Length == 1) { return(GetQueryWherePhrase(APSqlConditionOperator.NotEqual, values[0])); } // Change operator to 'NOT IN' return(new APSqlConditionPhrase(expr, APSqlConditionOperator.NotIn, GetFilterValues(values))); } else if (comparator == APRptFilterComparator.LessThan || comparator == APRptFilterComparator.LessOrEqual || comparator == APRptFilterComparator.GreaterThan || comparator == APRptFilterComparator.GreaterOrEqual) { if (values.Length > 1) { throw APRptFilterParseException.UnsupportMultiValues(comparator); } return(GetQueryWherePhrase((APSqlConditionOperator)comparator, values[0])); } else if (comparator == APRptFilterComparator.Between) { if (values.Length != 2) { throw APRptFilterParseException.BetweenMustHaveTwoValues(); } object v1 = TryGetFilterValue(values[0]); object v2 = TryGetFilterValue(values[1]); if (v1 == DBNull.Value || v2 == DBNull.Value) { throw APRptFilterParseException.UnsupportDBNull(); } return(new APSqlConditionPhrase(expr, APSqlConditionOperator.Between, new object[2] { v1, v2 })); } throw APRptFilterParseException.UnsupportFilterComparator(GetType(), comparator); }
/// <summary> /// Gets a APRptFilterParseException by UnsupportMultiValues. /// </summary> /// <param name="comparator">Comparator.</param> /// <returns>APRptFilterParseException.</returns> public static APRptFilterParseException UnsupportMultiValues(APRptFilterComparator comparator) { return new APRptFilterParseException(APResource.GetString(APResource.APRptFilter_UnsupportMultiValues, comparator)); }
public override APSqlWherePhrase ParseQueryWherePhrase(APRptFilterComparator comparator, params string[] values) { throw new NotImplementedException(); }
/// <summary> /// Gets a APRptFilterParseException by UnsupportSpecialDateValueOrOnlyOne. /// </summary> /// <param name="comparator">Comparator.</param> /// <returns>APRptFilterParseException.</returns> public static APRptFilterParseException UnsupportSpecialDateValueOrOnlyOne(APRptFilterComparator comparator) { return(new APRptFilterParseException(APResource.GetString(APResource.APRptFilter_UnsupportSpecialDateValueOrOnlyOne, comparator))); }
/// <summary> /// Gets a APRptFilterParseException by UnsupportFilterComparator. /// </summary> /// <param name="columnType">The column type.</param> /// <param name="comparator">Comparator.</param> /// <returns>APRptFilterParseException.</returns> public static APRptFilterParseException UnsupportFilterComparator(Type columnType, APRptFilterComparator comparator) { return new APRptFilterParseException(APResource.GetString(APResource.APRptFilter_UnsupportComparator, columnType, comparator)); }
/// <summary> /// Parse query where phrase. /// </summary> /// <param name="comparator">Comparator.</param> /// <param name="values">Values.</param> /// <returns>An APSqlWherePhrase.</returns> /// <exception cref="APRptFilterParseException">Throw exception on parse error.</exception> public override APSqlWherePhrase ParseQueryWherePhrase(APRptFilterComparator comparator, params string[] values) { return _relationShowColumn.ParseQueryWherePhrase(comparator, values); }
/// <summary> /// Gets a APRptFilterParseException by UnsupportSpecialDateValueOrOnlyOne. /// </summary> /// <param name="comparator">Comparator.</param> /// <returns>APRptFilterParseException.</returns> public static APRptFilterParseException UnsupportSpecialDateValueOrOnlyOne(APRptFilterComparator comparator) { return new APRptFilterParseException(APResource.GetString(APResource.APRptFilter_UnsupportSpecialDateValueOrOnlyOne, comparator)); }
/// <summary> /// Parse query where phrase. /// </summary> /// <param name="comparator">Comparator.</param> /// <param name="values">Values.</param> /// <returns>An APSqlWherePhrase.</returns> /// <exception cref="APRptFilterParseException">Throw exception on parse error.</exception> public override APSqlWherePhrase ParseQueryWherePhrase(APRptFilterComparator comparator, params string[] values) { if (values.Length == 0) throw APRptFilterParseException.ValuesCountCannotBeZero(); APSqlOperateExpr expr = SelectExpr; if (comparator == APRptFilterComparator.Equals) { if (values.Length == 1) return GetQueryWherePhrase(APSqlConditionOperator.Equals, values[0]); // Change operator to 'IN' return new APSqlConditionPhrase(expr, APSqlConditionOperator.In, GetFilterValues(values)); } else if (comparator == APRptFilterComparator.NotEqual) { if (values.Length == 1) return GetQueryWherePhrase(APSqlConditionOperator.NotEqual, values[0]); // Change operator to 'NOT IN' return new APSqlConditionPhrase(expr, APSqlConditionOperator.NotIn, GetFilterValues(values)); } else if (comparator == APRptFilterComparator.LessThan || comparator == APRptFilterComparator.LessOrEqual || comparator == APRptFilterComparator.GreaterThan || comparator == APRptFilterComparator.GreaterOrEqual) { if (values.Length > 1) throw APRptFilterParseException.UnsupportMultiValues(comparator); return GetQueryWherePhrase((APSqlConditionOperator)comparator, values[0]); } // todo: here use APDatabase.Provider.Wildcard, when multi-providers may by error wildcard char. else if (comparator == APRptFilterComparator.StartsWith) { if (values.Length == 1) { object v = TryGetFilterValue(values[0]); if (v == DBNull.Value) throw APRptFilterParseException.UnsupportDBNull(); string likeString = (v as String) + APDalProvider.Wildcard; return new APSqlConditionPhrase(expr, APSqlConditionOperator.Like, likeString); } List<APSqlWherePhrase> list = new List<APSqlWherePhrase>(); foreach (string s in values) { object v = TryGetFilterValue(s); if (v == DBNull.Value) throw APRptFilterParseException.UnsupportDBNull(); string likeString = (v as String) + APDalProvider.Wildcard; list.Add(new APSqlConditionPhrase(expr, APSqlConditionOperator.Like, likeString)); } return new APSqlConditionOrPhrase(list); } else if (comparator == APRptFilterComparator.Contains || comparator == APRptFilterComparator.DoesNotContain) { if (values.Length == 1) { object v = TryGetFilterValue(values[0]); if (v == DBNull.Value) throw APRptFilterParseException.UnsupportDBNull(); string likeString = APDalProvider.Wildcard + (v as String) + APDalProvider.Wildcard; if (comparator == APRptFilterComparator.Contains) return new APSqlConditionPhrase(expr, APSqlConditionOperator.Like, likeString); else return new APSqlConditionPhrase(expr, APSqlConditionOperator.NotLike, likeString); } List<APSqlWherePhrase> list = new List<APSqlWherePhrase>(); foreach (string s in values) { object v = TryGetFilterValue(s); if (v == DBNull.Value) throw APRptFilterParseException.UnsupportDBNull(); string likeString = APDalProvider.Wildcard + (v as String) + APDalProvider.Wildcard; list.Add(new APSqlConditionPhrase(expr, APSqlConditionOperator.NotLike, likeString)); } if (comparator == APRptFilterComparator.Contains) return new APSqlConditionOrPhrase(list); return !new APSqlConditionOrPhrase(list); } throw APRptFilterParseException.UnsupportFilterComparator(GetType(), comparator); }
/// <summary> /// Parse query where phrase. /// </summary> /// <param name="comparator">Comparator.</param> /// <param name="values">Values.</param> /// <returns>An APSqlWherePhrase.</returns> /// <exception cref="APRptFilterParseException">Throw exception on parse error.</exception> public override APSqlWherePhrase ParseQueryWherePhrase(APRptFilterComparator comparator, params string[] values) { if (values.Length == 0) throw APRptFilterParseException.ValuesCountCannotBeZero(); APSqlOperateExpr expr = SelectExpr; if (comparator == APRptFilterComparator.Equals) { if (values.Length == 1) return GetQueryWherePhrase(APSqlConditionOperator.Equals, values[0]); // Change operator to 'IN' return new APSqlConditionPhrase(expr, APSqlConditionOperator.In, GetFilterValues(values)); } else if (comparator == APRptFilterComparator.NotEqual) { if (values.Length == 1) return GetQueryWherePhrase(APSqlConditionOperator.NotEqual, values[0]); // Change operator to 'NOT IN' return new APSqlConditionPhrase(expr, APSqlConditionOperator.NotIn, GetFilterValues(values)); } else if (comparator == APRptFilterComparator.LessThan || comparator == APRptFilterComparator.LessOrEqual || comparator == APRptFilterComparator.GreaterThan || comparator == APRptFilterComparator.GreaterOrEqual) { if (values.Length > 1) throw APRptFilterParseException.UnsupportMultiValues(comparator); return GetQueryWherePhrase((APSqlConditionOperator)comparator, values[0]); } else if (comparator == APRptFilterComparator.Between) { if (values.Length != 2) throw APRptFilterParseException.BetweenMustHaveTwoValues(); object v1 = TryGetFilterValue(values[0]); object v2 = TryGetFilterValue(values[1]); if (v1 == DBNull.Value || v2 == DBNull.Value) throw APRptFilterParseException.UnsupportDBNull(); return new APSqlConditionPhrase(expr, APSqlConditionOperator.Between, new object[2] { v1, v2 }); } throw APRptFilterParseException.UnsupportFilterComparator(GetType(), comparator); }
/// <summary> /// Gets a APRptFilterParseException by UnsupportFilterComparator. /// </summary> /// <param name="columnType">The column type.</param> /// <param name="comparator">Comparator.</param> /// <returns>APRptFilterParseException.</returns> public static APRptFilterParseException UnsupportFilterComparator(Type columnType, APRptFilterComparator comparator) { return(new APRptFilterParseException(APResource.GetString(APResource.APRptFilter_UnsupportComparator, columnType, comparator))); }