NetTalk Central

Author Topic: Larges Reports on NT  (Read 5283 times)

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Larges Reports on NT
« on: December 22, 2022, 04:19:35 AM »
Hi, is possible create a process or report when finish in a server send notification to user with a link for download like google when export email:

Google is creating a copy of files from 2 products
This process can take a long time (possibly hours or days) to complete.
You'll receive an email when your export is done.

DonRidley

  • Don Ridley
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 729
  • donaldridley2011@gmail.com
    • View Profile
    • Email
Re: Larges Reports on NT
« Reply #1 on: December 22, 2022, 04:56:01 AM »
I don't see why you couldn't.

You could say that any file larger than x megabytes would trigger a "long" process.

Then in your user interface, notify the user that the report will take a while to process and that they will be notified when the report is ready for download.

Report process runs on its own thread.

When it's finished, file would be saved to a folder visible to the web server.

Then create a link to the file and email or SMS it to the user.

"Eliminate the impossible, whatever remains, however unlikely, must be the truth."

NetTalk 12.55
Clarion 11

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: Larges Reports on NT
« Reply #2 on: December 22, 2022, 09:39:16 AM »
Did you try a very long report with NT?

I made one using the progress bar that comes with NT but the webserver gets too slow waiting for that sub-process to finish as you indicate and on several occasions the webserver crashed

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Larges Reports on NT
« Reply #3 on: December 22, 2022, 09:18:42 PM »
You should probably better understand the cause of the crash etc so that you can determine the fault.
Also make sure your progress timer on such a long report is really slow.

To answer your question, of course you can let a user submit a report request, and then email them the result.

cheers
Bruce

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: Larges Reports on NT
« Reply #4 on: December 27, 2022, 05:11:47 AM »
I take a slightly different approach.

I start generating the report.

I give the user a message to say its generating.

If it generates quickly, I open the report.

If it takes longer (in my case a few minutes), I give them a message to say it will appear later in the "reports" section. My program has a place where all past reports are stored and viewable (by user) so they can refer back to them. So this makes sense to them.

In my case, duration not filesize is the reliable indication. I don't use the progress indicatior as I wrote all this before it existed, and on the web users would just rather go and do something else and go back and check (or be notified) that the report has finished.

Technically, most of this is done client side within the browser.

Regards
Bill

osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: Larges Reports on NT
« Reply #5 on: December 27, 2022, 10:24:41 AM »
"Technically, most of this is done client side within the browser."

but how can I send a process to the server and have the thread close?

i have no idea

Thanks..

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Larges Reports on NT
« Reply #6 on: December 27, 2022, 09:34:58 PM »
You could do something as simple as
a) have a button on a page
b) call START to start a thread when that button is pressed.

Or better yet, for the code under the button just
a) call p_web.ReplyComplete()
b) call the report procedure.

Incidentally, there's a button type that does this for you, called a START button.

Cheers
Bruce

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: Larges Reports on NT
« Reply #7 on: December 27, 2022, 09:47:50 PM »
Here is my methodology:

1. The report will have a predetermined filename (this is so I can check for its existence).

2. I start printing the report. Then I take them to a NetWebPage that has two parts. (technically, I take them to this page then do an ajax call to start printing, then do the following)

(a) A Message saying wait

(b) Javascript that calls the server and asks if the report is complete (being able to open the filename in write mode, means its been completed).

3. If the report is complete, I open it (with Javascript)

4. If the report took too long, i open another page saying its taking too long and it will arrive later.

Below is the javascript I use at step 2b. This code checks every 1.5 seconds, ten times, if it doesnt turn up by then, it checks every 5 seconds another 10 times, again it checks each 10 seconds another 10 times, if the report doesnt turn up by them it redirects to a NetWebPage called SlowReport which shows a message, telling them it will turn up later.

So if a report takes longer than 2:45 you'll get a message. The slower polling is to maximise responsivness at the begining and not waste server power if its taking longer.

The ReportWrap mentioned in the Javascript is where I take them when the report finishes. Mine is a bit more complicated than necessary as the report preview is placed in an iFrame, so the report can also be emailed at this point in time.

The GenReport function checks to see if the report has been completed.

    packet.Append( '<script>'&CRLF)
    packet.Append( 'var reportTimer = setInterval(CheckReportProgress,1500);'&CRLF)
    packet.Append( 'var intCount=0;'&CRLF)
    packet.Append( 'var reportfn='''&CLIP(Encode7Bit(lFilename))&''';'&CRLF)
    packet.Append( 'function CheckReportProgress(){{'&CRLF)
    packet.Append( 'var jqxhr = $.ajax({{url: "'&CLIP(lURL)&'/GenReport?f='&CLIP(Encode7Bit(lFilename))&'",dataType: "json",data: {{'&CRLF)
    packet.Append( ' result : "name",'&CRLF)
    packet.Append( ' value : "value" } } '&CRLF)
    packet.Append( ' ).done (function(data) {{'&CRLF)
    packet.Append( '    console.log(''Result: '' + data.result); ;'&CRLF)
    packet.Append( '    if (data.result==1) {{'&CRLF)
    packet.Append( '      clearInterval(reportTimer);'&CRLF)
    packet.Append( '      document.getElementById(''openReport'').style.display = "block";'&CRLF)
    packet.Append( '      location.href=''/ReportWrap?fn='&CLIP(Encode7Bit(ReplaceBackSlashWithSlash(lFilename)))&''';'&CRLF)
    packet.Append( '    } else {{'&CRLF)
    packet.Append( '      intCount++;'&CRLF)
    packet.Append( '      if (intCount>30) {{;'&CRLF)
    packet.Append( '        clearInterval(reportTimer);'&CRLF)
    packet.Append( '        location.href=''/SlowReport'';'&CRLF)
    packet.Append( '      } else {{'&CRLF)
    packet.Append( '        if (intCount>20) {{'&CRLF)
    packet.Append( '          clearInterval(reportTimer);'&CRLF)
    packet.Append( '          reportTimer = setInterval(CheckReportProgress,10000);'&CRLF)
    packet.Append( '        } else {{'&CRLF)
    packet.Append( '          if (intCount>10) {{'&CRLF)
    packet.Append( '            clearInterval(reportTimer);'&CRLF)
    packet.Append( '            reportTimer = setInterval(CheckReportProgress,5000);'&CRLF)
    packet.Append( '          }'&CRLF)
    packet.Append( '        }'&CRLF)
    packet.Append( '      } '&CRLF)
    packet.Append( '    } '&CRLF)
    packet.Append( ' });'&CRLF)
    packet.Append( '};'&CRLF)
    packet.Append( '$.get('''&CLIP(lURL)&CLIP(st.GetValue())&'&m=c&f=''+reportfn);'&CRLF)
    packet.Append( '</script>'&CRLF)
    DO SendPacket

bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: Larges Reports on NT
« Reply #8 on: December 27, 2022, 11:39:38 PM »
Oh.. in direct answer to your question, this bit does it, its at the bottom, and its called when the page loads:

packet.Append( '$.get('''&CLIP(lURL)&CLIP(st.GetValue())&'&m=c&f=''+reportfn);'&CRLF)

Its a bit confusing as you can't see all my code (and I have a lot of other stuff going on). This bit:

$.get('/YourReport?f=thefilenameyouwant');




osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: Larges Reports on NT
« Reply #9 on: December 29, 2022, 04:09:43 AM »
Hi Bruce,i missed tell you that i use the start button, but after report process start all other transaction said Slow Request: [760] and really is very slow, only when a appear pdf window generating the web server return to a normal.

Is a desktop app large report converted to NT, it is a customer account statement, in desktop mode run and completed, and generates a pdf of 500 mb or more with draft mode for small pdf.

i trying to undestand the bshields code and many thanks for share.

My idea is if possible is send a request to the server for a particular report with parameter and this report execute outside any thread of NT and when finish the report send email to user for downlod.

it is very difficult for me to create app a demo for the large amount of data

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Larges Reports on NT
« Reply #10 on: January 01, 2023, 10:21:49 PM »
>> i missed tell you that i use the start button,

an important detail, but definitely a good idea.

>> but after report process start all other transaction said Slow Request: [760] and really is very slow, only when a appear pdf window generating the web server return to a normal.

That doesn't surprise me, and will depend largely on the hardware, and database you are using.

Naturally a big report will work hard on the database engine. It will also likely consume a bunch of CPU on the server, especially if you have code in the report itself. And being large it will have a fair amount of disk activity as it writes the WMF files. Then once the WMF files have been constructed, they need to be loaded, joined, and converted into a PDF. This will all take significant work.

If you have a machine with limited CPU power (perhaps a VM with only one core) then all the other code will run slowly. If you have a serialized, or slow, connection to the database then any other requests talking to the database will be slower. If the database is running on the same (underpowered?) server machine then naturally everything slows down.

Incidentally a "slow request" is only posted once the request has been completed. So it would seem your server is still serving - just slowly.





osquiabro

  • Hero Member
  • *****
  • Posts: 687
    • View Profile
    • Email
Re: Larges Reports on NT
« Reply #11 on: January 03, 2023, 05:39:03 AM »
I'm creating my own solutions, I don't know if it's a good practice, but it works for me.

I created an .exe only for reports and by parameters I pass the required data, that .exe runs independently of NT so no more slowness in NT and when it ends, an email is sent to the user to download it, the account statements are saved in a table and the user downloads them from there.