erich.wanker Posted June 7, 2020 Share Posted June 7, 2020 Hi .. i must resync tables all 24 hours (with CSV files) I dont know - but it works sometimes - and sometimes not .. i use a UniThreadTimer (Interval 2000000) in Servermodule ( the servermodule has also a seperate ZConnection1 to the database to make the job) if i start the procedure "alle_importieren" manualy - everything works fine. procedure TUniServerModule.UniThreadTimer1Timer(Sender: TObject); var dd, mm, yyyy: Word; dda, mma, yyyya: Word; zuletzt: TDatetime; h, m, s, ms: Word; begin Importeinstellung.Refresh; if Importeinstellung.FieldByName('Aktiv').AsInteger = 1 then // Yes - do it begin zuletzt := Importeinstellung.FieldByName('lastSync').AsDateTime; decodedate(now, dda, mma, yyyya); decodedate(zuletzt, dd, mm, yyyy); if dda <> dd then begin DecodeTime(now, h, m, s, ms); if Importeinstellung.FieldByName('SyncTime').AsInteger = h then / h is the hour - in my case 18 ( 6 pm ) - the time of the server is set to 24 h begin alle_importieren; / the main import procedure Importeinstellung.Edit; Importeinstellung.FieldByName('lastSync').AsDateTime := now; Importeinstellung.post; Logger.AddLog('lastSync:' + datetostr(now)); end; end; end; end; ThanX for help :-) nice greetings erich Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted June 8, 2020 Share Posted June 8, 2020 14 hours ago, erich.wanker said: Hi .. i must resync tables all 24 hours (with CSV files) I dont know - but it works sometimes - and sometimes not .. i use a UniThreadTimer (Interval 2000000) in Servermodule ( the servermodule has also a seperate ZConnection1 to the database to make the job) if i start the procedure "alle_importieren" manualy - everything works fine. procedure TUniServerModule.UniThreadTimer1Timer(Sender: TObject); var dd, mm, yyyy: Word; dda, mma, yyyya: Word; zuletzt: TDatetime; h, m, s, ms: Word; begin Importeinstellung.Refresh; if Importeinstellung.FieldByName('Aktiv').AsInteger = 1 then // Yes - do it begin zuletzt := Importeinstellung.FieldByName('lastSync').AsDateTime; decodedate(now, dda, mma, yyyya); decodedate(zuletzt, dd, mm, yyyy); if dda <> dd then begin DecodeTime(now, h, m, s, ms); if Importeinstellung.FieldByName('SyncTime').AsInteger = h then / h is the hour - in my case 18 ( 6 pm ) - the time of the server is set to 24 h begin alle_importieren; / the main import procedure Importeinstellung.Edit; Importeinstellung.FieldByName('lastSync').AsDateTime := now; Importeinstellung.post; Logger.AddLog('lastSync:' + datetostr(now)); end; end; end; end; ThanX for help :-) nice greetings erich Hi Erich, UniThreadTimer need to lock thread. Then you can insert your procedure inside the block. See the MegaDemo. i have worked with unithreadTimer on ServerModule to do automatic Backup everynight at 23:00, and that works fine. i will try to send you an example. Quote Link to comment Share on other sites More sharing options...
Abaksoft Posted June 8, 2020 Share Posted June 8, 2020 Here we go : procedure TUniServerModule.UniThreadTimer1Timer(Sender: TObject); begin UniThreadTimer1.Lock; try //============== MyProcedure; //============== finally UniThreadTimer1.Release; end; end; To know : 1. We can not Use UniTimer in serverModule, use instead UniThreadTimer 2. We have to lock UniThreadTimer, execute a code then release it. 3. We can not use in MyProcedure something coded in MainModule or Main, as MainModule and Main are an Instance (Session Clientside) ! -> Common error : in myProcedure i want to use a SQL Query which is already coded in MainModule : This raises an AV. The good way is to create a classical Delphi Unit (not an UniguiDataModule) and rewrite the SQL query there. Regards. Quote Link to comment Share on other sites More sharing options...
erich.wanker Posted June 8, 2020 Author Share Posted June 8, 2020 ThanX a lot :-) i included "UniThreadTimer1.Lock .." and i will test it today :-) Thank you Erich Quote Link to comment Share on other sites More sharing options...
kkelchev Posted July 8, 2020 Share Posted July 8, 2020 Hi , did you check [node_recycling] setings in app server config file. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.