This commit is contained in:
2020-03-16 23:02:51 +00:00
parent e47b0501c9
commit f001786137

View File

@@ -15,15 +15,10 @@ namespace AyaNova.PickList
{
internal static class PickListFetcher
{
internal static async Task<List<NameIdActiveItem>> GetResponseAsync(IAyaPickList PickList, string autoCompleteQuery, string tagSpecificQuery, bool includeInactive, AyContext ct)
{
//Template
//Sort out effective Template
string Template = null;
//Attempt to fetch custom template
var t = await ct.PickListTemplate.FirstOrDefaultAsync(m => m.Id == ((long)PickList.DefaultListObjectType));
@@ -39,20 +34,15 @@ namespace AyaNova.PickList
//parse the template
var jTemplate = JArray.Parse(Template);
//Get the field key names in a list from the template
List<string> TemplateColumnNames = PickList.GetFieldListFromTemplate(jTemplate);
//BUILD THE QUERY
var q = PickListSqlBuilder.Build(PickList, TemplateColumnNames, autoCompleteQuery, tagSpecificQuery, includeInactive);
//RETURN OBJECTS
var ret = new List<NameIdActiveItem>();
//QUERY THE DB
using (var command = ct.Database.GetDbConnection().CreateCommand())
{
@@ -72,83 +62,10 @@ namespace AyaNova.PickList
Active = dr.GetBoolean(1),
Name = dr.GetString(2)
});
// List<AyaFieldData> row = new List<AyaFieldData>(returnRowColumnCount);
// //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)
// {
// 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);
// }
// /*
// 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
// */
// }
// 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);
// }
// row.Add(AyaField);
// }
// }
// rows.Add(row);
}
}
}
return ret;
}
}//eoc
}//eons