This commit is contained in:
@@ -136,7 +136,7 @@ export default {
|
|||||||
//Meta data from client for use by report script
|
//Meta data from client for use by report script
|
||||||
reportDataOptions.ClientMeta = window.$gz.api.reportClientMetaData();
|
reportDataOptions.ClientMeta = window.$gz.api.reportClientMetaData();
|
||||||
this.jobActive = true;
|
this.jobActive = true;
|
||||||
var reportUrl = null;
|
|
||||||
try {
|
try {
|
||||||
let jobId = await window.$gz.api.upsert(
|
let jobId = await window.$gz.api.upsert(
|
||||||
"report/render-job",
|
"report/render-job",
|
||||||
@@ -177,79 +177,72 @@ export default {
|
|||||||
);
|
);
|
||||||
//get final entry is error or success
|
//get final entry is error or success
|
||||||
var finalEntry = jobLogRes.data[jobLogRes.data.length - 1];
|
var finalEntry = jobLogRes.data[jobLogRes.data.length - 1];
|
||||||
console.log("final entry:", finalEntry);
|
const finalEntryObject = JSON.parse(finalEntry.statusText);
|
||||||
|
|
||||||
if (jobStatus == 4 || jobStatus == 0) {
|
if (jobStatus == 4 || jobStatus == 0) {
|
||||||
/*
|
var e = null;
|
||||||
report template processing error example
|
//any error should be in a rendererror keyed object
|
||||||
{
|
if (!finalEntryObject.rendererror) {
|
||||||
"created": "2021-12-28T16:13:01.13624Z",
|
//unusual unknown error, shouldn't happen but just in case
|
||||||
"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\"",
|
e = this.$ay.t("JobFailed");
|
||||||
"jobId": "3deeac20-b49d-46d8-a5f6-891b7d1049f8"
|
} else {
|
||||||
}
|
//failure of some kind, either timeout, exception or exception plus pagelog
|
||||||
"{\"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\"}}"
|
if (finalEntryObject.rendererror.timeout) {
|
||||||
*/
|
//timeout
|
||||||
const o = JSON.parse(finalEntry.statusText);
|
await window.$gz.dialog.displayNoTranslationModalNotificationMessage(
|
||||||
console.log("Error object", o);
|
window.$gz.translation
|
||||||
|
.get("ReportRenderTimeOut")
|
||||||
var e = `${this.$ay.t("Error")}: ${o.rendererror.exception}`;
|
.replace(
|
||||||
if (o.rendererror.pagelog) {
|
"{0}",
|
||||||
e += "\n---------\n" + o.rendererror.pagelog;
|
finalEntryObject.rendererror.timeoutsetting
|
||||||
}
|
),
|
||||||
|
null,
|
||||||
throw new Error(e);
|
"error",
|
||||||
}
|
`${this.$store.state.helpUrl}/ay-report-timeout`
|
||||||
if (jobStatus == 3) {
|
);
|
||||||
/*
|
//we're done here
|
||||||
example success
|
this.reject(error);
|
||||||
{
|
} else {
|
||||||
"created": "2021-12-28T16:14:32.184925Z",
|
//exception
|
||||||
"statusText": "{\"reportfilename\":\"tixcxh25aop.pdf\"}",
|
e = `${this.$ay.t("JobFailed")}: ${
|
||||||
"jobId": "c251aa88-6763-4065-a1d4-13fdeb947a72"
|
finalEntryObject.rendererror.exception
|
||||||
}
|
}`;
|
||||||
*/
|
if (finalEntryObject.rendererror.pagelog) {
|
||||||
this.jobActive = false;
|
e += "\n---------\n" + finalEntryObject.rendererror.pagelog;
|
||||||
//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
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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) {
|
} catch (error) {
|
||||||
this.jobActive = false;
|
this.jobActive = false;
|
||||||
this.reject(error);
|
this.reject(error);
|
||||||
//window.$gz.errorHandler.handleFormError(error, this);
|
|
||||||
//window.$gz.eventBus.$emit("notify-error", this.$ay.t("JobFailed"));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async open(reportDataOptions, preSelectReportId) {
|
async open(reportDataOptions, preSelectReportId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user