This commit is contained in:
@@ -13,6 +13,11 @@ namespace AyaNova.DataList
|
||||
{
|
||||
internal static class DataListFetcher
|
||||
{
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// Get the data list data requested
|
||||
//
|
||||
//
|
||||
internal static async Task<ApiDataListResponse> GetResponseAsync(string DataListKey, AyContext ct, ListOptions listOptions, AuthorizationRoles UserRoles, ILogger log)
|
||||
{
|
||||
|
||||
@@ -20,20 +25,15 @@ namespace AyaNova.DataList
|
||||
|
||||
//was the name not found as a list?
|
||||
if (DataList == null)
|
||||
{
|
||||
throw new System.ArgumentOutOfRangeException($"DataList \"{DataListKey}\" specified does not exist");
|
||||
}
|
||||
|
||||
//check rights
|
||||
|
||||
if (!UserRoles.HasAnyFlags(DataList.AllowedRoles))
|
||||
throw new System.UnauthorizedAccessException("User roles insufficient for this datalist");
|
||||
|
||||
//do we need to default the listView?
|
||||
if (string.IsNullOrWhiteSpace(listOptions.ListView))
|
||||
{
|
||||
listOptions.ListView = DataList.DefaultListView;
|
||||
}
|
||||
|
||||
//parse the list view(s)
|
||||
//This one is for the return list to the Client for grid column display
|
||||
@@ -212,37 +212,35 @@ namespace AyaNova.DataList
|
||||
}
|
||||
|
||||
|
||||
//Get a list of id's for reporting
|
||||
internal static async Task<long[]> GetIdListResponseAsync(string dataListKey, string listView, AyContext ct, AuthorizationRoles userRoles, ILogger log)
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// Get a list of id's of the datalist results for reporting
|
||||
//
|
||||
//
|
||||
internal static async Task<long[]> GetIdListResponseAsync(string dataListKey, string listView, string metaListView, AyContext ct, AuthorizationRoles userRoles, ILogger log)
|
||||
{
|
||||
|
||||
var DataList = DataListFactory.GetAyaDataList(dataListKey);
|
||||
|
||||
//was the name not found as a list?
|
||||
if (DataList == null)
|
||||
{
|
||||
throw new System.ArgumentOutOfRangeException($"DataList \"{dataListKey}\" specified does not exist");
|
||||
}
|
||||
|
||||
//check rights
|
||||
|
||||
if (!userRoles.HasAnyFlags(DataList.AllowedRoles))
|
||||
throw new System.UnauthorizedAccessException("User roles insufficient for this datalist");
|
||||
|
||||
//do we need to default the listView?
|
||||
if (string.IsNullOrWhiteSpace(listView))
|
||||
{
|
||||
listView = DataList.DefaultListView;
|
||||
}
|
||||
|
||||
//parse the list view
|
||||
var ListViewArray = JArray.Parse(listView);
|
||||
|
||||
var MetaListViewArray = JArray.Parse(metaListView ?? "[]");
|
||||
foreach (JToken jt in MetaListViewArray)
|
||||
ListViewArray.Add(jt);
|
||||
|
||||
//Get the field key names in a list from the listview
|
||||
List<string> ListViewFieldList = DataList.GetFieldListFromListView(ListViewArray);
|
||||
|
||||
|
||||
//BUILD THE QUERY
|
||||
//SELECT FRAGMENT COLUMNS FROM TEMPLATE
|
||||
var SelectBuild = DataListSqlSelectBuilder.BuildForReportIdListOnly(DataList.FieldDefinitions, ListViewFieldList);
|
||||
@@ -259,7 +257,6 @@ namespace AyaNova.DataList
|
||||
//ORDER BY CLAUSE - SORT
|
||||
qOrderBy = DataListSqlFilterOrderByBuilder.DataFilterToSQLOrderBy(DataList.FieldDefinitions, ListViewArray);
|
||||
|
||||
|
||||
//PUT IT ALL TOGETHER
|
||||
string qDataQuery = string.Empty;
|
||||
|
||||
@@ -281,12 +278,9 @@ namespace AyaNova.DataList
|
||||
}
|
||||
}
|
||||
|
||||
//QUERY THE DB
|
||||
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
||||
{
|
||||
await ct.Database.OpenConnectionAsync();
|
||||
|
||||
//GET DATA RETURN ROWS
|
||||
command.CommandText = qDataQuery;
|
||||
try
|
||||
{
|
||||
@@ -294,21 +288,8 @@ namespace AyaNova.DataList
|
||||
{
|
||||
while (dr.Read())
|
||||
{
|
||||
//todo: test this with a full on widget report
|
||||
if (!dr.IsDBNull(IDColumnOrdinal))
|
||||
retList.Add(dr.GetInt64(IDColumnOrdinal));
|
||||
// foreach (string TemplateField in ListViewFieldList)
|
||||
// {
|
||||
// //get the AyaObjectFieldDefinition
|
||||
// AyaDataListFieldDefinition f = DataList.FieldDefinitions.FirstOrDefault(z => z.FieldKey == TemplateField);
|
||||
// if (f.IsRowId)
|
||||
// {
|
||||
// var ordinal = SelectBuild.map[f.SqlIdColumnName];
|
||||
// if (!await dr.IsDBNullAsync(ordinal))
|
||||
// retList.Add(dr.GetInt64(ordinal));
|
||||
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -320,13 +301,9 @@ namespace AyaNova.DataList
|
||||
|
||||
log.LogInformation(e, "DB Exception");
|
||||
throw new System.Exception("DataListFetcher:GetIdListResponseAsync - Query failed see log");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//retList.Reverse();
|
||||
return retList.ToArray();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user