This commit is contained in:
@@ -5,11 +5,14 @@
|
|||||||
## IMMEDIATE ITEMS
|
## IMMEDIATE ITEMS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//PICKLISTS:
|
//PICKLISTS:
|
||||||
|
|
||||||
todo: move to client work then back here to document after
|
todo: move to client work then back here to document after
|
||||||
todo: document picklist and tag search etc after client example working in widget form
|
todo: document picklist and tag search etc after client example working in widget form
|
||||||
|
|
||||||
|
todo: add query fail logging to datalist just like done with picklist so in production can catch mysterious problems more easily
|
||||||
|
|
||||||
|
|
||||||
TODO: BizRoles.cs seems to get hammered on every single request, is it efficient?
|
TODO: BizRoles.cs seems to get hammered on every single request, is it efficient?
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
PickListBiz biz = PickListBiz.GetBiz(ct, HttpContext);
|
PickListBiz biz = PickListBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
var o = await biz.GetPickListAsync(PickList, query, inactive);
|
var o = await biz.GetPickListAsync(PickList, query, inactive, log);
|
||||||
if (o == null)
|
if (o == null)
|
||||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -3,14 +3,15 @@ using Newtonsoft.Json.Linq;
|
|||||||
using AyaNova.Models;
|
using AyaNova.Models;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
|
||||||
namespace AyaNova.PickList
|
namespace AyaNova.PickList
|
||||||
{
|
{
|
||||||
internal static class PickListFetcher
|
internal static class PickListFetcher
|
||||||
{
|
{
|
||||||
internal static async Task<List<NameIdActiveItem>> GetResponseAsync(IAyaPickList PickList, string autoCompleteQuery, string tagSpecificQuery, bool includeInactive, AyContext ct)
|
internal static async Task<List<NameIdActiveItem>> GetResponseAsync(IAyaPickList PickList, string autoCompleteQuery,
|
||||||
|
string tagSpecificQuery, bool includeInactive, AyContext ct, ILogger log)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Sort out effective Template
|
//Sort out effective Template
|
||||||
@@ -45,20 +46,32 @@ namespace AyaNova.PickList
|
|||||||
|
|
||||||
//GET DATA RETURN ROWS
|
//GET DATA RETURN ROWS
|
||||||
command.CommandText = q;
|
command.CommandText = q;
|
||||||
using (var dr = await command.ExecuteReaderAsync())
|
try
|
||||||
{
|
{
|
||||||
while (dr.Read())
|
using (var dr = await command.ExecuteReaderAsync())
|
||||||
{
|
{
|
||||||
//query is always in the same order:
|
while (dr.Read())
|
||||||
//plId, plActive, plName
|
|
||||||
ret.Add(new NameIdActiveItem
|
|
||||||
{
|
{
|
||||||
Id = dr.GetInt64(0),
|
//query is always in the same order:
|
||||||
Active = dr.GetBoolean(1),
|
//plId, plActive, plName
|
||||||
Name = dr.GetString(2)
|
ret.Add(new NameIdActiveItem
|
||||||
});
|
{
|
||||||
|
Id = dr.GetInt64(0),
|
||||||
|
Active = dr.GetBoolean(1),
|
||||||
|
Name = dr.GetString(2)
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Npgsql.PostgresException e)
|
||||||
|
{
|
||||||
|
//log out the exception and the query
|
||||||
|
log.LogInformation("PickList query failed unexpectedly. Query was:");
|
||||||
|
log.LogInformation(q);
|
||||||
|
log.LogInformation(e,"DB Exception");
|
||||||
|
throw new System.Exception("PickListFetcher - Query failed see log");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ namespace AyaNova.PickList
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (HasAutoCompleteQuery)
|
if (HasAutoCompleteQuery && !HasTagSpecificQuery)
|
||||||
lWhere.Add(sWhere);
|
lWhere.Add(sWhere);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using AyaNova.Util;
|
using AyaNova.Util;
|
||||||
@@ -69,7 +70,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
|
|
||||||
//get picklist
|
//get picklist
|
||||||
internal async Task<List<NameIdActiveItem>> GetPickListAsync(IAyaPickList PickList, string query, bool inactive)
|
internal async Task<List<NameIdActiveItem>> GetPickListAsync(IAyaPickList PickList, string query, bool inactive, ILogger log)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Crack and validate the query part set a broken rule if not valid and return null
|
//Crack and validate the query part set a broken rule if not valid and return null
|
||||||
@@ -133,7 +134,7 @@ namespace AyaNova.Biz
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Autocomplete and tagonly query terms now set for consumption by PickListFetcher, ready to fetch...
|
//Autocomplete and tagonly query terms now set for consumption by PickListFetcher, ready to fetch...
|
||||||
List<NameIdActiveItem> items = await PickListFetcher.GetResponseAsync(PickList, AutoCompleteQuery, TagSpecificQuery, inactive, ct);
|
List<NameIdActiveItem> items = await PickListFetcher.GetResponseAsync(PickList, AutoCompleteQuery, TagSpecificQuery, inactive, ct, log);
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user