Double Pass

Stimulsoft Reports.NET discussion
Post Reply
Leandro Borges
Posts: 219
Joined: Tue Oct 27, 2015 4:19 pm

Double Pass

Post by Leandro Borges »

Hello.

In my report, there are five data sources. When the first data source is executed, if it brings data, the others must execute. Otherwise, the others should not run. I was able to do this by using the following code in the report's BeginRender event:

Page0.Enabled = false;
Page1.Enabled = false;

second_data_souce.ConnectOnStart = false;
third_data_souce.ConnectOnStart = false;
fourth_data_souce.ConnectOnStart = false;
fifth_data_souce.ConnectOnStart = false;

first_data_source.Connect();

if (first_data_source.Count == 0)
{
StiDataSource[] sds = this.Dictionary.DataSources.Items;
List<StiDataSource> lstDsForDelete = new Lis<StiDataSource>();

foreach (StiDataSource item in sds)
lstDsForDelete.Add(item);

foreach (StiDataSource itemRemove in lstDsForDelete)
this.Dictionary.DataSources.Remove(itemRemove);

Page0.Enabled = true;
}
else
{
second_data_souce.ConnectOnStart = true;
third_data_souce.ConnectOnStart = true;
fourth_data_souce.ConnectOnStart = true;
fifth_data_souce.ConnectOnStart = true;

Page1.Enabled = true;
}

The problem is that because of the double pass, the command first_data_source.Connect (); does not run again and ends up entering the if instead of entering the else. Is there any solution or other way to do it?

Thank you.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: Double Pass

Post by Edward »

Hi Leandro,

Thank you for the detailed explanation of the issue you are facing. Please check for the pass you are in with help of this.IsFirstPass property.

So usually the approach is as follows:
During the first pass you can calculate all values you need and in the second pass, you can display the calculated values.

Thank you,
Edward
Leandro Borges
Posts: 219
Joined: Tue Oct 27, 2015 4:19 pm

Re: Double Pass

Post by Leandro Borges »

Hello.

I used the this.IsFirstPass property and managed to make the report work as expected but there is still a problem: when I run the report out of the editor, using Stimulsoft Viewer for example, it does not work. If it is executed in the same way with the same parameters inside the editor, it works. Can you help me ? Below is my changed code.

if (this.IsFirstPass)
{
Page0.Enabled = false;

second_data_souce.ConnectOnStart = false;
third_data_souce.ConnectOnStart = false;
fourth_data_souce.ConnectOnStart = false;
fifth_data_souce.ConnectOnStart = false;

first_data_source.Connect();

Verifica = first_data_source.Count;

if (first_data_source.Count == 0)
{
StiDataSource[] sds = this.Dictionary.DataSources.Items;
List<StiDataSource> lstDsForDelete = new List<StiDataSource>();

foreach (StiDataSource item in sds)
lstDsForDelete.Add(item);

foreach(StiDataSource itemRemove in lstDsForDelete)
this.Dictionary.DataSources.Remove(itemRemove);
}
else
{
second_data_souce.ConnectOnStart = true;
third_data_souce.ConnectOnStart = true;
fourth_data_souce.ConnectOnStart = true;
fifth_data_souce.ConnectOnStart = true;
}
}
else
{
if (Verifica == 0)
{
Page0.Enabled = true;
Page1.Enabled = false;
}
else
{
Page0.Enabled = false;
Page1.Enabled = true;
}
}

I think the command first_data_source.Connect (); is not running when the report is generated outside the editor.
I await a return.

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

Re: Double Pass

Post by Alex K. »

Hello,

Please clarify which product, version and which viewer are you use?

Also, if possible, please send us a sample report with test data which reproduces the issue for analysis.

Thank you.
Leandro Borges
Posts: 219
Joined: Tue Oct 27, 2015 4:19 pm

Re: Double Pass

Post by Leandro Borges »

Hello.

I use version 2017.1.11 to develop the reports and I have used the Stimulsoft Viewer from version 2017.2.2 to test the report.
I think the command Name_data_source.Connect (); is not running when the report is generated outside the editor.
Is there a command to force the connection of a data source when the report is generated outside the editor?

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

Re: Double Pass

Post by Alex K. »

Hello,

Please try to use the following code:

Code: Select all

first_data_source.ConnectOnStart = true;
first_data_source.Connect();
If the issue still present, please send us a sample which reproduces the issue for analysis.

Thank you.
Leandro Borges
Posts: 219
Joined: Tue Oct 27, 2015 4:19 pm

Re: Double Pass

Post by Leandro Borges »

Hello.

Even by placing these codes, the report does not work when generated by Stimulsoft Viewer. Only works when generated by the publisher. Anything else I can try?

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

Re: Double Pass

Post by Alex K. »

Hello,

Please send us a sample report with test data which reproduces the issue for analysis.

Thank you.
Leandro Borges
Posts: 219
Joined: Tue Oct 27, 2015 4:19 pm

Re: Double Pass

Post by Leandro Borges »

Hello.

Sorted out.

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

Re: Double Pass

Post by Alex K. »

Hello

Ok.
Please let us know if you need any additional help.

Thank you.
Post Reply