This commit is contained in:
2020-03-19 15:46:35 +00:00
parent ab3d4606c3
commit ac7f0f94e1
5 changed files with 32 additions and 15 deletions

View File

@@ -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;
}

View File

@@ -156,7 +156,7 @@ namespace AyaNova.PickList
}
if (HasAutoCompleteQuery)
if (HasAutoCompleteQuery && !HasTagSpecificQuery)
lWhere.Add(sWhere);