This commit is contained in:
2021-12-28 16:24:36 +00:00
parent 681c74d73d
commit 61d344d124
3 changed files with 75 additions and 20 deletions

View File

@@ -161,29 +161,79 @@ export default {
);
}
jobStatus = jobStatus.data;
if (jobStatus == 4 || jobStatus == 0) {
throw new Error("Job failed");
}
if (jobStatus == 3) {
/*
Absent = 0,
Sleeping = 1,
Running = 2,
Completed = 3,
Failed = 4
*/
//check for any terminal status
if (jobStatus != 1 && jobStatus != 2) {
this.jobActive = false;
//success, get the report url name
const jobLogRes = await window.$gz.api.get(
`job-operations/logs/${jobId}`
);
if (Array.isArray(jobLogRes.data)) {
//walk the array backwards as it's probably the final entry in the log
for (var i = jobLogRes.data.length - 1; i >= 0; i--) {
var v = jobLogRes.data[i].statusText;
if (v.includes("reportfilename")) {
const o = JSON.parse(v);
reportUrl = window.$gz.api.reportDownloadUrl(
o.reportfilename
);
//get final entry is error or success
var finalEntry = jobLogRes.data[jobLogRes.data.length - 1];
console.log("final entry:", finalEntry);
// if (Array.isArray(jobLogRes.data)) {
// //walk the array backwards as it's probably the final entry in the log
// for (var i = jobLogRes.data.length - 1; i >= 0; i--) {
// var v = jobLogRes.data[i].statusText;
// if (v.includes("reportfilename")) {
// const o = JSON.parse(v);
// reportUrl = window.$gz.api.reportDownloadUrl(
// o.reportfilename
// );
// }
// }
// }
if (jobStatus == 4 || jobStatus == 0) {
/*
report template processing error example
{
"created": "2021-12-28T16:13:01.13624Z",
"statusText": "rendererror:exception,\"PuppeteerSharp -> Evaluation failed: TypeError: Assignment to constant variable.\n at ayPrepareData (<anonymous>:7:2)\n at ayPreRender (C:\\data\\code\\raven\\server\\AyaNova\\resource\\rpt\\ay-report.js:8:38)\n at eval (eval at waitForPredicatePageFunction (:3:23), <anonymous>:3:9)\n at onRaf (__puppeteer_evaluation_script__:50:35)\n at pollRaf (__puppeteer_evaluation_script__:43:15)\n at waitForPredicatePageFunction (__puppeteer_evaluation_script__:8:22)\r\n\"",
"jobId": "3deeac20-b49d-46d8-a5f6-891b7d1049f8"
}
*/
throw new Error("Job failed");
}
if (jobStatus == 3) {
/*
example success
{
"created": "2021-12-28T16:14:32.184925Z",
"statusText": "{\"reportfilename\":\"tixcxh25aop.pdf\"}",
"jobId": "c251aa88-6763-4065-a1d4-13fdeb947a72"
}
*/
this.jobActive = false;
//success, get the report url name
// const jobLogRes = await window.$gz.api.get(
// `job-operations/logs/${jobId}`
// );
if (Array.isArray(jobLogRes.data)) {
//walk the array backwards as it's probably the final entry in the log
for (var i = jobLogRes.data.length - 1; i >= 0; i--) {
var v = jobLogRes.data[i].statusText;
if (v.includes("reportfilename")) {
const o = JSON.parse(v);
reportUrl = window.$gz.api.reportDownloadUrl(
o.reportfilename
);
}
}
}
}
this.jobActive = false;
this.jobActive = false;
}
}
}
//job ran to completion, get the report file name and fetch it