From 3b2189de019d4b06ed39179e69314ced75156bb4 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 27 Jan 2020 18:41:14 +0000 Subject: [PATCH] --- devdocs/todo.txt | 1 + server/AyaNova/Controllers/DataListController.cs | 2 +- server/AyaNova/DataList/DataListFetcher.cs | 10 +++++----- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/devdocs/todo.txt b/devdocs/todo.txt index f338e734..4ddaefca 100644 --- a/devdocs/todo.txt +++ b/devdocs/todo.txt @@ -13,6 +13,7 @@ TODO: look for any line of code that does this or similar: await Task.CompletedT TODO: Look at any of my middleware code as it's a HOT PATH, make sure it's async db access etc and nothing slowing it down +TODO: Any code at the server that access the db or does file IO MUST be async top to bottom!! TODO: REFACTOR GetNoLogAsync function is used in many places redundantly when the logging version could do the same thing but not log it with an optional bool switch so refactor that shit TODO: REFACTOR biz objects have two creates, an async and sync one, WTF is that about? See if can make it just one async version. diff --git a/server/AyaNova/Controllers/DataListController.cs b/server/AyaNova/Controllers/DataListController.cs index 6a07f6a1..b21f2438 100644 --- a/server/AyaNova/Controllers/DataListController.cs +++ b/server/AyaNova/Controllers/DataListController.cs @@ -62,7 +62,7 @@ namespace AyaNova.Api.Controllers try { - ApiPagedResponse pr = await DataListFetcher.GetResponse(listOptions.DataListKey, ct, Url, nameof(List), listOptions, UserId, UserRoles); + ApiPagedResponse pr = await DataListFetcher.GetResponseAsync(listOptions.DataListKey, ct, Url, nameof(List), listOptions, UserId, UserRoles); return Ok(new ApiOkWithPagingResponse(pr)); } catch (System.UnauthorizedAccessException) diff --git a/server/AyaNova/DataList/DataListFetcher.cs b/server/AyaNova/DataList/DataListFetcher.cs index a3942c19..db6c53f0 100644 --- a/server/AyaNova/DataList/DataListFetcher.cs +++ b/server/AyaNova/DataList/DataListFetcher.cs @@ -13,7 +13,7 @@ namespace AyaNova.DataList { internal static class DataListFetcher { - internal static async Task GetResponse(string DataListKey, AyContext ct, IUrlHelper Url, + internal static async Task GetResponseAsync(string DataListKey, AyContext ct, IUrlHelper Url, string routeName, ListOptions listOptions, long UserId, AuthorizationRoles UserRoles) { @@ -117,11 +117,11 @@ namespace AyaNova.DataList //QUERY THE DB using (var command = ct.Database.GetDbConnection().CreateCommand()) { - ct.Database.OpenConnection(); + await ct.Database.OpenConnectionAsync(); //GET DATA RETURN ROWS command.CommandText = qDataQuery; - using (var dr = command.ExecuteReader()) + using (var dr = await command.ExecuteReaderAsync()) { while (dr.Read()) { @@ -155,7 +155,7 @@ namespace AyaNova.DataList if (f.SqlIdColumnName != null)//skip over df column id, it's not there { - if (!dr.IsDBNull(nCurrentColumnPointer)) + if (!await dr.IsDBNullAsync(nCurrentColumnPointer)) AyaField.i = dr.GetInt64(nCurrentColumnPointer); nCurrentColumnPointer++; @@ -168,7 +168,7 @@ namespace AyaNova.DataList //GET TOTAL RECORD COUNT command.CommandText = qTotalRecordsQuery; - using (var dr = command.ExecuteReader()) + using (var dr = await command.ExecuteReaderAsync()) { if (dr.Read()) {