This commit is contained in:
@@ -5,7 +5,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
public static class FilterSpecialToken
|
||||
{
|
||||
|
||||
public const string Null = "{[null]}";
|
||||
public const string Yesterday = "{[yesterday]}";
|
||||
public const string Today = "{[today]}";
|
||||
public const string Tomorrow = "{[tomorrow]}";
|
||||
@@ -30,7 +30,7 @@ namespace AyaNova.Biz
|
||||
public const string FourToSix = "{[46]}";
|
||||
public const string SevenToNine = "{[79]}";
|
||||
public const string LessThanZero = "{[<0]}";
|
||||
// public const string Zero = "{[0]}";
|
||||
// public const string Zero = "{[0]}";
|
||||
public const string GreaterThanZero = "{[>0]}";
|
||||
|
||||
//https://www.klipfolio.com/resources/articles/kpi-timeframe-comparison-metrics
|
||||
@@ -38,7 +38,7 @@ namespace AyaNova.Biz
|
||||
//More business time frames
|
||||
public const string LastQuarter = "{[lastquarter]}";
|
||||
public const string YearToDate = "{[yeartodate]}";
|
||||
public const string QuarterToDate = "{[quartertodate]}";
|
||||
public const string QuarterToDate = "{[quartertodate]}";
|
||||
public const string Past90Days = "{[past90days]}";
|
||||
public const string Past30Days = "{[past30days]}";
|
||||
public const string Past24Hours = "{[past24hours]}";
|
||||
|
||||
@@ -44,28 +44,22 @@ namespace AyaNova.Biz
|
||||
/// </summary>
|
||||
private static string DataFilterToColumnCriteria(string sColumn, string sDataType, string sOperator, string sValue)//, bool IsCompound)
|
||||
{
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
//Column name
|
||||
//sb.Append(" ");
|
||||
sb.Append(sColumn);
|
||||
sb.Append(" ");
|
||||
|
||||
|
||||
|
||||
//handle null values separately
|
||||
|
||||
if (sValue == "")
|
||||
{
|
||||
//strings in grids are rarely null, almost always just an empty string
|
||||
//so filter on that instead
|
||||
//handle null values separately
|
||||
if (sValue == FilterSpecialToken.Null)
|
||||
{
|
||||
switch (sDataType)
|
||||
{
|
||||
case "System.String":
|
||||
case "text":
|
||||
{
|
||||
if (sOperator == "Equals")
|
||||
if (sOperator == FilterComparisonOperator.Equality)
|
||||
{
|
||||
//Changed: 19-July-2006 was missing null values, "almost always' above not good enough!
|
||||
|
||||
sb.Append("Is Null");
|
||||
sb.Append(" OR ");
|
||||
sb.Append(sColumn);
|
||||
@@ -77,7 +71,7 @@ namespace AyaNova.Biz
|
||||
break;
|
||||
default:
|
||||
{
|
||||
if (sOperator == "Equals")
|
||||
if (sOperator == FilterComparisonOperator.Equality)
|
||||
sb.Append("Is Null");
|
||||
else
|
||||
sb.Append("Is Not Null");
|
||||
@@ -100,7 +94,7 @@ namespace AyaNova.Biz
|
||||
// {
|
||||
switch (sOperator)
|
||||
{
|
||||
case "Equals":
|
||||
case FilterComparisonOperator.Equality:
|
||||
//no change on equals for nulls
|
||||
break;
|
||||
case "GreaterThan":
|
||||
@@ -144,14 +138,19 @@ namespace AyaNova.Biz
|
||||
//if this wasn't done
|
||||
//MS-sql and firebird use double apostrophes so
|
||||
//any future db added should consider this
|
||||
sValue = sValue.Replace("'", "''");
|
||||
|
||||
|
||||
//RAVEN - Removed this because I think postgres would be ok with it, it's not a special character
|
||||
//will have a specific test for this to ensure.
|
||||
//https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-SPECIAL-CHARS
|
||||
// sValue = sValue.Replace("'", "''");
|
||||
|
||||
//case 1951 - unescape ampersands
|
||||
sValue = sValue.Replace("&", "&");
|
||||
|
||||
switch (sOperator)
|
||||
{
|
||||
case "Equals":
|
||||
case FilterComparisonOperator.Equality:
|
||||
sb.Append("='");
|
||||
sb.Append(sValue);
|
||||
sb.Append("'");
|
||||
@@ -245,7 +244,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
switch (sOperator)
|
||||
{
|
||||
case "Equals":
|
||||
case FilterComparisonOperator.Equality:
|
||||
sb.Append("= ");
|
||||
if (sValue == "True")
|
||||
sb.Append("1");
|
||||
@@ -673,13 +672,13 @@ namespace AyaNova.Biz
|
||||
|
||||
switch (sOperator)
|
||||
{
|
||||
//case "Equals":
|
||||
//case FilterComparisonOperator.Equality:
|
||||
// sb.Append("='");
|
||||
// sb.Append(sValue);
|
||||
// sb.Append("'");
|
||||
// break;
|
||||
|
||||
case "Equals":
|
||||
case FilterComparisonOperator.Equality:
|
||||
sb.Append(">='");
|
||||
sb.Append(sLowEnd);
|
||||
sb.Append("') AND (");
|
||||
@@ -780,7 +779,7 @@ namespace AyaNova.Biz
|
||||
|
||||
switch (sOperator)
|
||||
{
|
||||
case "Equals":
|
||||
case FilterComparisonOperator.Equality:
|
||||
sb.Append("=");
|
||||
sb.Append(sValue);
|
||||
break;
|
||||
@@ -820,7 +819,7 @@ namespace AyaNova.Biz
|
||||
throw new System.ArgumentOutOfRangeException("DATA_TYPE", sDataType, "GridToSqlCriteria unhandled data type[" + sDataType + "]");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}//end of nonnull path
|
||||
|
||||
//
|
||||
//if(log.IsDebugEnabled)
|
||||
|
||||
Reference in New Issue
Block a user