Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
146513 | Aug 6,2019 08:36 PM UTC | Sep 4,2019 12:05 PM UTC | Report Platform | 3 |
![]() |
Tags: Report Viewer |
public partial class HomeController : Controller, IReportController
{
private IMemoryCache _cache;
private IHostingEnvironment _hostingEnvironment;
public HomeController(IMemoryCache memoryCache, IHostingEnvironment hostingEnvironment)
{
_cache = memoryCache;
_hostingEnvironment = hostingEnvironment;
}
[HttpPost]
public object PostReportAction([FromBody] Dictionary<string, object> jsonResult)
{
return ReportHelper.ProcessReport(jsonResult, this, this._cache);
}
[ActionName("GetResource")]
[AcceptVerbs("GET")]
public object GetResource(ReportResource resource)
{
return ReportHelper.GetResource(resource, this, _cache);
}
[HttpPost]
public object PostFormReportAction()
{
return ReportHelper.ProcessReport(null, this, this._cache);
}
public void OnInitReportOptions(ReportViewerOptions reportOption)
{
reportOption.ReportModel.ReportServerCredential = new System.Net.NetworkCredential("<no user>", "<no password>");
Reportserver reportserver = new Reportserver(_hostingEnvironment);
reportOption.ReportModel.ReportingServer = reportserver;
}
public void OnReportLoaded(ReportViewerOptions reportOption)
{
}
}
public class Reportserver : ReportingServer
{
private IHostingEnvironment _hostingEnvironment;
public Reportserver(IHostingEnvironment hostingEnvironment)
{
_hostingEnvironment = hostingEnvironment;
}
public override Stream GetReport()
{
string basePath = _hostingEnvironment.WebRootPath + "/ReportData/";
FileStream inputStream = new FileStream(basePath+this.ReportPath+".rdl", FileMode.Open, FileAccess.Read);
return inputStream;
}
}
|
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.