You are not logged in.
Hello guys,
I have a system that uses reportserver webservices to generate reports.
my system access reportserver like this:
http://localhost:8180/reportserver/reportserver/reportexport?id=16&p_policy_id=$id
now I need to save the result of every report generated into a teamspace(specific folder.. just like the option Send To Teamspace under Executed reports)
I believe I need to create a hook for it but not quite sure how to do it..
I would appreciate any help or direction on this.
thanks in advance.
Last edited by marcosfilho (2015-06-15 23:30:41)
Offline
Hi Marcos,
let me try to understand this. You have a system A and a system RS. RS is the system on which you run reportserver. Now from system A you call
http://localhost:8180/reportserver/reportserver/reportexport?id=16&p_policy_id=$id
which accesses RS and its reportserver to get back some report. It then does something with it and in the end you also want to store the result in various TeamSpaces.
Is that somewhat correct?
Questions: Do you want to store the report as it came frome the reportexport in a TeamSpace or is it something which is slightly adapted? How do you know in which TeamSpaces
to store the report? Is that a simple static list or something more complex? For example, one way of doing what you want would be to create a script "exportAndStoreInTS" which
does the following:
- it gathers the URL parameters as does reportexport and then executes the report.
- it stores the result in the TeamSpaces
- it returns the result to the caller
Would that do it?
Cheers
-Arno
Offline
Arno,
thanks for your ideas:
It could work like this:
System A calls reportserver like this: http://localhost:8180/reportserver/reportserver/reportexport?key=exportAndStoreInTS&p_policy_id=$id
exportAndStoreInTS is a Script report that will do:
1 - exportAndStoreInTS gathers the URL parameters as does reportexport and then executes the report(report id = 16).
2 - exportAndStoreInTS stores the result in the TeamSpaces ( it will be a static teamspace and folder. example: TeamSpace: MySystem - Folder: history)
3- exportAndStoreInTS returns the result to the caller
i think it is pretty straightforward.. nothing complex.
so..
1 - how could I get the result of report 16 (it would be an html returned from report id = 16 -> return new CompiledHtmlReportImpl(report))
2 - how can I store it in the specific static teamspace/folder
3 - how can i return the result to the caller (system A) .. i think i could just return the new CompiledHtmlReportImpl(report) as number 1 ?
thanks a lot for your support, mate. very much appreciated.
Offline
maybe it could be simple like this:
filesystem/bin/report/myScriptReport.rs
//to make it simple im not including parameters neither any logic here
def report = """\
<html?
<body>
something here
</body>
</html>
"""
compiledReport = new CompiledHtmlReportImpl(report)
// here I need to save the compiledReport to a specific teamspace/folder
return compiledReport
then I create a script Report under Reportmanager with the key myreport
then system A can make this call: http://localhost:8180/reportserver/reportserver/reportexport?key=myreport
does that work? or I actually need to follow the 3 steps mentioned in the earlier comment?
Offline
Hi Marcos,
yes this could work. As for storing the report in a TeamSpace, there is a bit of work involved as we do not yet have a nice API for this to be used by scripts. Here is the basic
idea. If you have a CompiledReport object. Use the
net.datenwerke.rs.compiledreportstore.CompiledReportStoreService
as follows to obtain a PersistentCompiledReport
def compiledReportService = GLOBALS.getInstance(CompiledReportStoreService.class)
def persistentReport = compiledReportService.toPersistenReport(compiledReport, report);
if you do not want to store the reference to the actual report you can just provide NULL as second parameter. Then to store it in the TeamSpace you'll need to create an object type
net.datenwerke.rs.scheduleasfile.service.scheduleasfile.entities.ExecutedReportFileReference
which references your persistent report. Have a look at net.datenwerke.rs.scheduleasfile.server.scheduleasfile.ScheduleAsFileRpcServiceImpl for further info.
One other thing I thought of was that you might also be able to use a ReportExecutionNotificationHook. This allows you to be notified of a successful report execution. You
could then check if this was triggered via a servlet call (see if you can inject an HttpServletRequest) and check for a special parameter. If this special parameter is set
then you store the report in a TeamSpace.
Cheers
-Arno
Offline
Thanks, mate. That gives me a direction. I'll have a look and let you know how it goes.
Offline
Hey Arno,
I had a look at the class net.datenwerke.rs.scheduleasfile.server.scheduleasfile.ScheduleAsFileRpcServiceImpl and came up with the following script:
import groovy.sql.Sql
import groovy.xml.*
import net.datenwerke.rs.base.service.reportengines.table.output.object.*
import java.util.Date;
import net.datenwerke.rs.core.service.datasourcemanager.entities.DatasourceDefinition;
import net.datenwerke.rs.core.service.datasourcemanager.DatasourceService;
import net.datenwerke.rs.base.service.datasources.definitions.DatabaseDatasource;
import net.datenwerke.dbpool.config.ConnectionPoolConfig;
import net.datenwerke.dbpool.DbPoolService;
import java.sql.Connection;
import java.util.concurrent.Future;
import java.text.SimpleDateFormat;
import net.datenwerke.rs.core.service.reportmanager.engine.basereports.CompiledHtmlReportImpl
import groovy.json.*
import org.apache.commons.lang.StringEscapeUtils
import net.datenwerke.gxtdto.server.dtomanager.DtoService;
import net.datenwerke.rs.compiledreportstore.CompiledReportStoreService;
import net.datenwerke.rs.compiledreportstore.entities.PersistentCompiledReport;
import net.datenwerke.rs.core.client.reportexporter.dto.ReportExecutionConfigDto;
import net.datenwerke.rs.core.client.reportmanager.dto.reports.ReportDto;
import net.datenwerke.rs.core.service.reportmanager.ReportDtoService;
import net.datenwerke.rs.core.service.reportmanager.ReportExecutorService;
import net.datenwerke.rs.core.service.reportmanager.ReportService;
import net.datenwerke.rs.core.service.reportmanager.engine.CompiledReport;
import net.datenwerke.rs.core.service.reportmanager.engine.config.RECReportExecutorToken;
import net.datenwerke.rs.core.service.reportmanager.engine.config.ReportExecutionConfig;
import net.datenwerke.rs.core.service.reportmanager.entities.reports.Report;
import net.datenwerke.rs.scheduleasfile.client.scheduleasfile.rpc.ScheduleAsFileRpcService;
import net.datenwerke.rs.scheduleasfile.server.scheduleasfile.events.ExportReportIntoTeamSpaceFailedEvent;
import net.datenwerke.rs.scheduleasfile.service.scheduleasfile.entities.ExecutedReportFileReference;
import net.datenwerke.rs.scheduler.service.scheduler.exceptions.InvalidConfigurationException;
import net.datenwerke.rs.teamspace.service.teamspace.TeamSpaceService;
import net.datenwerke.rs.teamspace.service.teamspace.entities.TeamSpace;
import net.datenwerke.rs.teamspace.service.teamspace.entities.TeamSpaceRole;
import net.datenwerke.rs.tsreportarea.client.tsreportarea.dto.AbstractTsDiskNodeDto;
import net.datenwerke.rs.tsreportarea.service.tsreportarea.TsDiskService;
import net.datenwerke.rs.tsreportarea.service.tsreportarea.entities.AbstractTsDiskNode;
import net.datenwerke.rs.tsreportarea.service.tsreportarea.entities.TsDiskFolder;
import net.datenwerke.rs.tsreportarea.service.tsreportarea.entities.TsDiskRoot;
def report = """\
<html >
<head>
<meta charset="UTF-8" />
<style>
@font-face {
font-family: "ubuntumono";
src: url("UbuntuMono-R.ttf");
-fs-pdf-font-embed: embed;
-fs-pdf-font-encoding: Identity-H;
}
* {
font-family: "ubuntumono";
}
</style>
</head>
<body>
<p>Enrollment Statement </p>
<ul>
<li>Full name: <span> 朱凡鲁</span> </li>
</ul>
</body>
</html>
""";
CompiledReport cReport = new CompiledHtmlReportImpl(report);
def compiledReportService = GLOBALS.getInstance(CompiledReportStoreService.class)
def pReport = compiledReportService.toPersistenReport(cReport, null);
def tsService = GLOBALS.getInstance(TsDiskService.class)
//PersistentCompiledReport pReport = compiledReportService.toPersistenReport(cReport, orgReport);
ExecutedReportFileReference ref = new ExecutedReportFileReference();
ref.setCompiledReport(pReport);
ref.setOutputFormat("html");
ref.setDescription("desc");
ref.setName("REPORT_90");
AbstractTsDiskNode node = tsService.getNodeById(3); //this is the folder's id - I looked up in the DB table RS_TS_DISK_FOLDER
tout.println(node.getName()); // it prints the correct name
node.addChild(ref);
tsService.persist(ref);
tsService.merge(node);
this scripts runs fine in the terminal however it doesnt save the report into that folder (I verified it through the UI as well as the db tables RS_COMPILED_REPORT,RS_EXEC_REPORT_AS_FILE_REF )
any advice will be very much appreciated.
thanks
Offline
Did you run the script in commit mode?
Offline
shame on me. exec -c script.groovy works!!
thanks a lot!!
Offline