Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
6
Erster Beitrag:
vor 1 Jahr, 4 Monaten
Letzter Beitrag:
vor 1 Monat, 1 Woche
Beteiligte Autoren:
Danny Lauwers, Fabrice Harari

[WB21] Long running MS SQL Query in background ?

Startbeitrag von Danny Lauwers am 07.07.2016 12:57

Hi,

What would be the best strategy to run an long calculation that is done in a MS SQL stored Procedure triggered by a user action from a webpage ?

The user presses the"Calculate" button on the webpage. This will call a procedure on the WebDev Server Side that is calling the MS SQL Stored Procedure that does the calculation. This calculation takes about 1 to 2 minutes depending on the parameters.

I show a wait dialog on the screen, but my Browser (Chrome) will display an warning box that the server is not responding. You can select cancel or wait. But if it takes to long it will just abort the whole thing ! Even the warning box is not wanted.

Can I start a thread on server side to run this procedure in the background ?
En when it is finished, how can I notify the user ? I would like to show a "Calculating NOW" message in the browser that would disappear when the calculation is done, even if this calculation or process would take a few minutes and would exceed the browser response timeout !

How to best approach this kind of problem ?

Thanks
Danny

Antworten:

Hi Danny,

you could use a call made with ajaxexecuteasynchronous from browser code...

This call doesn't wait for a return, so you would't have your warning message, and it will call a local/blorwser procedure when finished

Best regards

von Fabrice Harari - am 07.07.2016 14:20
Thanks Fabrice,

I'll try that direction and post the results here !

Danny

von Danny Lauwers - am 07.07.2016 23:25

Re: [WB22] Long running MS SQL Query in background ?

Hi,

It is been a while, and we have the impression that the AJAXExecuteAsynchronous does not do anything Asynchronous ?? (v21 + v22)

When I call the following code from a button "Save"


BROWSERCODE - Click
ShowWaitPopup(True) // This will show a please wait...
AJAXExecuteAsynchronous(ajaxUpdateControls,ActionSave,B_BackgroundSaveCompleted)



BROWSERCODE - AfterClicking
ToastDisplay("Test - Done - Test Test")



BROWSERCODE -B_BackgroundSaveCompleted
ShowWaitPopup(False) // This will hide please wait...



The ActionSave function is a serverfunction that does a long calculation/MSSQL call.

The Please wait popup has a animating gif, the popup is shown with the message, but the gif is not animating ??

I would assume as the AJAXExecuteAsynchronous is non blocking, that the ToastDisplay with the test message In the "after clicking" would appear directly after clicking the save button !
This is NOT the case.

I tried different options (Ajax, no Ajax - and no server action, Not submitting the values to the server,...

Nothing seems to help ??

The browser seems to be locked until the long procedure is ready, then the Test message is displayed and the Please wait popup is hidden.

Anybode any idea what could be wrong here ?

Thanks
Danny

von Danny Lauwers - am 13.10.2017 13:36

[WB22] Long running MS SQL Query in background ? - SOLVED

Hi,

Where back

There seem to be a conflict between AJAXExecuteAsynchronous and Submitting Values to the server option ! If you do this on the browser click event

But, I finally got it working !

Based on an article from Uncle Pete (Click here Article from Uncle Pete)

In my Save button I now have the following code


BROWSER CODE - Click
-Empty-

SERVER CODE - Click AJAX ENABLED
-Empty-

BROWSER CODE - After Click
B_ShowWaitPopup(True)
AJAXExecuteAsynchronous(ajaxUpdateControls,ActionSave,B_BackgroundSaveCompleted)


The Save button has the Submit Values to server on AND Run the server click code of the button. The server code is Ajax Enabled.

The click of the button will submit the values of the controls, and update them on the server. After this (after click) is done I call the AJAXExecuteAsynchronous.

Somehow if you combine the AJAXExecuteAsynchronous with the option Submit Values to the Server in the browser click event, it does not work !! It is not executed asynchronous !

If you don't need the actual values to be updated, you can directly call AJAXExecuteAsynchronous in the browser click event, else use this trick !

So eventually by just moving my code from the browser - Click event to the browser - After click event, all is executed asynchronously as wanted ! :rp:

Danny

von Danny Lauwers - am 13.10.2017 14:19

Re: [WB22] Long running MS SQL Query in background ?

Hi Danny,

I suspect your option ajaxUpdateControls...

It's anew option (therefore a new behavior) and as the calls says that it needs to update the controls, that may explain the wait.

The way I do things is with the old (and at the time only) option of NOT updating the UI in the server code, and just returning the result to the browser procedure, in charge of doing anything needed (display or not)

Best regards

von Fabrice Harari - am 13.10.2017 14:56
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.