Report Inheritance - Creation of the basic class of a report

Stimulsoft Reports.NET discussion
tammamkoujan
Posts: 22
Joined: Wed Oct 08, 2008 1:57 pm

Report Inheritance - Creation of the basic class of a report

Post by tammamkoujan »

Hello,
I am trying to apply reports inheritance in my project, I read the Report Inheritance section in your documentation and download a good sample from the forum
but this sample cove only the Creation of the master-report , I tried to apply inheritance through creation of the basic class of a report but its not working and show a blank report.
I attached the sample I am working on.

Thank you in advanced.
Attachments
ReportInheritance.rar
(92.32 KiB) Downloaded 211 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Report Inheritance - Creation of the basic class of a re

Post by HighAley »

Hello.

You you need to use compiled report then it's not right to open it in the Designer. It's possible to open there report template but not compiled in class reports.
Your code is very strange. What do you try to do when you load InheritedReport1.mrt over the report created from class. Maybe you forget to use MasterReport property.
Could you describe your issue more detailed where do you get unexpected results?

Thank you.
tammamkoujan
Posts: 22
Joined: Wed Oct 08, 2008 1:57 pm

Re: Report Inheritance - Creation of the basic class of a re

Post by tammamkoujan »

I followed what you mentioned into your documentation (attached it)
I create the base report and saved it as cs file
add it to my project in used
StiOptions.Engine.BaseReportType = typeof(Reports.Report);
Then all new reports will be automatically inherited from the basic class.
I want to keep the base report as class in my project so I can extend it as I like
as example I want to wrap the base report variables into properties
so I can replace myreport["varReportTitle"] = " test title";
with myreport.ReportTitle = " test title";
what I am expecting from inheritance is the new report should inherit the members of the base one
and i need to access this members through my code and because of that I wrote
Reports.Report report = new Reports.Report();
report.Load("InheritedReport1.mrt");
Attachments
inheritance.jpg
inheritance.jpg (232.72 KiB) Viewed 3888 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Report Inheritance - Creation of the basic class of a re

Post by HighAley »

Hello.

In the next code you load report to the report which was created using your class. In this case the report from Reports.Report class will be overwritten.

Code: Select all

//Show an inherited report
StiOptions.Engine.BaseReportType = typeof(Reports.Report);
Reports.Report report = new Reports.Report();
report.Load("InheritedReport1.mrt");
report["varReportTitle"] = " test title";
report.Render();
report.Show();
Thank you.
tammamkoujan
Posts: 22
Joined: Wed Oct 08, 2008 1:57 pm

Re: Report Inheritance - Creation of the basic class of a re

Post by tammamkoujan »

I know that the Reports.Report class will be overwritten , but it will overwritten with a report already inherit from it. its like:

Code: Select all

    public class A
    {
        public string ValueA;
    }

    public class B : A
    {

    }
        [STAThread]
        static void Main()
        {
            A x = new B();
            x.ValueA = "";

            //or
            B b1 = new B();
            A a1 = new A();
            a1 = b1;
            a1.ValueA = "";
     }
in other words my question is I need to have a base class into my project this class will wrap variables and common things between all of my application reports , who I can achieve that.
Thank you
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Report Inheritance - Creation of the basic class of a re

Post by HighAley »

Hello.

It's impossible to do so. Our tool support the inheritance of the components but not the classes which were inherited from StiReport.
If you need to inherit report this way you could buy our source code and edit our StiReport class as you need.

Thank you.
tammamkoujan
Posts: 22
Joined: Wed Oct 08, 2008 1:57 pm

Re: Report Inheritance - Creation of the basic class of a re

Post by tammamkoujan »

Hello,

In this case what is the advantage of saving reports as CS into your tool?

thank you
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Report Inheritance - Creation of the basic class of a re

Post by Alex K. »

Hello,

> In this case what is the advantage of saving reports as CS into your tool?

The main advantage - if you add this class to your project, then this class will be compiled together with your project, and no need to runtime compilation:
- more faster report rendering,
- can work under MediumTrust,
- less memory consumption.

> I followed what you mentioned into your documentation (attached it)
> I create the base report and saved it as cs file

You use the "Save As -> CSharp files", but should use the "Save As -> CSharp files for inherited reports".

Thank you.
tammamkoujan
Posts: 22
Joined: Wed Oct 08, 2008 1:57 pm

Re: Report Inheritance - Creation of the basic class of a re

Post by tammamkoujan »

Hello,

What you mentioned into your reply is very nice and important , but it not include Inheritance and following OOP designs!! .
You use the "Save As -> CSharp files", but should use the "Save As -> CSharp files for inherited reports".
this will do nothing more than set the "this.MasterReport" with a hard coded value represent the master report. it is another way to apply the master report way and I cannot consider
it as real inheritance (really it is just using a template as base to design the report ), Imagine that I have 100 reports into my system if I used this way then when I change the design of the base report
I should go through the 100 reports and update the MasterReport property for each one.
I will appreciate if you recommend me about the best scenario when I have an enterprise application where there is a base report class include the common properties and variables between reports and I can handle it through my code while the real reports are saved in a central place (i.e. database)
Thank you.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Report Inheritance - Creation of the basic class of a re

Post by HighAley »

Hello.

Please, describe your issue more detailed. What format your reports are stored now?
What result do you need to get?
Why don't you use our product as were suggested?

Thank you.
Post Reply