From cb272f41327e14aeec3d30a4c6be58aebcfcce96 Mon Sep 17 00:00:00 2001 From: "honza.pofider@seznam.cz" Date: Sat, 20 Dec 2014 13:07:31 +0100 Subject: [PATCH] added support for preview header --- .../Impl/ReportingServerManagerBase.cs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/JsReportVSTools/Impl/ReportingServerManagerBase.cs b/JsReportVSTools/Impl/ReportingServerManagerBase.cs index 1d918a4..44481c8 100644 --- a/JsReportVSTools/Impl/ReportingServerManagerBase.cs +++ b/JsReportVSTools/Impl/ReportingServerManagerBase.cs @@ -59,10 +59,21 @@ public RemoteTask SynchronizeTemplatesAsync() public RemoteTask RenderAsync(string shortid, string sampleDataName) { dynamic rs = CreateReportingService(); - + return RemoteTask.ServerStart(async cts => { - dynamic report = await rs.RenderAsync(shortid, PrepareSampleData(sampleDataName)); + dynamic renderRequest = Activator.CreateInstance(LoadType("jsreport.Client.RenderRequest")); + renderRequest.template = (dynamic) Activator.CreateInstance(LoadType("jsreport.Client.Entities.Template")); + renderRequest.template.shortid = shortid; + renderRequest.data = PrepareSampleData(sampleDataName); + renderRequest.options = (dynamic)Activator.CreateInstance(LoadType("jsreport.Client.RenderOptions")); + try + { + renderRequest.options.preview = true; + }//back compatibility + catch (Exception e) { } + + dynamic report = await rs.RenderAsync(renderRequest); return new Report { Content = report.Content, @@ -104,11 +115,16 @@ public override object InitializeLifetimeService() } protected Type LoadReportingServiceType() + { + return LoadType("jsreport.Client.ReportingService"); + } + + protected Type LoadType(string typeName) { AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve; AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; - return AppDomain.CurrentDomain.Load("jsreport.Client").GetType("jsreport.Client.ReportingService"); + return AppDomain.CurrentDomain.Load("jsreport.Client").GetType(typeName); } private readonly IList _triedWithoutVersion = new List();