logo

Warning: The forum is now for consultation only. Please use GitHub Discussions to post any questions or comments.


Welcome Guest ! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
andrey.malyanov  
#1 Posted : Friday, November 27, 2020 5:16:11 PM(UTC)
andrey.malyanov

Rank: Newbie

Groups: Registered
Joined: 11/19/2020(UTC)
Posts: 3
Location: Moscow, RU

Thanks: 1 times
Hello colleagues,
I have a report which I use like Dashboard. The report shows quantity of bad events in my internal system.
If all is well the report shows: QTY of bad events = 0.
In bad situation the report shows: QTY of bad events = 10 (for example).
I try to set up output for the report (email or folder).
Because my report always has one record (0 or not) I couldn't use the standard method Cancel generation if no records.
Ok.
I have written Pre-generation script when a calculate result (<>0) and set variable result to 0 or 1.
But...
In any cases (result=0 or result=1) my output is working and generate file or send e-mail.

My code is
Quote:
@{
ReportOutput output = Model;
string result = "0"; //Set result to 0 to cancel the report.
}
@Raw(result)


I Execute Output and check Messages:
Quote:

20:14:14 Starting execution of 'DayRegistryStatus' (No security context)...
20:14:14 Starting to build models...
20:14:14 Build models of Execution Set 1...
20:14:14 Model 'mShouldBeSend': Loading result set...
20:14:14 Model 'tShouldBeAccept': Loading result set...
20:14:14 Model 'tShouldBePay': Loading result set...
20:14:14 Model 'tShouldBePay': Executing main query...
20:14:14 Model 'tShouldBeAccept': Executing main query...
20:14:14 Model 'mShouldBeSend': Building pages...
20:14:14 Model 'mShouldBeSend': Building tables...
20:14:14 Model 'mShouldBeSend': Building totals...
20:14:14 Model 'tShouldBePay': Building pages...
20:14:14 Model 'tShouldBePay': Building tables...
20:14:14 Model 'tShouldBePay': Building totals...
20:14:14 Model 'tShouldBeAccept': Building pages...
20:14:14 Model 'tShouldBeAccept': Building tables...
20:14:14 Model 'tShouldBeAccept': Building totals...
20:14:14 Rendering report...
20:14:15 Report result generated in '\Отчет по статусам.html'
20:14:15 Processing result file for output 'output (Folder Device)'
20:14:15 Executing Pre-Execution script.
20:14:15 The script returns:0
20:14:15 Report result generated in '\Отчет по статусам.html'
20:14:15 Rendering report...


I see "The script returns:0". But the output is not stopped. Why?
epf  
#2 Posted : Monday, November 30, 2020 8:26:30 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 206 time(s) in 199 post(s)
This is a bug that will be fixed in the 6.0 (coming this week).
As a workaround, you can cancel the report with the Cancel flag:
Code:
output.Report.Cancel = true;


but for generation in a folder, the report result file will be created anyway...
Note that you can also use a task (with the Step 'Rendering is done, before output execution') to handle what you need.
thanks 1 user thanked epf for this useful post.
andrey.malyanov on 11/30/2020(UTC)
andrey.malyanov  
#3 Posted : Monday, November 30, 2020 8:35:35 AM(UTC)
andrey.malyanov

Rank: Newbie

Groups: Registered
Joined: 11/19/2020(UTC)
Posts: 3
Location: Moscow, RU

Thanks: 1 times
Big thanks!
Before your answer I used rise an error divide by zero :)
int i = 0;
i = 10 / Int32.Parse(result);
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.