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