logo

Warning: The forum is now for consultation only. Please use GitHub Discussions to post any questions or comments.


Welcome Guest ! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
Harikrishna  
#1 Posted : Friday, March 3, 2017 11:03:20 AM(UTC)
Harikrishna

Rank: Newbie

Groups: Registered
Joined: 2/21/2017(UTC)
Posts: 1
India
Location: Hyderabad

Hi Team,

We are having one seal report file (.srex) which had restrictions(i.e., input parameters), and need to show the report through Web API. So we written following code to show the report on HTML file. But the generated HTML file not showing restrictions for filter functionality. Please suggest us to over come the situation.
Note: 1) In your older references you are using Process.Start(filepath) to generate HTML file, But Process.Start(filepath) won't work while we published Web API in IIS.
2)And our environment not using .cshtml as per our project requirements.

[HttpGet]
[Route("api/GetSealReport")]
public HttpResponseMessage GetSealReport()
{
try
{
Repository repository = Repository.Create();

Report report = Report.LoadFromFile(System.Web.HttpContext.Current.Server.MapPath("~/Dashboard.srex"), repository);
report.Models[0].Restrictions[0].UseAsParameter = true;

ReportExecution execution = new ReportExecution() { Report = report };
execution.Execute();
while (report.Status != ReportStatus.Executed) System.Threading.Thread.Sleep(100);
Report previousReport = report;
string result = execution.GenerateHTMLResult();
if (!string.IsNullOrEmpty(result))
{

string filePath = result;

using (MemoryStream ms = new MemoryStream())
{
using (FileStream file = new FileStream(filePath, FileMode.Open, FileAccess.Read))
{
byte[] bytes = new byte[file.Length];
file.Read(bytes, 0, (int)file.Length);
ms.Write(bytes, 0, (int)file.Length);

HttpResponseMessage httpResponseMessage = new HttpResponseMessage();
httpResponseMessage.Content = new ByteArrayContent(bytes.ToArray());
httpResponseMessage.Content.Headers.Add("x-filename", execution.Report.ResultFileName);
httpResponseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
httpResponseMessage.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline");
httpResponseMessage.Content.Headers.ContentDisposition.FileName = execution.Report.ResultFileName;
httpResponseMessage.StatusCode = HttpStatusCode.OK;
return httpResponseMessage;
}
}
}
return this.Request.CreateResponse(HttpStatusCode.NotFound, "File not found.");
}
catch (Exception ex)
{
return this.Request.CreateResponse(HttpStatusCode.InternalServerError, ex);
}
}
epf  
#2 Posted : Monday, March 6, 2017 3:06:45 PM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
Here you are only displaying a static html result file...so you cannot re-execute the report with restrictions.

Depending on your framework, you have to re-implement part of the controller to execute report dynamically,
You have to check and take the code from HomeController.cs and implement at least:
ActionExecuteReport
ActionRefreshReport
ActionCancelReport

plus more or less all procedures starting by Action as they are called by the report itself during execution...
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.