Question on StiMvcDesigner (MVC)

Stimulsoft Reports.NET discussion
Post Reply
Haraldf
Posts: 24
Joined: Thu Dec 05, 2013 8:21 pm

Question on StiMvcDesigner (MVC)

Post by Haraldf »

Is it possible to add some custom data to the StiMvcViewerFx?

e.g.

Code: Select all

@Html.Stimulsoft().StiMvcViewerFx(new StiMvcViewerFxOptions() { 
    ActionGetReportSnapshot = "GetReportSnapshot",
    ActionGetLocalization = "GetLocalization",
    ActionExportReport = "ExportReport",
    UserData = "MyCoolData"
})
I need this data in my Actions

Code: Select all

        public ActionResult GetReportSnapshot(string UserData )
        {
        }
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Question on StiMvcDesigner (MVC)

Post by Alex K. »

Hello,

Please see the following code:

Code: Select all

public ActionResult GetReportSnapshot(string UserData )
{
   StiReport report = StiMvcViewerFx.GetReportObject(this.Request);
   report.RegData(.....);

   return StiMvcViewerFx.GetReportSnapshotResult(this.Request, report);
}
Thank you.
Haraldf
Posts: 24
Joined: Thu Dec 05, 2013 8:21 pm

Re: Question on StiMvcDesigner (MVC)

Post by Haraldf »

Hello Alesey,

thank you for your answer, please let me restate my question.

It's somehow (very?) adavanced.

1) My Controller of the page and the controller of the Report handling are
totally separated. The even reside in differend ASP.Net MVC Areas.

2) I use AJAX + Partial layouts to load the partial views from the
reporter controller on demand.

3) I'd like to have a way to paramterize the toplevel function.

For my question I am refering to this file:

MvcMobileViewer (Razor)\MvcMobileViewer (Razor)\Controllers\.HomeController.cs

Code: Select all

        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC Stimulsoft Demo";
            return View();
        }
In my case the Index method is parameterized with some userdata string:

ReportController.cs:

Code: Select all

        public ActionResult Index(string UserData)
        {
             ViewBag.UserData = UserData; // neet to happen: persist this value as Index is the starting call
        
            return PartialView("_Viewer.cshtml", UserData);
        }
What i want to have a way to have the userdata in all internal Stimulsoft Actions.
That means it have to loop from the Controler (via Model/Viewbag) to the Flash
and on ActionCalls from flash back to the controller:

The View:

Code: Select all

@Html.Stimulsoft().StiMvcViewerFx(new StiMvcViewerFxOptions() {
    ActionGetReportSnapshot = "GetReportSnapshot",
    ActionGetLocalization = "GetLocalization",
    ActionExportReport = "ExportReport",
    UserData = ViewBag.UserData  /* doesn't exist, yet! */
})

Code: Select all

public ActionResult GetReportSnapshot(string UserData)
{
    StiReport report = StiMvcDesigner.GetReportObject(this.Request);
byte[] data = DecideWhatDataToLoad(UserData);
    report.Load(data);
   // ...
   return StiMvcViewerFx.GetReportSnapshotResult(this.Request, report);
}
Is there a way to get this to work?

I am currently using a session object. However this is bad, because if
a user opens a 2nd Browser Tab the Session Data will be overwritten.


Btw. we need this vor the Viewer and for the Designer.
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: Question on StiMvcDesigner (MVC)

Post by Vladimir »

Hello,

Unfortunately, currently there is no special fields that would pass parameters to the Viewer or Designer. But, if you initialize the parameters in the URL, you can use the following method:

Code: Select all

public ActionResult GetReportSnapshot(string UserData )
{
    RouteValueDictionary routeValues = StiMvcViewer.GetRouteValues(HttpContext);
    ...
}
Thank you.
Haraldf
Posts: 24
Joined: Thu Dec 05, 2013 8:21 pm

Re: Question on StiMvcDesigner (MVC)

Post by Haraldf »

Hello Vladimir,

in our application we will have a lot of reports. That's why we decided to just use one
ReportController.

We can't init values by the URL, as we load the Viewer and the Designer via AJAX to
a window system (please check the screenshots).

I currently wrote a hack to save the user data in sessions:

Code: Select all

        public PartialViewResult Viewer(ReportDescription description)
        {
            Session[SessionHackKey] = description; // store user values in session
            
...
            return PartialView("_FlashViewer", model);
        }
Unfortunatly this is a 90% solution. If the user opens a 2nd Tab, there are some
very very very bad things happening. Because the session of Tab2 overwrites
all values of Tab1. :mrgreen:

Is there any chance that you will add this custom value in a later version?

Thank you.

Edit: PICs deleted - I can't make them public. I'll post you a message.
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: Question on StiMvcDesigner (MVC)

Post by Vladimir »

Hello,

Thank you for the sent information. Please specify the form in which parameters are passed? That is, the string data, byte data, hash table, something else? We try to find the most versatile way.

Thank you.
Haraldf
Posts: 24
Joined: Thu Dec 05, 2013 8:21 pm

Re: Question on StiMvcDesigner (MVC)

Post by Haraldf »

We use just a simple string - a user id.
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: Question on StiMvcDesigner (MVC)

Post by Vladimir »

Hello,

Unfortunately, there are currently no special storage for MvcViewerFx, but you can solve the problem with sessions using one of the methods, for example, solution on link below:

http://stackoverflow.com/questions/3686 ... owser-tabs

Thank you.
Haraldf
Posts: 24
Joined: Thu Dec 05, 2013 8:21 pm

Re: Question on StiMvcDesigner (MVC)

Post by Haraldf »

That's a very very nice hack!

Thank you!
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Question on StiMvcDesigner (MVC)

Post by HighAley »

Hello.

We are always glad to help you.

Thank you.
Post Reply