This commit is contained in:
2020-01-20 18:30:25 +00:00
parent b2d2f0f108
commit b20d81e5cf
9 changed files with 89 additions and 70 deletions

View File

@@ -0,0 +1,15 @@
using System.Linq;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using System.Text;
using Newtonsoft.Json;
namespace AyaNova.Biz
{
public class AyaFieldData
{
public object v { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
public long? Id { get; set; }
}
}

View File

@@ -42,7 +42,7 @@ namespace AyaNova.Biz
return AvailableObjectKeys.Contains(key);
}
public static List<AyaField> ObjectFieldsList(string key)
public static List<AyaFieldDefinition> ObjectFieldsList(string key)
{
/*
***************************** WARNING: Be careful here, if a standard field is hideable and also it's DB SCHEMA is set to NON NULLABLE then the CLIENT end needs to set a default
@@ -55,7 +55,7 @@ namespace AyaNova.Biz
Sortable = true;
MiniAvailable = true;
*/
List<AyaField> l = new List<AyaField>();
List<AyaFieldDefinition> l = new List<AyaFieldDefinition>();
switch (key)
{
/*
@@ -157,73 +157,73 @@ namespace AyaNova.Biz
//first column is the non visible Default Id column so that the client knows what to open when there is no field with ID selected that matches underlying record type
//in this case the default of id is sufficient for this list
l.Add(new AyaField { LtKey = "df", AyaObjectType = (int)AyaType.Widget });
l.Add(new AyaField { LtKey = "WidgetName", FieldKey = "Name", UiFieldDataType = (int)AyaUiFieldDataType.Text, Hideable = false });
l.Add(new AyaField { LtKey = "WidgetSerial", FieldKey = "Serial", UiFieldDataType = (int)AyaUiFieldDataType.Integer });
l.Add(new AyaField { LtKey = "WidgetDollarAmount", FieldKey = "DollarAmount", UiFieldDataType = (int)AyaUiFieldDataType.Currency });
l.Add(new AyaField { LtKey = "WidgetCount", FieldKey = "Count", UiFieldDataType = (int)AyaUiFieldDataType.Integer });
l.Add(new AyaField { LtKey = "WidgetRoles", FieldKey = "Roles", UiFieldDataType = (int)AyaUiFieldDataType.Enum, EnumType = typeof(AuthorizationRoles).ToString() });
l.Add(new AyaField { LtKey = "WidgetStartDate", FieldKey = "StartDate", UiFieldDataType = (int)AyaUiFieldDataType.DateTime });
l.Add(new AyaField { LtKey = "WidgetEndDate", FieldKey = "EndDate", UiFieldDataType = (int)AyaUiFieldDataType.DateTime });
l.Add(new AyaField { LtKey = "WidgetNotes", FieldKey = "Notes", UiFieldDataType = (int)AyaUiFieldDataType.Text });
l.Add(new AyaFieldDefinition { LtKey = "df", AyaObjectType = (int)AyaType.Widget });
l.Add(new AyaFieldDefinition { LtKey = "WidgetName", FieldKey = "Name", UiFieldDataType = (int)AyaUiFieldDataType.Text, Hideable = false });
l.Add(new AyaFieldDefinition { LtKey = "WidgetSerial", FieldKey = "Serial", UiFieldDataType = (int)AyaUiFieldDataType.Integer });
l.Add(new AyaFieldDefinition { LtKey = "WidgetDollarAmount", FieldKey = "DollarAmount", UiFieldDataType = (int)AyaUiFieldDataType.Currency });
l.Add(new AyaFieldDefinition { LtKey = "WidgetCount", FieldKey = "Count", UiFieldDataType = (int)AyaUiFieldDataType.Integer });
l.Add(new AyaFieldDefinition { LtKey = "WidgetRoles", FieldKey = "Roles", UiFieldDataType = (int)AyaUiFieldDataType.Enum, EnumType = typeof(AuthorizationRoles).ToString() });
l.Add(new AyaFieldDefinition { LtKey = "WidgetStartDate", FieldKey = "StartDate", UiFieldDataType = (int)AyaUiFieldDataType.DateTime });
l.Add(new AyaFieldDefinition { LtKey = "WidgetEndDate", FieldKey = "EndDate", UiFieldDataType = (int)AyaUiFieldDataType.DateTime });
l.Add(new AyaFieldDefinition { LtKey = "WidgetNotes", FieldKey = "Notes", UiFieldDataType = (int)AyaUiFieldDataType.Text });
//More to do on this, maybe the datatype should be a LINK or something for UI purposes
//circle back on this when there is enough infrastructure to test
l.Add(new AyaField { LtKey = "User", FieldKey = "userid", UiFieldDataType = (int)AyaUiFieldDataType.Text, AyaObjectType = (int)AyaType.User });
l.Add(new AyaField { LtKey = "Active", FieldKey = "Active", UiFieldDataType = (int)AyaUiFieldDataType.Bool, Hideable = false });
l.Add(new AyaField { LtKey = "Tags", FieldKey = "Tags", UiFieldDataType = (int)AyaUiFieldDataType.Tags });
l.Add(new AyaFieldDefinition { LtKey = "User", FieldKey = "userid", UiFieldDataType = (int)AyaUiFieldDataType.Text, AyaObjectType = (int)AyaType.User });
l.Add(new AyaFieldDefinition { LtKey = "Active", FieldKey = "Active", UiFieldDataType = (int)AyaUiFieldDataType.Bool, Hideable = false });
l.Add(new AyaFieldDefinition { LtKey = "Tags", FieldKey = "Tags", UiFieldDataType = (int)AyaUiFieldDataType.Tags });
l.Add(new AyaField { LtKey = "WidgetCustom1", FieldKey = "WidgetCustom1", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom2", FieldKey = "WidgetCustom2", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom3", FieldKey = "WidgetCustom3", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom4", FieldKey = "WidgetCustom4", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom5", FieldKey = "WidgetCustom5", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom6", FieldKey = "WidgetCustom6", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom7", FieldKey = "WidgetCustom7", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom8", FieldKey = "WidgetCustom8", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom9", FieldKey = "WidgetCustom9", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom10", FieldKey = "WidgetCustom10", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom11", FieldKey = "WidgetCustom11", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom12", FieldKey = "WidgetCustom12", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom13", FieldKey = "WidgetCustom13", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom14", FieldKey = "WidgetCustom14", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom15", FieldKey = "WidgetCustom15", IsCustomField = true });
l.Add(new AyaField { LtKey = "WidgetCustom16", FieldKey = "WidgetCustom16", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "WidgetCustom1", FieldKey = "WidgetCustom1", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "WidgetCustom2", FieldKey = "WidgetCustom2", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "WidgetCustom3", FieldKey = "WidgetCustom3", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "WidgetCustom4", FieldKey = "WidgetCustom4", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "WidgetCustom5", FieldKey = "WidgetCustom5", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "WidgetCustom6", FieldKey = "WidgetCustom6", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "WidgetCustom7", FieldKey = "WidgetCustom7", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "WidgetCustom8", FieldKey = "WidgetCustom8", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "WidgetCustom9", FieldKey = "WidgetCustom9", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "WidgetCustom10", FieldKey = "WidgetCustom10", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "WidgetCustom11", FieldKey = "WidgetCustom11", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "WidgetCustom12", FieldKey = "WidgetCustom12", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "WidgetCustom13", FieldKey = "WidgetCustom13", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "WidgetCustom14", FieldKey = "WidgetCustom14", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "WidgetCustom15", FieldKey = "WidgetCustom15", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "WidgetCustom16", FieldKey = "WidgetCustom16", IsCustomField = true });
break;
#endregion
case USER_KEY:
#region USER_KEY
l.Add(new AyaField { LtKey = "df", AyaObjectType = (int)AyaType.User });
l.Add(new AyaField { LtKey = "Name", FieldKey = "Name", UiFieldDataType = (int)AyaUiFieldDataType.Text, Hideable = false });
l.Add(new AyaField { LtKey = "UserEmployeeNumber", FieldKey = "EmployeeNumber", UiFieldDataType = (int)AyaUiFieldDataType.Text });
l.Add(new AyaField { LtKey = "AuthorizationRoles", FieldKey = "Roles", Hideable = false, UiFieldDataType = (int)AyaUiFieldDataType.Enum, EnumType = typeof(AuthorizationRoles).ToString() });
l.Add(new AyaField { LtKey = "UserNotes", FieldKey = "Notes", UiFieldDataType = (int)AyaUiFieldDataType.Text });
l.Add(new AyaField { LtKey = "UserUserType", FieldKey = "UserType", Hideable = false, UiFieldDataType = (int)AyaUiFieldDataType.Enum, EnumType = typeof(UserType).ToString() });
l.Add(new AyaField { LtKey = "Active", FieldKey = "Active", UiFieldDataType = (int)AyaUiFieldDataType.Bool, Hideable = false });
l.Add(new AyaField { LtKey = "Tags", FieldKey = "Tags", UiFieldDataType = (int)AyaUiFieldDataType.Tags });
l.Add(new AyaFieldDefinition { LtKey = "df", AyaObjectType = (int)AyaType.User });
l.Add(new AyaFieldDefinition { LtKey = "Name", FieldKey = "Name", UiFieldDataType = (int)AyaUiFieldDataType.Text, Hideable = false });
l.Add(new AyaFieldDefinition { LtKey = "UserEmployeeNumber", FieldKey = "EmployeeNumber", UiFieldDataType = (int)AyaUiFieldDataType.Text });
l.Add(new AyaFieldDefinition { LtKey = "AuthorizationRoles", FieldKey = "Roles", Hideable = false, UiFieldDataType = (int)AyaUiFieldDataType.Enum, EnumType = typeof(AuthorizationRoles).ToString() });
l.Add(new AyaFieldDefinition { LtKey = "UserNotes", FieldKey = "Notes", UiFieldDataType = (int)AyaUiFieldDataType.Text });
l.Add(new AyaFieldDefinition { LtKey = "UserUserType", FieldKey = "UserType", Hideable = false, UiFieldDataType = (int)AyaUiFieldDataType.Enum, EnumType = typeof(UserType).ToString() });
l.Add(new AyaFieldDefinition { LtKey = "Active", FieldKey = "Active", UiFieldDataType = (int)AyaUiFieldDataType.Bool, Hideable = false });
l.Add(new AyaFieldDefinition { LtKey = "Tags", FieldKey = "Tags", UiFieldDataType = (int)AyaUiFieldDataType.Tags });
l.Add(new AyaField { LtKey = "UserCustom1", FieldKey = "UserCustom1", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom2", FieldKey = "UserCustom2", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom3", FieldKey = "UserCustom3", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom4", FieldKey = "UserCustom4", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom5", FieldKey = "UserCustom5", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom6", FieldKey = "UserCustom6", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom7", FieldKey = "UserCustom7", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom8", FieldKey = "UserCustom8", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom9", FieldKey = "UserCustom9", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom10", FieldKey = "UserCustom10", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom11", FieldKey = "UserCustom11", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom12", FieldKey = "UserCustom12", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom13", FieldKey = "UserCustom13", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom14", FieldKey = "UserCustom14", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom15", FieldKey = "UserCustom15", IsCustomField = true });
l.Add(new AyaField { LtKey = "UserCustom16", FieldKey = "UserCustom16", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "UserCustom1", FieldKey = "UserCustom1", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "UserCustom2", FieldKey = "UserCustom2", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "UserCustom3", FieldKey = "UserCustom3", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "UserCustom4", FieldKey = "UserCustom4", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "UserCustom5", FieldKey = "UserCustom5", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "UserCustom6", FieldKey = "UserCustom6", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "UserCustom7", FieldKey = "UserCustom7", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "UserCustom8", FieldKey = "UserCustom8", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "UserCustom9", FieldKey = "UserCustom9", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "UserCustom10", FieldKey = "UserCustom10", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "UserCustom11", FieldKey = "UserCustom11", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "UserCustom12", FieldKey = "UserCustom12", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "UserCustom13", FieldKey = "UserCustom13", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "UserCustom14", FieldKey = "UserCustom14", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "UserCustom15", FieldKey = "UserCustom15", IsCustomField = true });
l.Add(new AyaFieldDefinition { LtKey = "UserCustom16", FieldKey = "UserCustom16", IsCustomField = true });
break;
#endregion
case TEST_WIDGET_USER_EMAIL_ADDRESS_LIST_KEY:
#region TEST_WIDGET_USER_EMAIL_ADDRESS_LIST_KEY
l.Add(new AyaField { FieldKey = "df", AyaObjectType = (int)AyaType.Widget, SqlIdColumnName = "awidget.id" });
l.Add(new AyaField
l.Add(new AyaFieldDefinition { FieldKey = "df", AyaObjectType = (int)AyaType.Widget, SqlIdColumnName = "awidget.id" });
l.Add(new AyaFieldDefinition
{
FieldKey = "widgetname",
LtKey = "WidgetName",
@@ -232,7 +232,7 @@ namespace AyaNova.Biz
SqlIdColumnName = "awidget.id",
SqlDisplayColumnName = "awidget.name"
});
l.Add(new AyaField
l.Add(new AyaFieldDefinition
{
FieldKey = "username",
LtKey = "User",
@@ -241,7 +241,7 @@ namespace AyaNova.Biz
SqlIdColumnName = "auser.id",
SqlDisplayColumnName = "auser.name"
});
l.Add(new AyaField
l.Add(new AyaFieldDefinition
{
LtKey = "UserEmailAddress",
FieldKey = "emailaddress",
@@ -301,7 +301,7 @@ namespace AyaNova.Biz
foreach (string s in fullFields)
{
AyaField o = fields.FirstOrDefault(x => x.FieldKey == s);
AyaFieldDefinition o = fields.FirstOrDefault(x => x.FieldKey == s);
#if (DEBUG)
//Developers little helper
if (o == null)
@@ -335,7 +335,7 @@ namespace AyaNova.Biz
}//eoc ObjectFields
public class AyaField
public class AyaFieldDefinition
{
//CLIENT / SERVER Unique identifier used at BOTH client and server
//also the sql displaycolumnname if identical
@@ -370,7 +370,7 @@ namespace AyaNova.Biz
public string SqlDisplayColumnName { get; set; }
public AyaField()
public AyaFieldDefinition()
{
//most common defaults
Hideable = true;

View File

@@ -247,7 +247,7 @@ namespace AyaNova.Biz
AddError(ApiErrorCode.VALIDATION_REQUIRED, "ListKey");
List<AyaField> FieldList = null;
List<AyaFieldDefinition> FieldList = null;
if (!AyaObjectFields.IsValidObjectKey(inObj.ListKey))
{
AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "ListKey", $"ListKey \"{inObj.ListKey}\" is empty or in-valid");

View File

@@ -206,7 +206,7 @@ namespace AyaNova.Biz
for (int i = 0; i < v.Count; i++)
{
AyaField MasterFormField = null;
AyaFieldDefinition MasterFormField = null;
var formFieldItem = v[i];
if (formFieldItem["fld"] == null)

View File

@@ -10,7 +10,7 @@ namespace AyaNova.Biz
internal static class PickListFetcher
{
internal static PickListResult GetPickList(AyContext ct, long userId, ListOptions pagingOptions, List<AyaField> objectFields, string tableName)
internal static PickListResult GetPickList(AyContext ct, long userId, ListOptions pagingOptions, List<AyaFieldDefinition> objectFields, string tableName)
{
List<NameIdItem> listItems = new List<NameIdItem>();

View File

@@ -30,7 +30,7 @@ namespace AyaNova.Biz
// - e.g.: {template:[{fld:"ltkeyfieldname",hide:"true/false",required:"true/false", type:"bool"},{fld:"ltkeyfieldname",hide:"true/false",required:"true/false", type:"text"]}
//get the FormField object
AyaField FF = FormFields.Where(x => x.LtKey == FldLtKey).Single();
AyaFieldDefinition FF = FormFields.Where(x => x.LtKey == FldLtKey).Single();
//don't validate custom fields, just skip them
// if (!string.IsNullOrWhiteSpace(FF.PropertyName))//this used to work because there would be no property name but now there is so it doesn't

View File

@@ -11,7 +11,7 @@ namespace AyaNova.Biz
{
public static class SqlFilterCriteriaBuilder
{
public static string DataFilterToSQLCriteria(AyaNova.Models.DataFilter dataFilter, List<AyaField> objectFields, long userId)
public static string DataFilterToSQLCriteria(AyaNova.Models.DataFilter dataFilter, List<AyaFieldDefinition> objectFields, long userId)
{
if (string.IsNullOrWhiteSpace(dataFilter.Filter))

View File

@@ -37,7 +37,7 @@ namespace AyaNova.Biz
sb.Append("SELECT ");
//Default ID column for each row (always is aliased as df)
AyaField def = objectFieldsList.FirstOrDefault(x => x.FieldKey == "df");
AyaFieldDefinition def = objectFieldsList.FirstOrDefault(x => x.FieldKey == "df");
if (def == null)
{
throw new System.ArgumentNullException($"SqlSelectBuilder: objectFieldList for key \"{objectKey}\" is missing the df default field");
@@ -55,7 +55,7 @@ namespace AyaNova.Biz
foreach (string ColumnName in templateFieldList)
{
AyaField o = objectFieldsList.FirstOrDefault(x => x.FieldKey == ColumnName);
AyaFieldDefinition o = objectFieldsList.FirstOrDefault(x => x.FieldKey == ColumnName);
#if (DEBUG)
//Developers little helper
if (o == null)

View File

@@ -466,8 +466,11 @@ namespace AyaNova.Biz
}
//RETURN OBJECTS
List<object[]> items = new List<object[]>();
//RETURN OBJECTS
//todo: need exact rowcount so can set up array on each row
//need to know which index of each row is going to need the id of the next row
List<List<AyaFieldData>> rows= new List<List<AyaFieldData>>();
long totalRecordCount = 0;
//RUN THE QUERY
@@ -482,6 +485,7 @@ namespace AyaNova.Biz
{
object[] row = new object[dr.FieldCount];
dr.GetValues(row);
//INSERT INTO THE RETURN ROWS LIST
items.Add(row);
}
}