March 30, 2013

How to handle SSRS reports which will take long time

How to handle SSRS reports which will take long time

We know that there are/will be some reports which will take more time to render due to the many rows/transactions. This post will help you to show appropriate warning/error messages to the end user while running the report.

The number of records that are processed by report might be large and the user experience will be affected, because the client will be locked up if printing to the screen. 

In this case, you might want to return a warning message to the user that indicates that time to process the report might be long and confirm that they want to run the report. 

Another case could be where the number of records being processed is very large and a time-out might occur in report processing and clearly, we should not run this report.
In this case, we should not run the report and therefore, should return anSrsReportPreRunState::Error enumeration value with the error message.
In AX 2012, SSRS reports, through SrsReportRunController we can easily let the user know the report will take more time with warnings or error messages through preRunValidate method.

Example : General Journals report

Take the standard example of Print journal from General Ledger >> Reports >> Journal >> Print journal.

Use standard LedgerJournalController class to help you understand preRunValidate method: this validates container before running the report. Override this method to do custom pre-validation for any report. Typical use of this method will be to validate if the time taken to run the report is acceptable.
In this standard example: If the query is going to retrieve more than 1000 rows, a confirmation Box will be displayed to the user as shown below.

To get the confirmation box and for the sake of the demo/understanding: I have hardcoded the rows count to 1001 as shown below. There is a new static method in QueryRun::getQueryRowCount that will get the row Count of the query.

Please note: Remove hardcoded values later. This is hardcoded only for the sake of demo/Walk through
Clearly in the below standard example : warning limit is 1000 and error limit is 100000. 


image

Run this report as shown below...

image


Here comes the confirmation Box: 
If your report is long running, it may time-out. Do you want to continue?

Note: In order to resolve/by pass this confirmation Box, a developer can change the macro #define.warningLimit to greater value

Example : #define.warningLimit(2000);

image

you can increase the row count : to 1000001.

image

Let us run the report One more time as shown below.

image


Here comes the error message: Running the report has been cancelled due to the time it will take to run. Adjust the parameters of the report and retry.
In order to resolve this problem, Increase the ErrorLimit macro value in thepreRunValidate method.
Please note, it is not recommended to increase as it will take more time and your box cannot handle load.


Example : #define.ErrorLimit(150000);
image


Click below for original post...

-Harry 

March 20, 2013

Upload an image in a form window control

Upload an image in a form of window control

Hi Guys,
Here is the code for Upload an image in a form of window control in your Axapta world.
Go n Get It......

str filename;
FileNameFilter filter = ['JPG files','*.jpg'];
Bindata binData;
Image signatureImage = new Image();

super();

filename = Winapi::getOpenFileName(element.hWnd(), filter, '', "Upload your image", '', '');

binData = new BinData();

if (binData.loadFile(filename))
{
signatureImage = binData.getData();
FormWindowCOntrol.image(signatureImage);
FormWindowCOntrol.widthValue(signatureImage.width());
FormWindowCOntrol.heightValue(signatureImage.height());
element.resetSize();
element.unLock();
}

-Harry