This commit is contained in:
2020-03-13 19:11:29 +00:00
parent 8163f43fd7
commit d6d69b4a0c
2 changed files with 103 additions and 164 deletions

View File

@@ -15,9 +15,9 @@ namespace AyaNova.PickList
{
internal static class PickListFetcher
{
internal static async Task<List<NameIdActiveItem>> GetResponseAsync(AyaType ayaType, string query, AyContext ct, AuthorizationRoles userRoles)
internal static async Task<List<NameIdActiveItem>> GetResponseAsync(AyaType ayaType, string autoCompleteQuery, AyContext ct, AuthorizationRoles userRoles)
{
var PickList = PickListFactory.GetAyaPickList(ayaType);
//was the name not found as a list?
@@ -52,14 +52,14 @@ namespace AyaNova.PickList
List<string> TemplateColumnNames = PickList.GetFieldListFromTemplate(jTemplate);
//BUILD THE QUERY
var q = PickListSqlBuilder.Build(PickList.ColumnDefinitions, TemplateColumnNames);
var q = PickListSqlBuilder.Build(PickList, TemplateColumnNames, autoCompleteQuery);
//RETURN OBJECTS
var ret=new List<NameIdActiveItem>();
var ret = new List<NameIdActiveItem>();
//QUERY THE DB
using (var command = ct.Database.GetDbConnection().CreateCommand())
@@ -72,80 +72,80 @@ namespace AyaNova.PickList
{
while (dr.Read())
{
// List<AyaFieldData> row = new List<AyaFieldData>(returnRowColumnCount);
// List<AyaFieldData> row = new List<AyaFieldData>(returnRowColumnCount);
// //INSERT REMAINING FIELDS FROM TEMPLATE INTO THE RETURN ROWS LIST
// foreach (string TemplateField in ListViewFieldList)
// {
// //INSERT REMAINING FIELDS FROM TEMPLATE INTO THE RETURN ROWS LIST
// foreach (string TemplateField in ListViewFieldList)
// {
// //get the AyaObjectFieldDefinition
// AyaPickListFieldDefinition f = PickList.FieldDefinitions.FirstOrDefault(x => x.FieldKey == TemplateField);
// if (f.IsCustomField)
// {
// //get the AyaObjectFieldDefinition
// AyaPickListFieldDefinition f = PickList.FieldDefinitions.FirstOrDefault(x => x.FieldKey == TemplateField);
// if (f.IsCustomField)
// {
// AyaFieldData AyaField = new AyaFieldData();
// var cust = dr.GetString(SelectBuild.map[f.GetSqlValueColumnName()]);
// if (!string.IsNullOrWhiteSpace(cust))
// {
// JObject j = JObject.Parse(cust);
// //convert field name to cust name then get value
// var InternalCustomFieldName = AyaFormFieldDefinitions.TranslateLTCustomFieldToInternalCustomFieldName(TemplateField);
// //Sometimes a custom field is specified but doesn't exist in the collection so don't assume it's there
// // AyaField.v = j[InternalCustomFieldName].Value<object>();
// JToken o = j[InternalCustomFieldName];
// if (o != null)
// AyaField.v = o.Value<object>();
// else
// AyaField.v = null;
// AyaFieldData AyaField = new AyaFieldData();
// var cust = dr.GetString(SelectBuild.map[f.GetSqlValueColumnName()]);
// if (!string.IsNullOrWhiteSpace(cust))
// {
// JObject j = JObject.Parse(cust);
// //convert field name to cust name then get value
// var InternalCustomFieldName = AyaFormFieldDefinitions.TranslateLTCustomFieldToInternalCustomFieldName(TemplateField);
// //Sometimes a custom field is specified but doesn't exist in the collection so don't assume it's there
// // AyaField.v = j[InternalCustomFieldName].Value<object>();
// JToken o = j[InternalCustomFieldName];
// if (o != null)
// AyaField.v = o.Value<object>();
// else
// AyaField.v = null;
// row.Add(AyaField);
// }
// row.Add(AyaField);
// }
// /*
// TODO: Custom field handling
// GetName works just not with multipart identifiers
// I could force naming by making all fields and AS, or
// I could map the ordinal when generating the Select fields so that I have a map to refer to here
// mapping in advance actually makes a lot of sense, then no more of this fragility of going by pointer index and hoping for the best
// it would just be premapped out.
// /*
// TODO: Custom field handling
// GetName works just not with multipart identifiers
// I could force naming by making all fields and AS, or
// I could map the ordinal when generating the Select fields so that I have a map to refer to here
// mapping in advance actually makes a lot of sense, then no more of this fragility of going by pointer index and hoping for the best
// it would just be premapped out.
// dr.GetOrdinal(f.SqlValueColumnName)
// 'dr.GetOrdinal(f.SqlValueColumnName)' threw an exception of type 'System.IndexOutOfRangeException'
// f.SqlValueColumnName
// "awidget.customfields"
// dr.GetName(nCurrentColumnPointer)
// "customfields"
// dr.GetOrdinal("customfields");
// 5
// dr.GetOrdinal(f.SqlValueColumnName)
// 'dr.GetOrdinal(f.SqlValueColumnName)' threw an exception of type 'System.IndexOutOfRangeException'
// f.SqlValueColumnName
// "awidget.customfields"
// dr.GetName(nCurrentColumnPointer)
// "customfields"
// dr.GetOrdinal("customfields");
// 5
// */
// }
// else
// {
// AyaFieldData AyaField = new AyaFieldData();
// AyaField.v = dr.GetValue(SelectBuild.map[f.GetSqlValueColumnName()]);
// */
// }
// else
// {
// AyaFieldData AyaField = new AyaFieldData();
// AyaField.v = dr.GetValue(SelectBuild.map[f.GetSqlValueColumnName()]);
// if (f.SqlIdColumnName != null)
// {
// var ordinal = SelectBuild.map[f.SqlIdColumnName];
// if (!await dr.IsDBNullAsync(ordinal))
// AyaField.i = dr.GetInt64(ordinal);
// if (f.SqlIdColumnName != null)
// {
// var ordinal = SelectBuild.map[f.SqlIdColumnName];
// if (!await dr.IsDBNullAsync(ordinal))
// AyaField.i = dr.GetInt64(ordinal);
// }
// row.Add(AyaField);
// }
// }
// rows.Add(row);
// }
// row.Add(AyaField);
// }
// }
// rows.Add(row);
}
}
}
return ret;
return ret;
}