Page 1 of 1

Question on StiMvcDesigner (MVC)

Posted: Fri Dec 06, 2013 9:01 am
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 )
        {
        }

Re: Question on StiMvcDesigner (MVC)

Posted: Fri Dec 06, 2013 12:59 pm
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.

Re: Question on StiMvcDesigner (MVC)

Posted: Fri Dec 06, 2013 5:08 pm
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.

Re: Question on StiMvcDesigner (MVC)

Posted: Tue Dec 10, 2013 7:11 am
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.

Re: Question on StiMvcDesigner (MVC)

Posted: Tue Dec 10, 2013 8:03 am
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.

Re: Question on StiMvcDesigner (MVC)

Posted: Wed Dec 11, 2013 6:45 am
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.

Re: Question on StiMvcDesigner (MVC)

Posted: Thu Aug 14, 2014 8:07 am
by Haraldf
We use just a simple string - a user id.

Re: Question on StiMvcDesigner (MVC)

Posted: Thu Aug 14, 2014 12:51 pm
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.

Re: Question on StiMvcDesigner (MVC)

Posted: Thu Aug 14, 2014 2:02 pm
by Haraldf
That's a very very nice hack!

Thank you!

Re: Question on StiMvcDesigner (MVC)

Posted: Fri Aug 15, 2014 5:54 am
by HighAley
Hello.

We are always glad to help you.

Thank you.