This commit is contained in:
2020-01-15 17:12:58 +00:00
parent 122d3a93fa
commit 8c574152e8
3 changed files with 46 additions and 46 deletions

View File

@@ -2,21 +2,21 @@ using System.Collections.Generic;
namespace AyaNova.Biz
{
public static class AyDataType
{
//Date and time types, all stored internally as a date and time timestamp, but may display as date only or time only
public const string DateTime = "datetime";
public const string Date = "date";
public const string Time = "time";
public const string Text = "text";
public const string Integer = "int";
public const string Bool = "bool";
public const string Decimal = "decimal";
public const string Currency = "currency";
public const string Tags = "tags";
public const string Enum = "enum";//enums are just integers in the db so the sql code handles it like an int, but the client needs to know it's an enum
}
// public static class AyDataType
// {
// //Date and time types, all stored internally as a date and time timestamp, but may display as date only or time only
// public const string DateTime = "datetime";
// public const string Date = "date";
// public const string Time = "time";
// public const string Text = "text";
// public const string Integer = "int";
// public const string Bool = "bool";
// public const string Decimal = "decimal";
// public const string Currency = "currency";
// public const string Tags = "tags";
// public const string Enum = "enum";//enums are just integers in the db so the sql code handles it like an int, but the client needs to know it's an enum
// }
//DataTypes used to format display properly and for custom fields definition etc
public enum AyaDataType : int
{

View File

@@ -13,28 +13,28 @@ namespace AyaNova.Biz
// - Text
// - Bool
public const string Currency = "currency";
public const string Date = "date";
public const string Time = "time";
public const string DateTime = "datetime";
public const string Text = "text";
public const string Number = "number"; //decimal regardless
public const string Bool = "bool";
// public const string Currency = "currency";
// public const string Date = "date";
// public const string Time = "time";
// public const string DateTime = "datetime";
// public const string Text = "text";
// public const string Number = "number"; //decimal regardless
// public const string Bool = "bool";
public static List<string> ValidCustomFieldTypes
public static List<int> ValidCustomFieldTypes
{
get
{
var ret = new List<string>();
ret.Add(CustomFieldType.Currency);
ret.Add(CustomFieldType.Date);
ret.Add(CustomFieldType.Time);
ret.Add(CustomFieldType.DateTime);
ret.Add(CustomFieldType.Text);
ret.Add(CustomFieldType.Number);
ret.Add(CustomFieldType.Bool);
var ret = new List<int>();
ret.Add((int)AyaDataType.Currency);
ret.Add((int)AyaDataType.Date);
ret.Add((int)AyaDataType.Time);
ret.Add((int)AyaDataType.DateTime);
ret.Add((int)AyaDataType.Text);
ret.Add((int)AyaDataType.Number);
ret.Add((int)AyaDataType.Bool);
return ret;
}
}

View File

@@ -40,7 +40,7 @@ namespace AyaNova.Biz
var dataType = objectFields.Find(x => x.PropertyName.ToLowerInvariant() == fld).DataType;
sb.Append("(");
sb.Append(DataFilterToColumnCriteria(fld, dataType, opType, val, tagList, userId));
sb.Append(DataFilterToColumnCriteria(fld, (AyaDataType)dataType, opType, val, tagList, userId));
if (i < FilterArray.Count - 1)
{
sb.Append(") AND ");
@@ -142,9 +142,9 @@ namespace AyaNova.Biz
}
#region Build for specific type
switch (sDataType)
switch (DataType)
{
case AyDataType.Text:
case AyaDataType.Text:
//escape any pre-existing apostrophes
//i.e. "O'Flaherty's pub"
sValue = sValue.Replace("'", "''");
@@ -243,7 +243,7 @@ namespace AyaNova.Biz
}
#endregion build text ops criteria
break;
case AyDataType.Bool:
case AyaDataType.Bool:
{
switch (sOperator)
{
@@ -271,9 +271,9 @@ namespace AyaNova.Biz
break;
//Note there are three types here for display purposes but all are stored in the db as a timestamp the same with date and time components
case AyDataType.Date:
case AyDataType.DateTime:
case AyDataType.Time:
case AyaDataType.Date:
case AyaDataType.DateTime:
case AyaDataType.Time:
{
//Note: it is assumed all dates come into here from the CLIENT in UTC iso8601 format
//suitable for the database to handle as all database dates are in UTC
@@ -717,16 +717,16 @@ namespace AyaNova.Biz
}
}
break;
case AyDataType.Enum://enums are just ints to the db, but it's a special type so the client can recognize it
case AyDataType.Decimal:
case AyDataType.Integer: //whole numbers, not only integer
case AyaDataType.Enum://enums are just ints to the db, but it's a special type so the client can recognize it
case AyaDataType.Decimal:
case AyaDataType.Integer: //whole numbers, not only integer
{
//case 1795 - it's numeric, convert to locale independant format
//RAVEN NOTE: this code looks suspect to me, but I'll leave it in for now
NumberFormatInfo nfi = System.Globalization.CultureInfo.CurrentCulture.NumberFormat;
switch (sDataType)
switch (DataType)
{
case AyDataType.Decimal:
case AyaDataType.Decimal:
{
if (nfi.CurrencyDecimalSeparator != ".")
{
@@ -735,7 +735,7 @@ namespace AyaNova.Biz
}
}
break;
case AyDataType.Integer:
case AyaDataType.Integer:
{
if (nfi.NumberDecimalSeparator != ".")
{
@@ -781,7 +781,7 @@ namespace AyaNova.Biz
}
break;
}
case AyDataType.Tags:
case AyaDataType.Tags:
{
//Build tags filter fragment
//for initial release a tag filter is inclusive of all tags only
@@ -800,7 +800,7 @@ namespace AyaNova.Biz
}
break;
default:
throw new System.ArgumentOutOfRangeException("DATA_TYPE", sDataType, "GridToSqlCriteria unhandled data type[" + sDataType + "]");
throw new System.ArgumentOutOfRangeException("DATA_TYPE", DataType, "GridToSqlCriteria unhandled data type[" + DataType + "]");
}
#endregion
}//end of nonnull path