Page 1 of 1

Double Pass

Posted: Wed Oct 25, 2017 11:42 am
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.

Re: Double Pass

Posted: Thu Oct 26, 2017 12:20 pm
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

Re: Double Pass

Posted: Tue Oct 31, 2017 11:31 am
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.

Re: Double Pass

Posted: Tue Oct 31, 2017 8:05 pm
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.

Re: Double Pass

Posted: Wed Nov 01, 2017 11:33 am
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.

Re: Double Pass

Posted: Thu Nov 02, 2017 7:23 pm
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.

Re: Double Pass

Posted: Fri Nov 10, 2017 4:30 pm
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.

Re: Double Pass

Posted: Sun Nov 12, 2017 10:17 pm
by Alex K.
Hello,

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

Thank you.

Re: Double Pass

Posted: Fri Jan 26, 2018 10:50 am
by Leandro Borges
Hello.

Sorted out.

Thank you.

Re: Double Pass

Posted: Fri Jan 26, 2018 11:00 am
by Alex K.
Hello

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

Thank you.