Page 1 of 1

Not all my business objects appear on the MVC report viewer.

Posted: Wed Nov 06, 2013 1:04 pm
by kgb2013
Hello.

I have an MVC Viewer for displaying my bussiness object data:

Code: Select all

@Html.Stimulsoft().RenderMvcViewerScripts()
@Html.Stimulsoft().StiMvcViewer(
	"Reports",
	new StiMvcViewerOptions() {
		Controller = "List",
		ActionGetReportSnapshot = "GetReportSnapshot",
		ActionViewerEvent = "ViewerEvent",
		ActionExportReport = "ExportReport",
		ActionPrintReport = "PrintReport",
		Width = Unit.Percentage(100),
		Height = Unit.Pixel(1300),
		ClientRequestTimeout = 900000,

		BackColor = Color.DarkGray,
		MenuShowMode = StiShowMenuMode.Click,
		MenuViewMode = StiWebViewMode.OnePage,
		MenuAnimation = false,
		ShowButtonBookmarks = false,
		ShowButtonParameters = false,
		ShowButtonDesign = false,
	}

		private StiReport GetReport(ListModel model)
		{
			var docs = model.GetDocsStimulSoft();
			using(var report = new StiReport())
			{
				report.Load(MrtFilePath);
				report.RegBusinessObject("Document", "Document", docs);
				return report;
			}
		}

		public ActionResult GetReportSnapshot(ListModel model)
		{
			return StiMvcViewer.GetReportSnapshotResult(HttpContext, GetReport(model));
		}
)
My problem is that I get displayed only some of the business objects that I feed it (around 23 objects out of ~3000).
So I get only 2 pages instead of let's say 200.
Is there a limit setting somewhere?
When I was doing the same with SQL query stored in the MRT file I didn't have such problems.

Thanks.

Re: Not all my business objects appear on the MVC report vie

Posted: Wed Nov 06, 2013 1:41 pm
by kgb2013
I see now that I am disposing the report before returing it but now that I've changed that it still see only 23 entries:

Code: Select all

@Html.Stimulsoft().RenderMvcViewerScripts()
@Html.Stimulsoft().StiMvcViewer(
   "Reports",
   new StiMvcViewerOptions() {
      Controller = "List",
      ActionGetReportSnapshot = "GetReportSnapshot",
      ActionViewerEvent = "ViewerEvent",
      ActionExportReport = "ExportReport",
      ActionPrintReport = "PrintReport",
      Width = Unit.Percentage(100),
      Height = Unit.Pixel(1300),
      ClientRequestTimeout = 900000,

      BackColor = Color.DarkGray,
      MenuShowMode = StiShowMenuMode.Click,
      MenuViewMode = StiWebViewMode.OnePage,
      MenuAnimation = false,
      ShowButtonBookmarks = false,
      ShowButtonParameters = false,
      ShowButtonDesign = false,
   }

      private StiReport GetReport(ListModel model)
      {
         var docs = model.GetDocsStimulSoft();
         var report = new StiReport();
         report.Load(MrtFilePath);
         report.RegBusinessObject("Document", "Document", docs);
         return report;
      }

      public ActionResult GetReportSnapshot(ListModel model)
      {
         return StiMvcViewer.GetReportSnapshotResult(HttpContext, GetReport(model));
      }
)

Re: Not all my business objects appear on the MVC report vie

Posted: Wed Nov 06, 2013 2:07 pm
by kgb2013
I have now tried to use the advice from here :
http://stackoverflow.com/a/18373412/2173353

But this generates the following error:

c:\Users\User\AppData\Local\Temp\fzsik4oi.0.cs(1482,35) : error CS0102: The type 'Reports.Report.DocumentBusinessObject' already contains a definition for 'Type'

at Stimulsoft.Report.StiReport.Compile(String path, Stream stream, StiOutputType outputType, Boolean autoCreate, Object standaloneReportType)
at Stimulsoft.Report.StiReport.Compile(String path, Stream stream, StiOutputType outputType, Boolean autoCreate)
at Stimulsoft.Report.StiReport.Compile(String path, StiOutputType outputType, Boolean autoCreate)
at Stimulsoft.Report.StiReport.Compile(String path, StiOutputType outputType)
at Stimulsoft.Report.StiReport.Compile(StiOutputType outputType)
at Stimulsoft.Report.StiReport.Compile()
at Stimulsoft.Report.Engine.StiReportV2Builder.RenderSingleReport(StiReport masterReport, StiRenderState renderState)
at Stimulsoft.Report.StiReport.RenderReport(StiRenderState renderState)
at Stimulsoft.Report.StiReport.Render(StiRenderState renderState, StiGuiMode guiMode)
at Stimulsoft.Report.StiReport.Render(StiRenderState renderState)
at Stimulsoft.Report.StiReport.Render(Boolean showProgress, Int32 fromPage, Int32 toPage)
at Stimulsoft.Report.StiReport.Render(Boolean showProgress)
at Stimulsoft.Report.Mvc.StiMvcViewer.SaveReportObject(HttpContextBase httpContext, StiReport report)
at Stimulsoft.Report.Mvc.StiMvcViewer.GetReportSnapshotResult(HttpContextBase httpContext, StiReport report)
...

In your demo here:
http://www.stimulsoft.com/en/articles/s ... ss-objects
..you don't mention anythig about a need to call SynchronizeBusinessObjects() so I guess that the post in Stackoverflow is wrong...

So, back to the begining...
Any idea what is missing here?
I also attach my MRT file.

EDIT:
The variable `docs` is an IEnumerable of my business objects.

Re: Not all my business objects appear on the MVC report vie

Posted: Thu Nov 07, 2013 9:32 am
by kgb2013
I have news on this problem:
When I make the IEnumerable a List the problem goes away!

Code: Select all

report.RegBusinessObject("Document", "Document", docs.ToList());

Re: Not all my business objects appear on the MVC report vie

Posted: Thu Nov 07, 2013 1:36 pm
by kgb2013
I have noticed that when navigating to the last page of the report I get this error:

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

at System.Collections.CollectionBase.System.Collections.IList.get_Item(Int32 index)
at Stimulsoft.Report.Components.StiPagesCollection.get_Item(Int32 index)
at Stimulsoft.Report.Mvc.StiMvcViewer.RenderPageParameters(StiReport report, Int32 pageNumber, Double zoom, String& pageMargins, String& pageSizes, String& pageBackgrounds)
at Stimulsoft.Report.Mvc.StiMvcViewer.ViewerEventResult(HttpContextBase httpContext, StiReport report)
at MyProj.Controllers.ListController.ViewerEvent(ListModel model) in STH.cs:line 116
at lambda_method(Closure , ControllerBase , Object[] )

Re: Not all my business objects appear on the MVC report vie

Posted: Thu Nov 07, 2013 3:35 pm
by Alex K.
Hello,

Please check the last prerelease build. If the issue still present please send us a sample project which reproduce the issue for analysis.

Thank you.

Re: Not all my business objects appear on the MVC report vie

Posted: Tue Nov 19, 2013 9:50 am
by kgb2013
I think this was solved by the time I used ToList().
If I see it again, I will let you know.

Re: Not all my business objects appear on the MVC report vie

Posted: Wed Nov 20, 2013 6:55 am
by HighAley
Hello.

Let us know if you have any problems else.

Thank you.

Re: Not all my business objects appear on the MVC report vie

Posted: Mon Nov 25, 2013 9:09 am
by kgb2013
OK.
Here is a case where the exception:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
..happens:

When I use an MRT file that uses bussines objects, it happens when have my code like this:

Code: Select all

		public ActionResult GetReportSnapshot(ListModel model)
		{
			try
			{
				using (var report = GetReport(model))
				{
					return StiMvcViewer.GetReportSnapshotResult(HttpContext, report);
				}
			}
			catch
			{
				return null;
			}
		}
		//---------------------------------------------------------------------------
		public ActionResult ViewerEvent(ListModel model)
		{
			return StiMvcViewer.ViewerEventResult(HttpContext);
		}
If I make my ViewerEvent(..) like so the problem disappears (but I make unessesary DB calls):

Code: Select all

		public ActionResult ViewerEvent(ListModel model)
		{
			using (var report = GetReport(model))
			{
				return StiMvcViewer.ViewerEventResult(HttpContext, report);
			}
		}
It happens when moving to another page (from the initial/first page) and here is the stack trace:
at System.Collections.CollectionBase.System.Collections.IList.get_Item(Int32 index)
at Stimulsoft.Report.Components.StiPagesCollection.get_Item(Int32 index)
at Stimulsoft.Report.Mvc.StiMvcViewer.RenderPageParameters(StiReport report, Int32 pageNumber, Double zoom, String& pageMargins, String& pageSizes, String& pageBackgrounds)
at Stimulsoft.Report.Mvc.StiMvcViewer.ViewerEventResult(HttpContextBase httpContext, StiReport report)
at Stimulsoft.Report.Mvc.StiMvcViewer.ViewerEventResult(HttpContextBase httpContext)

Re: Not all my business objects appear on the MVC report vie

Posted: Mon Nov 25, 2013 12:56 pm
by Alex K.
Hello,

Can you please send us a sample project which reproduce the issue for analysis.

Thank you.