From e8184a3443f6ceb467a5f473c0d7b2eec55465c1 Mon Sep 17 00:00:00 2001 From: zgong-gov Date: Wed, 22 Mar 2023 11:43:42 -0700 Subject: [PATCH 1/8] Add date to timestamp for logging --- api/Hmcr.Api/appsettings.json | 12 ++++++++++-- api/Hmcr.Hangfire/appsettings.json | 7 ++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/api/Hmcr.Api/appsettings.json b/api/Hmcr.Api/appsettings.json index a6915069..79e5aac5 100644 --- a/api/Hmcr.Api/appsettings.json +++ b/api/Hmcr.Api/appsettings.json @@ -21,7 +21,10 @@ "Args": { "configure": [ { - "Name": "Console" + "Name": "Console", + "Args": { + "outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}" + } } ] } @@ -49,7 +52,12 @@ "renderAsText": false } }, - "timestamp": "TimestampColumnWriter", + "timestamp": { + "Name": "TimestampColumnWriter", + "Args": { + "dbType": "Timestamp" + } + }, "exception": "ExceptionColumnWriter", "log_event": "LogEventSerializedColumnWriter", "props_test": { diff --git a/api/Hmcr.Hangfire/appsettings.json b/api/Hmcr.Hangfire/appsettings.json index 5613860b..5d39045a 100644 --- a/api/Hmcr.Hangfire/appsettings.json +++ b/api/Hmcr.Hangfire/appsettings.json @@ -17,7 +17,12 @@ "Name": "Async", "Args": { "configure": [ - { "Name": "Console" } + { + "Name": "Console", + "Args": { + "outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}" + } + } ] } } From c43c367cf055c2cb45b6d77bcbf4535903d92933 Mon Sep 17 00:00:00 2001 From: zgong-gov Date: Thu, 23 Mar 2023 10:03:22 -0700 Subject: [PATCH 2/8] Update appsettings for openshift configmaps --- openshift/configmaps/api-appsettings.yaml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/openshift/configmaps/api-appsettings.yaml b/openshift/configmaps/api-appsettings.yaml index b2c8682a..2ebe7a7a 100644 --- a/openshift/configmaps/api-appsettings.yaml +++ b/openshift/configmaps/api-appsettings.yaml @@ -25,7 +25,14 @@ objects: { "Name": "Async", "Args": { - "configure": [ { "Name": "Console" } ] + "configure": [ + { + "Name": "Console", + "Args": { + "outputTemplate": "[{Timestamp:yyyy-MM-dd HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}" + } + } + ] } }, { @@ -48,7 +55,12 @@ objects: "renderAsText": false } }, - "timestamp": "TimestampColumnWriter", + "timestamp": { + "Name": "TimestampColumnWriter", + "Args": { + "dbType": "Timestamp" + } + }, "exception": "ExceptionColumnWriter", "log_event": "LogEventSerializedColumnWriter", "props_test": { From 6ec2bac79087a4f21aaaa885da163e3cae8f62e7 Mon Sep 17 00:00:00 2001 From: zgong-gov Date: Tue, 4 Apr 2023 14:17:42 -0700 Subject: [PATCH 3/8] Remove useless Keycloak logic in deployment pipeline --- .pipeline/lib/deploy.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.pipeline/lib/deploy.js b/.pipeline/lib/deploy.js index 26d5fb10..82e89879 100644 --- a/.pipeline/lib/deploy.js +++ b/.pipeline/lib/deploy.js @@ -3,7 +3,6 @@ const { OpenShiftClientX } = require("@bcgov/pipeline-cli"); const path = require("path"); const util = require("./util"); -const KeyCloakClient = require("./keycloak"); module.exports = (settings) => { const phases = settings.phases; @@ -17,15 +16,12 @@ module.exports = (settings) => { path.resolve(__dirname, "../../openshift") ); var objects = []; - const kc = new KeyCloakClient(settings, oc); const logDbSecret = util.getSecret( oc, phases[phase].namespace, `${phases[phase].name}-logdb${phases[phase].suffix}` ); - kc.addUris(); - // The deployment of your cool app goes here ▼▼▼ objects.push( ...oc.processDeploymentTemplate( From 06fcf5f9fe54fa69d9e6bff1d1452ed71b38cd4e Mon Sep 17 00:00:00 2001 From: zgong-gov Date: Wed, 12 Apr 2023 17:44:57 -0700 Subject: [PATCH 4/8] Update GeoServer urls for configmap --- openshift/configmaps/api-appsettings.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openshift/configmaps/api-appsettings.yaml b/openshift/configmaps/api-appsettings.yaml index 2ebe7a7a..645c65e6 100644 --- a/openshift/configmaps/api-appsettings.yaml +++ b/openshift/configmaps/api-appsettings.yaml @@ -153,12 +153,12 @@ parameters: displayName: EXPORT_URL name: EXPORT_URL required: true - value: "https://devoas1.apps.th.gov.bc.ca" + value: "https://tstoas5.apps.th.gov.bc.ca" - description: GeoServer CHRIS API URL displayName: OAS_URL name: OAS_URL required: true - value: "https://devoas1.apps.th.gov.bc.ca" + value: "https://prdoas5.apps.th.gov.bc.ca" - description: Default timeout value for CHRIS/GeoServer API calls displayName: GEOSERVER_TIMEOUT name: GEOSERVER_TIMEOUT From b624cc8ee66585f93319e0f60351a3d1640a34a1 Mon Sep 17 00:00:00 2001 From: zgong-gov Date: Wed, 12 Apr 2023 17:54:39 -0700 Subject: [PATCH 5/8] Update GeoServer settings in pipeline config --- .pipeline/lib/config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pipeline/lib/config.js b/.pipeline/lib/config.js index c49c1617..81e11b1d 100644 --- a/.pipeline/lib/config.js +++ b/.pipeline/lib/config.js @@ -29,8 +29,8 @@ const phases = { host: `hmcr-d3d940-dev.apps.silver.devops.gov.bc.ca`, url_prefix: "dev-", bceid_service: ".test", - oas_server: "devoas4", - export_server: "devoas4", + oas_server: "prdoas5", + export_server: "tstoas5", dotnet_env: "Development", transient: true, hangfire_cpu: "300m", From 0d67a123b6b1f68ad43b3654bd76533fa9c6733c Mon Sep 17 00:00:00 2001 From: zgong-gov Date: Thu, 13 Apr 2023 11:58:32 -0700 Subject: [PATCH 6/8] Add validation check and error message for empty report rows --- api/Hmcr.Domain/Services/RockfallReportService.cs | 6 ++++++ api/Hmcr.Domain/Services/WildlifeReportService.cs | 6 ++++++ api/Hmcr.Domain/Services/WorkReportService.cs | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/api/Hmcr.Domain/Services/RockfallReportService.cs b/api/Hmcr.Domain/Services/RockfallReportService.cs index aa143afb..97ada124 100644 --- a/api/Hmcr.Domain/Services/RockfallReportService.cs +++ b/api/Hmcr.Domain/Services/RockfallReportService.cs @@ -76,6 +76,12 @@ protected override async Task ParseRowsAsync(SubmissionObjectCreateDto sub } } + if (row == null) + { + errors.AddItem("File", "Row is empty. Please make sure that the report isn't empty, and doesn't have empty data rows"); + break; + } + row.ServiceArea = serviceArea.ConvertToServiceAreaString(row.ServiceArea); rows.Add(row); } diff --git a/api/Hmcr.Domain/Services/WildlifeReportService.cs b/api/Hmcr.Domain/Services/WildlifeReportService.cs index 3bb099d6..b02e55eb 100644 --- a/api/Hmcr.Domain/Services/WildlifeReportService.cs +++ b/api/Hmcr.Domain/Services/WildlifeReportService.cs @@ -74,6 +74,12 @@ protected override async Task ParseRowsAsync(SubmissionObjectCreateDto sub } } + if (row == null) + { + errors.AddItem("File", "Row is empty. Please make sure that the report isn't empty, and doesn't have empty data rows"); + break; + } + row.ServiceArea = serviceArea.ConvertToServiceAreaString(row.ServiceArea); rows.Add(row); } diff --git a/api/Hmcr.Domain/Services/WorkReportService.cs b/api/Hmcr.Domain/Services/WorkReportService.cs index e8060ad1..9be18ae3 100644 --- a/api/Hmcr.Domain/Services/WorkReportService.cs +++ b/api/Hmcr.Domain/Services/WorkReportService.cs @@ -76,6 +76,12 @@ protected override async Task ParseRowsAsync(SubmissionObjectCreateDto sub } } + if (row == null) + { + errors.AddItem("File", "Row is empty. Please make sure that the report isn't empty, and doesn't have empty data rows"); + break; + } + row.ServiceArea = serviceArea.ConvertToServiceAreaString(row.ServiceArea); rows.Add(row); } From 5a499bf70a1b651a51a2983974132049d41c1aae Mon Sep 17 00:00:00 2001 From: zgong-gov Date: Tue, 18 Apr 2023 10:57:47 -0700 Subject: [PATCH 7/8] Replace console logging with proper logging --- api/Hmcr.Data/Database/Entities/AppDbContextPartial.cs | 8 ++++++-- api/Hmcr.Domain/Hangfire/WorkReportJobService.cs | 3 ++- api/Hmcr.Domain/Services/EmailService.cs | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/api/Hmcr.Data/Database/Entities/AppDbContextPartial.cs b/api/Hmcr.Data/Database/Entities/AppDbContextPartial.cs index ec77bcba..607a2127 100644 --- a/api/Hmcr.Data/Database/Entities/AppDbContextPartial.cs +++ b/api/Hmcr.Data/Database/Entities/AppDbContextPartial.cs @@ -4,6 +4,7 @@ using Hmcr.Model.Utils; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.ChangeTracking; +using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.Linq; @@ -26,11 +27,13 @@ public partial class AppDbContext private const string AppLastUpdateUserGuid = "AppLastUpdateUserGuid"; private const string AppLastUpdateTimestamp = "AppLastUpdateTimestamp"; + private readonly ILogger _logger; public readonly HmcrCurrentUser _currentUser; - public AppDbContext(DbContextOptions options, HmcrCurrentUser currentUser) + public AppDbContext(DbContextOptions options, ILogger logger, HmcrCurrentUser currentUser) : base(options) { + _logger = logger; _currentUser = currentUser; } @@ -46,7 +49,8 @@ public override int SaveChanges() } catch (Exception e) { - Console.WriteLine(e); + string exceptionMessage = e.ToString(); + _logger.LogError($"AppDbContext Exception: {exceptionMessage}"); throw; } diff --git a/api/Hmcr.Domain/Hangfire/WorkReportJobService.cs b/api/Hmcr.Domain/Hangfire/WorkReportJobService.cs index 7b693cc2..1cb084c6 100644 --- a/api/Hmcr.Domain/Hangfire/WorkReportJobService.cs +++ b/api/Hmcr.Domain/Hangfire/WorkReportJobService.cs @@ -257,7 +257,8 @@ private List PerformAnalyticalValidationBatchAsync(List recipients, string subject, string h // return true; //} - //Console.WriteLine("Unable to validate certificate chain."); + //_logger.LogError("Unable to validate certificate chain."); //return false; return true; From 927778840b8cd5e1e20eecc76daa0038bde28348 Mon Sep 17 00:00:00 2001 From: zgong-gov Date: Tue, 18 Apr 2023 11:40:05 -0700 Subject: [PATCH 8/8] Improve type for logger in AppDbContext --- api/Hmcr.Data/Database/Entities/AppDbContextPartial.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/Hmcr.Data/Database/Entities/AppDbContextPartial.cs b/api/Hmcr.Data/Database/Entities/AppDbContextPartial.cs index 607a2127..24b73e08 100644 --- a/api/Hmcr.Data/Database/Entities/AppDbContextPartial.cs +++ b/api/Hmcr.Data/Database/Entities/AppDbContextPartial.cs @@ -27,7 +27,7 @@ public partial class AppDbContext private const string AppLastUpdateUserGuid = "AppLastUpdateUserGuid"; private const string AppLastUpdateTimestamp = "AppLastUpdateTimestamp"; - private readonly ILogger _logger; + private readonly ILogger _logger; public readonly HmcrCurrentUser _currentUser; public AppDbContext(DbContextOptions options, ILogger logger, HmcrCurrentUser currentUser)