procedure TForm1.Timer1Timer(Sender: TObject);
begin
if (StrToTime(TimeToStr(Now))>StrToTime('01:00:00')) and (StrToTime(TimeToStr(Now))<StrToTime('02:00:01')) then
begin
try
last_sync := IdHTTP1.get('http://xx.xx.xx.xx/api/get_date');
finally
IdHTTP1.Free;
end;
last_sync:=last_sync.Substring(0, 19);
MSSQLConnection1.Connected:=True;
SQLTransaction1.Active:=True;
query:=TStringList.Create;
query.Clear;
query.Add('SELECT * FROM MG_DOC');
SQLQuery1.SQL:=query;
SQLQuery1.Active:=True;
CSVExporter1.FileName:='doctypes.csv';
CSVExporter1.Execute;
SQLQuery1.Active:=False;
query.Clear;
AbZipper1 := TAbZipper.Create(Application);
AbZipper1.FileName := 'export.zip';
AbZipper1.AddFiles('doctypes.csv',1);
AbZipper1.Password := 'xxx';
AbZipper1.Save;
AbZipper1.CloseArchive;
DeleteFile('doctypes.csv');
Process1.Create(nil);
Process1.Executable:='pscp.exe';
Process1.Parameters.Add('-P xxx -pw xxx "export.zip" xxx@xx.xx.xx.xx:"/var/www/html/xxx"');
Process1.Options := Process1.Options + [poWaitOnExit];
Process1.Execute;
DeleteFile('export.zip');
try
job := IdHTTP2.get('http://xx.xx.xx.xx/api/sync');
finally
IdHTTP2.Free;
end;
SQLTransaction1.Active:=False;
MSSQLConnection1.Connected:=False;
query.Free;
SQLQuery1.Free;
CSVExporter1.Free;
AbZipper1.Free;
Process1.Free;
end;
end;