|
| Iniciado por guest, 10,abr. 2016 08:45 - 4 respuestas |
| |
| | | |
|
| |
| Publicado el 10,abril 2016 - 08:45 |
V20. I need to run a server procedure every 10 seconds. I have looked at help, i have followed the instructions, but I cant get it to work.
For testing I have only a single statement in the procedure STATIC = "last run at" SO no clever stuff here. I found that TRACE("HERE") causes it t abend
My settings are immediate, infinate, (it wont allow delay setting - grayed), no HFSQL etc. |
| |
| |
| | | |
|
| | |
| |
| Publicado el 10,abril 2016 - 15:26 |
Maybe set delay on 0,05 second?
I donnot work with timers in webdev but hae worked with them in windev. So Iam not an expert but i think it might just do the trick for you
regards
Allard |
| |
| |
| | | |
|
| | |
| |
| Publicado el 11,abril 2016 - 18:56 |
| Maybe if you use timers combined with AJAXExecute you can get it to work. |
| |
| |
| | | |
|
| | |
| |
| Publicado el 12,abril 2016 - 07:33 |
Luis,
I've found the trick on timers like this in WebDev is getting your head around the Local, Server, and browser procedures. I'm not sure what your procedure is doing every 10 seconds, so your use of this info (if helpful) may need to be modified based on your requirements. For example if trying to update a browser UI element, then you may need to add the use of Ajax and/or threads.
Nonetheless, I hope my example helps to get to your answer. It took me a while to get clear on how to implement.
In my example, I use timers to manage Session Duration (Inactive Session Timeout). This is used for two main functions.
1. To keep a page active indefinitely (like a dashboard) without worrying about the WebDev server expiring the context/session with extended periods of no user input. 2. To extend the timeout of a user login beyond the server session/contexts maximum while still maintaining a mechanism to identify a true inactive user after a period of time.
In my implementation I created a Local Procedure and a Local Procedure(Browser). I've included simplified code here for an example.
"Local Procedure": PROCEDURE KeepAlive() AJAX gnLoc_RefreshTimer++ sTMpRes is string IF gnLoc_RefreshTimer >= 4 THEN sTMpRes = "DOTIMEOUT" ELSE sTMpRes = "OK" END
RESULT = sTMpRes
"Local Browser Procedure": PROCEDURE Loc_KeepAlive() sTmpRes is string = AJAXExecute(KeepAlive) IF sTmpRes = "DOTIMEOUT" THEN ExecuteProcess(Link_MDL_LogOut,trtClick) END
I implemented these in the Template used by my pages. The page has the Global Variable (gnLoc_RefreshTimer is int). In the WL Load (onload) of PageTemplate (Browser), I instantiate the page timer by calling: Timer(Loc_KeepAlive,Default_Refresh_Timer) where "Default_Refresh_Timer" is just a constant of hundredths of seconds frequency for calling the Timer (in my example every 300 seconds since that is less than the server session timeout)
So on load of a Page the Timer is started to run every 300 seconds. The Timer calls the Loc_KeepAlive browser procedure, which calls the AJAX Local Server Procedure "KeepAlive".
KeepAlive() simply increments the page gnLoc_RefreshTimer counter to track how many times the session has been extended by the "keep alive". When the counter reaches the 4th iteration/call, KeepAlive returns "DOTIMEOUT".
When Loc_KeepAlive() receives "DOTIMEOUT" from the AjaxExecute(KeepAlive), it calls ExecuteProcess of a page Button in order to trigger a Server-type function. In this example it calls the Server code of the pages logout button.
The interaction between Server and Browser procedures is what is key to understand. We use this type of interaction, often with hidden Buttons to hold server code called by the Browser procedure using ExecuteProcess. This is especially useful when you want to create a Progress dialog (spinning wheel) to prevent "double-clicking" and/or session timeout during the execution of a long server procedure or transaction. In that example, you create a Button which just calls Browser code to load a "Wait/Progress" cell/popup and call AJAXExecuteAsynchronous(Local_Server_Procedure,Local_Browser_Procedure). A hidden button can then be called by the Local_Browser_Procedure to do server code like refreshing variables, closing a dialog, etc.
We also use a similar method to enable Browser double-click of Table Rows, Columns, or Cells to trigger a Server Procedure.
The main workflow to get down is:
1. Use Page/Control browser code to call a Local_Procedure (Browser). 2. In the Local_Procedure (Browser) use AjaxExecute to call Local_Procedures with server code. Then update the UI based on the result. 3. If you want to run normal Server code at the end of the Bowser procedure, put it in a Button (visible or hidden). Then just call the button using ExecuteProcess(BTN_NAME,trtclick).
Hope this helps you.
Stephen Myers |
| |
| |
| | | |
|
| | |
| |
| Publicado el 12,abril 2016 - 11:01 |
Hi Michael,
If I understand the Help correctly, an automatic or delayed procedure will be installed on the deployment server when you deploy/update the site. So I guess in testmode it won't work, because there's no permanent deployment engine on the dev machine. I suggest you test it on a test sever.
Regards, Piet |
| |
| |
| | | |
|
| | | | |
| | |
|