コード例 #1
0
    def run_async(self, path, pram, report_name, pformat="pdf"):
        rs = ReportingService(self.session)
        rr = ReportExecutionRequest()
        rr.setReportUnitUri(path)
        rr.setOutputFormat(pformat)
        rr.setParameters(pram)
        rr.setAsync(True)
        if pformat == "html":
            rr.setAttachmentsPrefix("./images/")
            #rr.setIgnorePagination(True)
        try:
            req = rs.newReportExecutionRequest(rr)
            res = req.run().getResult("content")
            res = json.loads(res)
            resp = self.prepareResponse(res, res.get("requestId"))
            resp["status"] = res.get("status")
            return resp
        except Exception as e:
            if isinstance(e, Unauthorized):

                raise Unauthorized
            else:
                frappe.throw(
                    _("Error in report %s, server error is: %s." %
                      (self.doc.jasper_report_name, e)))
コード例 #2
0
	def getAttachment(self, reqId, expId, attachmentId):
		try:
			rs = ReportingService(self.session)
			rexecreq = rs.reportExecutionRequest(reqId, expId)
			content = rexecreq.export().attachment(attachmentId)
			return content
		except NotFound:
			frappe.throw(_("Not Found."))
コード例 #3
0
	def getReport(self, reqId, expId):
		try:
			rs = ReportingService(self.session)
			rexecreq = rs.reportExecutionRequest(reqId, expId)
			report = rexecreq.export().outputResource().getResult("content")
			return report
		except NotFound:
			frappe.throw(_("Not Found."))
コード例 #4
0
	def getAttachment(self, reqId, expId, attachmentId):
		try:
			rs = ReportingService(self.session)
			rexecreq = rs.reportExecutionRequest(reqId, expId)
			content = rexecreq.export().attachment(attachmentId)
			return content
		except NotFound:
			frappe.throw(_("Not Found."))
コード例 #5
0
	def getReport(self, reqId, expId):
		try:
			rs = ReportingService(self.session)
			rexecreq = rs.reportExecutionRequest(reqId, expId)
			report = rexecreq.export().outputResource().getResult("content")
			return report
		except NotFound:
			frappe.throw(_("Not Found."))
コード例 #6
0
	def polling(self, reqId):
		res = []
		try:
			rs = ReportingService(self.session)
			rexecreq = rs.reportExecutionRequest(reqId)
			status = rexecreq.status().content
			status = json.loads(status)
			if status.get("value") == "ready":
				detail = self.reportExecDetail(rexecreq)
				res = self.prepareResponse(detail, reqId)
				if res.get('status', "") == "not ready":
					res = self.prepareResponse({}, reqId)
				else:
					res["status"] = "ready"
			elif status.get("value") == "failed":
				frappe.throw(_("Error in report %s, server error is: %s." % (self.doc.jasper_report_name, status['errorDescriptor'].get('message'))))
			else:
				res = self.prepareResponse({}, reqId)
		except NotFound:
			frappe.throw(_("Not Found."))
		return res
コード例 #7
0
	def polling(self, reqId):
		res = []
		try:
			rs = ReportingService(self.session)
			rexecreq = rs.reportExecutionRequest(reqId)
			status = rexecreq.status().content
			status = json.loads(status)
			if status.get("value") == "ready":
				detail = self.reportExecDetail(rexecreq)
				res = self.prepareResponse(detail, reqId)
				if res.get('status', "") == "not ready":
					res = self.prepareResponse({}, reqId)
				else:
					res["status"] = "ready"
			elif status.get("value") == "failed":
				frappe.throw(_("Error in report %s, server error is: %s." % (self.doc.jasper_report_name, status['errorDescriptor'].get('message'))))
			else:
				res = self.prepareResponse({}, reqId)
		except NotFound:
			frappe.throw(_("Not Found."))
		return res
コード例 #8
0
	def run_async(self, path, pram, report_name, pformat="pdf"):
		rs = ReportingService(self.session)
		rr = ReportExecutionRequest()
		rr.setReportUnitUri(path)
		rr.setOutputFormat(pformat)
		rr.setParameters(pram)
		rr.setAsync(True)
		if pformat == "html":
			rr.setAttachmentsPrefix("./images/")
			#rr.setIgnorePagination(True)
		try:
			req = rs.newReportExecutionRequest(rr)
			res = req.run().getResult("content")
			res = json.loads(res)
			resp = self.prepareResponse(res, res.get("requestId"))
			resp["status"] = res.get("status")
			return resp
		except Exception as e:
			if isinstance(e, Unauthorized):

				raise Unauthorized
			else:
				frappe.throw(_("Error in report %s, server error is: %s." % (self.doc.jasper_report_name, e)))