Skip to content

Commit

Permalink
added support for preview header
Browse files Browse the repository at this point in the history
  • Loading branch information
pofider committed Dec 20, 2014
1 parent dfb0688 commit cb272f4
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions JsReportVSTools/Impl/ReportingServerManagerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,21 @@ public RemoteTask<int> SynchronizeTemplatesAsync()
public RemoteTask<object> RenderAsync(string shortid, string sampleDataName)
{
dynamic rs = CreateReportingService();

return RemoteTask.ServerStart<object>(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,
Expand Down Expand Up @@ -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<string> _triedWithoutVersion = new List<string>();
Expand Down

0 comments on commit cb272f4

Please sign in to comment.