This commit is contained in:
@@ -3,14 +3,15 @@ using Newtonsoft.Json.Linq;
|
||||
using AyaNova.Models;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
||||
namespace AyaNova.PickList
|
||||
{
|
||||
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
|
||||
@@ -45,20 +46,32 @@ namespace AyaNova.PickList
|
||||
|
||||
//GET DATA RETURN ROWS
|
||||
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:
|
||||
//plId, plActive, plName
|
||||
ret.Add(new NameIdActiveItem
|
||||
while (dr.Read())
|
||||
{
|
||||
Id = dr.GetInt64(0),
|
||||
Active = dr.GetBoolean(1),
|
||||
Name = dr.GetString(2)
|
||||
});
|
||||
//query is always in the same order:
|
||||
//plId, plActive, plName
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace AyaNova.PickList
|
||||
}
|
||||
|
||||
|
||||
if (HasAutoCompleteQuery)
|
||||
if (HasAutoCompleteQuery && !HasTagSpecificQuery)
|
||||
lWhere.Add(sWhere);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user