From 5f01dda11afd7e858703f674a6fb9a4d9e4a349a Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Mon, 7 Mar 2022 22:58:03 +0000 Subject: [PATCH] --- .vscode/launch.json | 2 +- server/AyaNova/biz/JobsBiz.cs | 7 +++++-- server/AyaNova/generator/CoreJobNotify.cs | 19 +++++++++++-------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index f18b4927..d0cceaa8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -48,7 +48,7 @@ "AYANOVA_DATA_PATH": "c:\\temp\\ravendata", "AYANOVA_USE_URLS": "http://*:7575;", //"AYANOVA_PERMANENTLY_ERASE_DATABASE":"true", - "AYANOVA_SERVER_TEST_MODE": "true", + "AYANOVA_SERVER_TEST_MODE": "false", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-8", //"AYANOVA_REPORT_RENDERING_TIMEOUT":"1", "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small", diff --git a/server/AyaNova/biz/JobsBiz.cs b/server/AyaNova/biz/JobsBiz.cs index a05f875b..6a9b92b1 100644 --- a/server/AyaNova/biz/JobsBiz.cs +++ b/server/AyaNova/biz/JobsBiz.cs @@ -211,8 +211,11 @@ namespace AyaNova.Biz //BACKUP await CoreJobBackup.DoWorkAsync(); if (!KeepOnWorking()) return; - //NOTIFICATIONS - await CoreJobNotify.DoWorkAsync(); + + //NOTIFICATIONS + TaskUtil.Forget(Task.Run(() => CoreJobNotify.DoWorkAsync())); + // await CoreJobNotify.DoWorkAsync(); + if (!KeepOnWorking()) return; await CoreNotificationSweeper.DoWorkAsync(); if (!KeepOnWorking()) return; diff --git a/server/AyaNova/generator/CoreJobNotify.cs b/server/AyaNova/generator/CoreJobNotify.cs index 7c89660c..5a7e1cc2 100644 --- a/server/AyaNova/generator/CoreJobNotify.cs +++ b/server/AyaNova/generator/CoreJobNotify.cs @@ -403,7 +403,7 @@ namespace AyaNova.Biz DeliveryLogItem.Error = $"No email address provided for smtp delivery; event: {ne}"; } else - { + { IMailer m = AyaNova.Util.ServiceProviderProvider.Mailer; if (!ServerGlobalOpsSettingsCache.Notify.SmtpDeliveryActive) { @@ -425,8 +425,8 @@ namespace AyaNova.Biz //{"AType":34,"selectedRowIds":[355],"ReportId":9,"ClientMeta":{"UserName":"AyaNova SuperUser","Authorization":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOiIxNjQ2NzgyNTc4IiwiaXNzIjoiYXlhbm92YS5jb20iLCJpZCI6IjEifQ.ad7Acq54JCRGitDWKDJFFnqKkidbdaKaFmj-RA_RG5E","DownloadToken":"NdoU8ca3LG4L39Tj2oi3UReeeM7FLevTgbgopTPhGbA","TimeZoneName":"America/Los_Angeles","LanguageName":"en-US","Hour12":true,"CurrencyName":"USD","DefaultLocale":"en","PDFDate":"3/3/22","PDFTime":"3:38 PM"}} var reportRequest = new DataListReportRequest(); - - reportRequest.AType = ne.AyaType; + + reportRequest.AType = ne.AyaType; reportRequest.ReportId = (long)subscription.LinkReportId; reportRequest.SelectedRowIds = new long[] { ne.ObjectId }; var jwt = Api.Controllers.AuthController.GenRpt(subTranslationId); @@ -434,7 +434,7 @@ namespace AyaNova.Biz //this could be adjusted by culture if we allow user to set a culture but that's getting a bit into the weeds, likely the server default is fine var pdfDate = new DateTime().ToShortDateString(); var pdfTime = new DateTime().ToShortTimeString(); - var h12=subscription.Hour12?"true":"false"; + var h12 = subscription.Hour12 ? "true" : "false"; reportRequest.ClientMeta = JToken.Parse($"{{'UserName':'-','Authorization':'Bearer {jwt}','TimeZoneName':'{subscription.TimeZoneOverride}','LanguageName':'{subscription.LanguageOverride}','Hour12':{h12},'CurrencyName':'{subscription.CurrencyName}','DefaultLocale':'en','PDFDate':'{pdfDate}','PDFTime':'{pdfTime}'}}"); //get port number var match = System.Text.RegularExpressions.Regex.Match(ServerBootConfig.AYANOVA_USE_URLS, "[0-9]+"); @@ -447,15 +447,15 @@ namespace AyaNova.Biz else { bool done = false; - bool timedOut = false; - //todo: need a timeout here that sets done as failed due to timeout - while (!done && !timedOut) + DateTime bailAfter = DateTime.Now.AddMinutes(ServerBootConfig.AYANOVA_REPORT_RENDERING_TIMEOUT); + while (!done && DateTime.Now < bailAfter) { var status = await JobsBiz.GetJobStatusAsync((Guid)jobid); switch (status) { case JobStatus.Completed: { + done = true; //get job logs and parse file name from it JobOperationsBiz jobopsbiz = new JobOperationsBiz(ct, 1, AuthorizationRoles.BizAdmin); List log = await jobopsbiz.GetJobLogListAsync((Guid)jobid); @@ -467,11 +467,14 @@ namespace AyaNova.Biz break; } case JobStatus.Failed: + case JobStatus.Absent: throw new ApplicationException($"REPORT RENDER JOB {jobid} started but failed"); + } } - //throw new TimeoutException("JOB FAILED DUE TO REPORT RENDER TIMEOUT"); + if (!done) + throw new TimeoutException("JOB FAILED DUE TO REPORT RENDER TIMEOUT"); } } else