Page 1 of 1

Problem creating new Report to Business Object

Posted: Sat Oct 19, 2013 12:17 pm
by romulocpd
Hello.

I'm trying create new reporto for my business objects. I work with Entity Framework and I've got objects do query and show data to MVC views.

If I pass the business object and call method Design() (Windows Forms), the Dictionary is filled correct.

In Windows Forms:

My Object:

Code: Select all

public class ObjRelatorio
    {
        public ObjRelatorio()
        {
            Clientes = new List<Cliente>();
        }

        public int CodigoEmpresa { get; set; }
        public string RazaoSocial { get; set; }

        public List<Cliente> Clientes { get; set; }
        
    }
Call to show Design (Windows Forms yet):

Code: Select all

            ObjRelatorio Rel = new ObjRelatorio();

            GerarDados(Rel);

            StiReport S = new StiReport();
            S.RegBusinessObject("DadosEmpresa", Rel);            
            S.Design();
In this moment whe Stimulsoft recognized (like attachment) my object! Very good.

My problem is: In MVC Designer it won't work.

Code: Select all

         public ActionResult EditarRelatorioMaster()
        {
            StiReport S = new StiReport();
         
            // My Business Object !!!!!!!!!!!!!!!!!!1   
            S.RegBusinessObject("Cabecalho", new Models.View.ModelViewCabecalhoRelatoriosView());

            return StiMvcDesigner.GetReportTemplateResult(S);
        }
And in the view

Code: Select all

@using System.Web.UI.WebControls;
@using Stimulsoft.Report.Mvc;

@{
    ViewBag.Title = "EditarRelatorioMaster";
    Layout = "~/Views/Shared/_AlterarRelatorio.cshtml";
}

<h2>Alterar Relatório Master</h2>

@Html.Stimulsoft().StiMvcDesigner(new StiMvcDesignerOptions() {
        ActionGetReportTemplate = "EditarRelatorioMaster",
        ActionSaveReportTemplate = "SalvarRelatorioMaster",
        ActionGetReportSnapshot = "DadosAlteracaoRelatorioMaster",
        ActionGetLocalization = "GetLocalization",
        Width = Unit.Percentage(100),
        Height = Unit.Pixel(800)
})


It won't work!!!!

What my soluciton? I've create a equal object in Windows Forms, call the Designer, create the .mrt file. If I get this file and use in MVC project, the report works!!!!!!!

So, my problem is create new reports reading data from my Business Object.

Thank you!

Re: Problem creating new Report to Business Object

Posted: Mon Oct 21, 2013 9:46 am
by Vladimir
Hello,

Please use the following code:

Code: Select all

        public ActionResult EditarRelatorioMaster()
        {
            StiReport S = new StiReport();
         
            // My Business Object !!!!!!!!!!!!!!!!!!1   
            S.RegBusinessObject("Cabecalho", new Models.View.ModelViewCabecalhoRelatoriosView());
            S.Dictionary.Synchronize();

            return StiMvcDesigner.GetReportTemplateResult(S);
        }
Thank you.