From 3c650ba980b8eecb00a4ddddd568e308e9777209 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 21 Jul 2020 22:01:54 +0000 Subject: [PATCH] --- .../ControllerHelpers/ApiCustomExceptionFilter.cs | 4 +++- server/AyaNova/generator/CoreJobBackup.cs | 14 ++++++++------ server/AyaNova/generator/CoreJobNotify.cs | 7 ++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/server/AyaNova/ControllerHelpers/ApiCustomExceptionFilter.cs b/server/AyaNova/ControllerHelpers/ApiCustomExceptionFilter.cs index 349a33f9..d69b0dbb 100644 --- a/server/AyaNova/ControllerHelpers/ApiCustomExceptionFilter.cs +++ b/server/AyaNova/ControllerHelpers/ApiCustomExceptionFilter.cs @@ -80,6 +80,8 @@ namespace AyaNova.Api.ControllerHelpers if (loggableError) log.LogError(context.Exception, "Error"); + //Notify ops notification issue + NotifyEventProcessor.AddOpsProblemEvent("Server API internal error, see log for more details", context.Exception).Forget();//.Wait(); HttpResponse response = context.HttpContext.Response; response.StatusCode = (int)status; @@ -87,7 +89,7 @@ namespace AyaNova.Api.ControllerHelpers //This line is critical, without it the response is not proper and fails in various clients (postman, xunit tests with httpclient) context.ExceptionHandled = true; - + response.WriteAsync(JsonConvert.SerializeObject( new ApiErrorResponse(ApiErrorCode.API_SERVER_ERROR, "Server internal error", "See server log for details"), diff --git a/server/AyaNova/generator/CoreJobBackup.cs b/server/AyaNova/generator/CoreJobBackup.cs index 38eda510..ea0a2c4f 100644 --- a/server/AyaNova/generator/CoreJobBackup.cs +++ b/server/AyaNova/generator/CoreJobBackup.cs @@ -43,7 +43,7 @@ namespace AyaNova.Biz } } AyaNova.Api.ControllerHelpers.ApiServerState apiServerState = null; - string BackupStatusNotification = string.Empty; + try { BackupIsRunning = true; @@ -53,7 +53,8 @@ namespace AyaNova.Biz apiServerState.SetClosed("BACKUP RUNNING"); var jobstartmessage = $"Starting backup job {(OnDemand ? "manual / on demand" : "scheduled") } "; await JobsBiz.LogJobAsync(Guid.Empty, jobstartmessage); - BackupStatusNotification = jobstartmessage + "\n"; + + DateTime dtStartBackup=DateTime.Now; log.LogDebug("Backup starting"); var DemandFileNamePrepend = OnDemand ? "manual-" : string.Empty; //************* @@ -80,7 +81,7 @@ namespace AyaNova.Biz { var ms = "Backup of database completed OK"; log.LogDebug(ms); - BackupStatusNotification += (ms + "\n"); + } else { @@ -96,8 +97,7 @@ namespace AyaNova.Biz await JobsBiz.LogJobAsync(Guid.Empty, $"Attachments backup starting"); FileUtil.BackupAttachments(DemandFileNamePrepend); var ms = "Backup of file attachments completed OK"; - log.LogDebug(ms); - BackupStatusNotification += (ms + "\n"); + log.LogDebug(ms); } @@ -109,6 +109,8 @@ namespace AyaNova.Biz //*************** log.LogDebug("Backup completed"); + var duration=DateTime.Now - dtStartBackup; + await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.BackupStatus, $"Backup completed {(OnDemand ? "manual / on demand" : "scheduled")} duration: {duration.ToString()} server re-opened"); } catch (Exception ex) { @@ -126,7 +128,7 @@ namespace AyaNova.Biz apiServerState.ResumePriorState(); BackupIsRunning = false; await JobsBiz.LogJobAsync(Guid.Empty, $"Backup - fully complete, server re-opened"); - await NotifyEventProcessor.AddGeneralNotifyEvent(NotifyEventType.BackupStatus, $"Backup completed server re-opened\nStatus:{BackupStatusNotification}"); + } } diff --git a/server/AyaNova/generator/CoreJobNotify.cs b/server/AyaNova/generator/CoreJobNotify.cs index c83d1c18..3f4ccf74 100644 --- a/server/AyaNova/generator/CoreJobNotify.cs +++ b/server/AyaNova/generator/CoreJobNotify.cs @@ -158,7 +158,12 @@ namespace AyaNova.Biz { log.LogTrace($"DeliverSMTP deliving notify event: {ne}"); throw new System.NotImplementedException("DeliverSMTP: NOT IMPLEMENTED YET"); - + //todo: //Open question: what to do with failed deliveries? + //we dont' want them piling up but we don't want to just dump them do we? + //it should be only mail ones that fail, not app ones, there's no way for an app delivery to fail as it's just put in a table + //### PLAN if it's an smtp delivery that fails and it's to someone who can be delivered in app then it should send an inapp notification of + //delivery failure and still delete the smtp delivery + //If it's not possible to notify the person via in app of the failed smtp then perhaps it notifies OPS personnel and biz admin personnel }