Hi!
What is the best way to generate a heavy report (Multiple queries and pages) using FoxInCloud. Any tips?
Hi Arcadio,
What kind of tip are you looking for? reduce response time, reduce user waiting time, other?
Hi, Thierry!
A report that takes 10 minutes to generate. Foxincloud will generate me timeout errors. Right?
You just need to expand Timeout
in wc.ini
to 600 (secs.), or more if you see fit.
FoxInCloud has no such feature; you can look at Web Connect's wwWebAsyncRequest
Otherwise if your report can be generated by an independent procedure, you can do the following:
- JS Event handler:
- collect report parameters from controls on the form (
jQuery("#ID").val()
…) - send an async AJAX request to a dedicated
xxxProcess.myReport()
method with report parameters as form name-values pairs - As AJAX request call back, display a 'report complete' message with a link to the report in some Bootstrap Notify 'window'
- collect report parameters from controls on the form (
xxxProcess.myReport()
does the following:- collect report parameters using
request.form()
- run report in independent procedure with parameters
- copy PDF report into site's temp folder with user's ID added to file stem for uniqueness and confidentiality (you can use
this.oAJAX.FileToSiteTempDir()
) - return JSON result including URL to the
temp/report_userID.pdf
; the above AJAX request call-back processes this result.
- collect report parameters using
Benefit of that procedure is that user can continue working until the report is complete; however he/she must stay in the same page for the call-back to execute properly.
It would be interesting if you had a small example in the live tutorial of the following steps. It's definitely something that would be really cool for the product.
OK will try to do soon
Great! Thank you!
I had a similar need many years ago. My web application simply created a text file with a random name in a special folder, this text file included all the necessary details to define the report, plus the email address to the one who asked for the report. A second program regularly checked the folder in question, and if a file was found, it was analyzed and the report was created as a PDF. Then the PDF was simply sent as an email attachment. The second program was also responsible for deleting old PDFs in order to avoid storing unnecessary files.
Nice solution, thanks Tore
Arcadio, does it fit your immediate need?
(while I remain committed to adding an example to FLT's reporting sample form 😉)
OK here is quick and dirty sample: http://foxincloud.com/tutotest/bs/report.tuto
see code in:
- http://foxincloud.com/tutotest/bs/fileDisplay.tuto?report.scx.src >
PROCEDURE cmdRptAsync.Click
- resulting http://foxincloud.com/tutotest/bs/report_scx.js
- http://foxincloud.com/tutotest/bs/fileDisplay.tuto?tutoServer.prg >
procedure tutoProcess.custOrderReport()
- http://foxincloud.com/tutotest/bs/fileDisplay.tuto?tutoSets.prg >
procedure custOrderReport()
Hi Thierry,
Elegant !
I see you are using notify ()?
Yes!
In FoxinCloud V 2.31.0-beta.4
, just added xxxServer.lBSnotifyAdd
to load Bootstrap Notify and Animate.css automatically.
Credits to you for discovering this utility!
Maybe a track for wWait ?
Thierry!
Great! Speechless! Thank you!
À wait message needs be triggered on server side; let me think about it.
Hi Thierry,
In FoxinCloud V 2.31.0-beta.4, just added xxxServer.lBSnotifyAdd to load Bootstrap Notify and Animate.css automatically
Enjoy to see your beta.4 comming ...
Is animate.css included ?
Hi Vincent,
Yes, animate.css
ships with this release
Hi Thierry,
I find this message.
Do you plan to implement something for wWait the way you did for offline PDF printing ?
Have a good week-end
wWait()
executes on the server, can't send anything to the client until the request is finished, so it's useless because the user sees the 'wait' message when the long request is over.
can you provide a sample use case where emulating wWait()
would be useful?
Yes of course.
I run a fairly long process and ask the user to wait.
Schematically:
Click () =>
- Message of patience
- Long treatment ... The end of processing does not necessarily have to be intercepted (a "hide notify" would suffice)
Thanks in advance
If you use a FoxInCloud event method, please note that, by design similar to the VFP event model, the user won't be able to issue another action on the form until the looong request
is over.
Conversely, if you use an event separate and independent from the form (as I earlier proposed to Arcadio), the user can continue working on the form while the looong request is being processed by the server.
Here is a sample code you can try:
modify file xxx.js
FoxInCloud.AjaxComplete_ = function(jqXHR, statusText){
if (this.oNotify) {
this.oNotify.close();
this.oNotify = null;
}
}
procedure cmd.click
if thisForm.wlHTMLgen
local cJS
text to cJS …
FoxInCloud.oNotify = jQuery.notify(…);
FoxInCloud.DOMEvent(undefined, false, event);
endtext
return m.cJS
endif
&& loooong process
Thank you Thierry, for the code and for the explanation.
I did not succeed but will try again later and will keep you informed of course.
For very long reports, I suggest that you run the report in another VFP session, and let that session send it as an email after it's finished.
What does not succeed? JS error?
Yes thanks.
But in fact, I bounce back from the question because my problem is to send a message of patience before a long treatment.
I have used the solution I suggested, for many, many years now. My customers are very happy with it since it means that they don't have to wait at all. Also remember that the email may also contain links and other things.
Maybe it's time to rethink your strategy?
It works great, thanks !
At the click() of a button.
I had tried in the valid() of a dropdown button, and there the message does not appear (the loooong code is executed well).
the message does not appear
check the selector you give to jQuery.notify
Hi Thierry,
Then you can make this example available in the Live Tutorial?
FWIW, I have a different approach to this. I have a service running on the server that monitors a table looking for new reports t create. When I need a report, I pass the report info to the service. If I want to monitor the progress, I then open a form with a timer, and the timer checks the status of the designated report. This way any FiC or VFP apps can all use the same approach