This commit is contained in:
@@ -136,7 +136,7 @@ export default {
|
||||
//Meta data from client for use by report script
|
||||
reportDataOptions.ClientMeta = window.$gz.api.reportClientMetaData();
|
||||
this.jobActive = true;
|
||||
var reportUrl = null;
|
||||
|
||||
try {
|
||||
let jobId = await window.$gz.api.upsert(
|
||||
"report/render-job",
|
||||
@@ -177,79 +177,72 @@ export default {
|
||||
);
|
||||
//get final entry is error or success
|
||||
var finalEntry = jobLogRes.data[jobLogRes.data.length - 1];
|
||||
console.log("final entry:", finalEntry);
|
||||
const finalEntryObject = JSON.parse(finalEntry.statusText);
|
||||
|
||||
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"
|
||||
}
|
||||
"{\"rendererror\":{\"pagelog\":null,\"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\"}}"
|
||||
*/
|
||||
const o = JSON.parse(finalEntry.statusText);
|
||||
console.log("Error object", o);
|
||||
|
||||
var e = `${this.$ay.t("Error")}: ${o.rendererror.exception}`;
|
||||
if (o.rendererror.pagelog) {
|
||||
e += "\n---------\n" + o.rendererror.pagelog;
|
||||
}
|
||||
|
||||
throw new Error(e);
|
||||
}
|
||||
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
|
||||
);
|
||||
var e = null;
|
||||
//any error should be in a rendererror keyed object
|
||||
if (!finalEntryObject.rendererror) {
|
||||
//unusual unknown error, shouldn't happen but just in case
|
||||
e = this.$ay.t("JobFailed");
|
||||
} else {
|
||||
//failure of some kind, either timeout, exception or exception plus pagelog
|
||||
if (finalEntryObject.rendererror.timeout) {
|
||||
//timeout
|
||||
await window.$gz.dialog.displayNoTranslationModalNotificationMessage(
|
||||
window.$gz.translation
|
||||
.get("ReportRenderTimeOut")
|
||||
.replace(
|
||||
"{0}",
|
||||
finalEntryObject.rendererror.timeoutsetting
|
||||
),
|
||||
null,
|
||||
"error",
|
||||
`${this.$store.state.helpUrl}/ay-report-timeout`
|
||||
);
|
||||
//we're done here
|
||||
this.reject(error);
|
||||
} else {
|
||||
//exception
|
||||
e = `${this.$ay.t("JobFailed")}: ${
|
||||
finalEntryObject.rendererror.exception
|
||||
}`;
|
||||
if (finalEntryObject.rendererror.pagelog) {
|
||||
e += "\n---------\n" + finalEntryObject.rendererror.pagelog;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Error(e);
|
||||
}
|
||||
if (jobStatus == 3) {
|
||||
if (!finalEntryObject.reportfilename) {
|
||||
throw new Error(
|
||||
`${this.$ay.t(
|
||||
"JobCompleted"
|
||||
)}: But no file name was returned, cannot open report URL`
|
||||
);
|
||||
}
|
||||
var reportUrl = window.$gz.api.reportDownloadUrl(
|
||||
o.reportfilename
|
||||
);
|
||||
if (window.open(reportUrl, "Report") == null) {
|
||||
this.reject(
|
||||
"Problem displaying report in new window. Browser must allow pop-ups to view reports; check your browser setting"
|
||||
);
|
||||
}
|
||||
|
||||
this.jobActive = false;
|
||||
this.isVisible = false;
|
||||
if (reportName != null) {
|
||||
this.resolve({ name: reportName, id: reportId });
|
||||
} else {
|
||||
this.resolve(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//job ran to completion, get the report file name and fetch it
|
||||
if (reportUrl) {
|
||||
if (window.open(reportUrl, "Report") == null) {
|
||||
this.reject(
|
||||
"Problem displaying report in new window. Browser must allow pop-ups to view reports; check your browser setting"
|
||||
);
|
||||
}
|
||||
}
|
||||
this.jobActive = false;
|
||||
this.isVisible = false;
|
||||
if (reportName != null) {
|
||||
this.resolve({ name: reportName, id: reportId });
|
||||
} else {
|
||||
this.resolve(null);
|
||||
}
|
||||
} catch (error) {
|
||||
this.jobActive = false;
|
||||
this.reject(error);
|
||||
//window.$gz.errorHandler.handleFormError(error, this);
|
||||
//window.$gz.eventBus.$emit("notify-error", this.$ay.t("JobFailed"));
|
||||
}
|
||||
},
|
||||
async open(reportDataOptions, preSelectReportId) {
|
||||
|
||||
Reference in New Issue
Block a user