var reportOptions = { "report" : { "title": null, "query": { "name": "Teildachflaeche", "conditionField": "TDF_UID", "conditionFieldValue": null, "conditionOperator": "=" }, "graphics": [], "mapCenter": { "x": null, "y": null }, "xml": "/solarpotential/ReportConfig.xml", "url" : "https://svc.geo.lu.ch/agssec/rest/services/print/reporter/MapServer/exts/ReportServices/ReportBuilder/CreateReport", "symbolPolygon" : { "color": null, "outline": { "color": [0,255,255,255], "width": 1.5, "type": "esriSLS", "style": "esriSLSSolid" }, "type": "esriSFS", "style": "esriSFSSolid" } } }; var titlePlaceholder = "max. 30 Zeichen"; var subtitlePlaceholder = "max. 40 Zeichen"; var errorMessage = "Fehler aufgetreten. Bitte versuchen sie es mit einem kleineren Massstab erneut."; function startReporting () { console.log("the buck starts here"); var params = _compileReportServiceParameters(); dojo.byId("reportRun").style.display = "inline"; _showInfo(false); // this.printouts.add(params.exportOptions.guid, { params: params }); ?? reporter.report(params); } function addGraphicToReport (graphic) { reportOptions.report.graphics = []; // empty graphics array reportOptions.report.graphics.push({ geometry: graphic.geometry.toJson(), geometryType: graphic.geometry.type, symbol: reportOptions.report.symbolPolygon, refScale: 1000 }); //console.log(reportOptions.report.graphics); } function _compileReportServiceParameters () { //var scale = _getPrintScale(); var params = new geo.tasks.ReportServiceParameters(); // new "template" of report service params params = _compileMapOptions(params); params = _compileLayoutOptions(params); params = _compileGraphicsOptions(params); console.log(params); return params; } function _compileMapOptions (params) { var cp = _getCenterPoint(); params.reportOptions.pages[0].mapImages[0].mapOptions.centerPoint.x = reportOptions.report.mapCenter.x; params.reportOptions.pages[0].mapImages[0].mapOptions.centerPoint.y = reportOptions.report.mapCenter.y; params.reportOptions.pages[0].attributeTables[0].Query.name = reportOptions.report.query.name; params.reportOptions.pages[0].attributeTables[0].Query.conditionField = reportOptions.report.query.conditionField; params.reportOptions.pages[0].attributeTables[0].Query.conditionFieldValue = reportOptions.report.query.conditionFieldValue; params.reportOptions.pages[0].attributeTables[0].Query.conditionOperator = reportOptions.report.query.conditionOperator; params.reportOptions.pages[0].mapImages[0].mapOptions.scale = 1000; // fixed scale prints return params; } function _compileLayoutOptions (params) { params.reportOptions.xmlConfig = reportOptions.report.xml; params.reportOptions.title = reportOptions.report.title; return params; } function _compileGraphicsOptions (params) { params.reportOptions.pages[0].mapImages[0].graphics = reportOptions.report.graphics; return params; } // get print map scale (scale selection in print form is scale-limited) function _getPrintScale () { var lvl, pel, print_SCL; lvl = map.getLevel(); pel = dojo.byId("print_sel_PSC"); if (pel != null) { if (pel.value != "init") { print_SCL = pel.value; } else { print_SCL = lodsArr[lvl].scale; } } else { print_SCL = lodsArr[lvl].scale; // LOD to scale } return print_SCL; } // get print center point (map center or print preview center (if active)) function _getCenterPoint () { var pScrLeft, pScrTop, pScrW, pScrH, pScrCenterX, pScrCenterY; // map center is current screen center if (!(dojo.byId('printPreview'))) { return map.extent.getCenter(); } // map center is current preview box center else { if (dojo.byId('printPreview').style.display == "block") { pScrLeft = dojo.style('printPreview', "left"); pScrTop = dojo.style('printPreview', "top"); pScrW = dojo.style('printPreview', "width"); pScrH = dojo.style('printPreview', "height"); pScrCenterX = pScrLeft + (pScrW / 2); pScrCenterY = pScrTop + (pScrH / 2); return map.toMap(new esri.geometry.Point(pScrCenterX, pScrCenterY)); } else { return map.extent.getCenter(); } } } // get print quality based on printed scale and outputFormat function _getQuality (scale) { var format = printOptions.print.format; var qualities = printOptions.print.quality; var quality = qualities[format]; if (!quality) { quality = qualities["default"]; } return quality[scale]; } // get path to layout mxd, depending on page size and page orientation function _getPrintLayout (orientation, size) { var layouts = printOptions.print.layout[orientation]; if (layouts != undefined) { return layouts[size]; } console.error("ERROR: Konfiguration für Layouts (App '" + printOptions.print.appName + "') nicht gefunden."); return null; } function _formatDate (date) { var dateString = dojo.date.locale.format(date, { datePattern: "yyyy-MM-dd'T'", timePattern: "HH:mm:ss" }); return dateString.replace(" ", ""); } function _generateUid () { var dateObject = new Date(); var uniqueId = dateObject.getTime(); return uniqueId; } function showReportingOutput (result, timeUsed) { dojo.byId("reportRun").style.display = "none"; _showInfo(true, result.url); // this._addPrintoutToList(result); window.open(result.url, '_blank'); } function onReportError (error) { console.error("ERROR reporting: " + error); dojo.byId("reportRun").style.display = "none"; _showError(true, error); } function _showInfo (show, url) { var msg = "Dossier erfolgreich erstellt.
Falls das PDF nicht automatisch in einem neuen Fenster öffnet, klicken Sie hier."; dojo.byId("reportSuccess").innerHTML = msg; var vis; if (show) { vis = "block"; } else { vis = "none"; } dojo.byId("reportSuccess").style.display = vis; } function _showError (show, error) { var msg = errorMessage; // defined at the top of the page if (error && error.message.length > 0) { if (error.message.indexOf("Service may be stopped") != -1) { msg = "Fehler aufgetreten. " + "Der Druckdienst ist nicht verfügbar. Versuchen Sie es später erneut " + "oder wenden Sie sich an Ihren Administrator."; } else { msg = error.message; } } dojo.byId("reportError").innerHTML = msg; var vis; if (show) { vis = "block"; } else { vis = "none"; } dojo.byId("reportError").style.display = vis; }