From 477d752f8939550aa1d2efbfa332d4d3a566ce0a Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Thu, 14 Oct 2021 18:37:24 +0000 Subject: [PATCH] --- server/AyaNova/DataList/DataListFetcher.cs | 28 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/server/AyaNova/DataList/DataListFetcher.cs b/server/AyaNova/DataList/DataListFetcher.cs index 16ecb9ea..bf3861e1 100644 --- a/server/AyaNova/DataList/DataListFetcher.cs +++ b/server/AyaNova/DataList/DataListFetcher.cs @@ -52,7 +52,10 @@ namespace AyaNova.DataList int returnRowColumnCount = dataListTableProcessingOptions.Columns.Count(); List> rows = new List>(); long totalRecordCount = 0; +#if (DEBUG) + System.Diagnostics.Stopwatch stopWatch = new System.Diagnostics.Stopwatch(); +#endif //QUERY THE DB using (var command = ct.Database.GetDbConnection().CreateCommand()) { @@ -62,8 +65,16 @@ namespace AyaNova.DataList command.CommandText = qDataQuery; try { +#if (DEBUG) + stopWatch.Start(); +#endif using (var dr = await command.ExecuteReaderAsync()) { +#if (DEBUG) + stopWatch.Stop(); + log.LogInformation($"(debug) DataListFetcher:GetResponse DATA query took {stopWatch.ElapsedMilliseconds}ms to execute: {qDataQuery}"); + stopWatch.Reset(); +#endif while (dr.Read()) { List row = new List(returnRowColumnCount); @@ -72,9 +83,10 @@ namespace AyaNova.DataList { //get the AyaObjectFieldDefinition DataListFieldDefinition f = DataList.FieldDefinitions.FirstOrDefault(z => z.FieldKey == TemplateField); - if(f==null){ - - log.LogError($"DataListFetcher:GetResponseAsync Template field '{TemplateField}' was NOT found in the field definitions for data list {DataList.ToString()}"); + if (f == null) + { + + log.LogError($"DataListFetcher:GetResponseAsync Template field '{TemplateField}' was NOT found in the field definitions for data list {DataList.ToString()}"); continue; } if (f.IsCustomField) @@ -148,8 +160,15 @@ namespace AyaNova.DataList //GET TOTAL RECORD COUNT command.CommandText = qTotalRecordsQuery; +#if (DEBUG) + stopWatch.Start(); +#endif using (var dr = await command.ExecuteReaderAsync()) { +#if (DEBUG) + stopWatch.Stop(); + log.LogInformation($"(debug) DataListFetcher:GetResponse COUNT query took {stopWatch.ElapsedMilliseconds}ms to execute: {qTotalRecordsQuery}"); +#endif if (dr.Read()) { totalRecordCount = dr.GetInt64(0); @@ -173,7 +192,8 @@ namespace AyaNova.DataList //log out the exception and the query log.LogError("DataListFetcher:GetResponseAsync unexpected failure. Data Query was:"); log.LogError(qDataQuery); - + log.LogError("Count Query was:"); + log.LogError(qTotalRecordsQuery); log.LogError(e, "Exception"); throw new System.Exception("DataListFetcher:GetResponseAsync - unexpected failure see log"); }