procedure TfrmDownload.btnCancelClick(Sender: TObject);
begin
frmMain.IdFTP1.Abort;
Close;
end;
procedure TfrmDownload.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action := caFree;
frmDownload :=
nil;
end;
procedure TfrmDownload.IdFTP1Work(ASender: TObject; AWorkMode: TWorkMode;
AWorkCount: Int64);
begin
pbDL.Position := aWorkCount;
Application.ProcessMessages;
end;
procedure TfrmDownload.IdFTP1WorkBegin(ASender: TObject; AWorkMode: TWorkMode;
AWorkCountMax: Int64);
begin
pbDL.Max := IdFTP1.Size('
Downloads\' + strProgFile); ;
end;
procedure TfrmDownload.FormActivate(Sender: TObject);
var strDestFile :
string;
lStream : TFileStream;
strMsg :
string;
qryTemp : TIBCQuery;
begin
qryTemp := TIBCQuery.Create(Application);
with qrytemp
do
begin
Connection := dmFBData.ConData;
SQL.Text := '
SELECT INTMWMAIL, INTMWFTP, STRFTPHOST, STRFTPUSER, ' +
'
STRFTPPW, INTFTPPORT ' +
'
FROM SD_PARAMS';
try
Open;
idFTP1.Host := FieldbyName('
STRFTPHOST').AsString;
idFTP1.Username := FieldbyName('
STRFTPUSER').AsString;
idFTP1.Password := FieldbyName('
STRFTPPW').AsString;
idFTP1.Port := FieldbyName('
INTFTPPORT').AsInteger;
Close;
except
on E:
Exception do
begin
strMsg := '
Fehler bei Ermittlung FTP-Daten, Meldung: ' + E.
Message;
ShowWarningEx(strMsg);
end;
end;
Free;
end;
strDestFile := GetSpecialFolderLocation($23) + '
test\Updates\' + strProgFile;
lStream := TFileStream.Create(strDestFile, fmCreate
or fmShareDenyNone);
try
idFTP1.Connect;
Application.ProcessMessages;
idFTP1.Get('
Downloads\' + strProgfile, lStream);
except
on E:
Exception do
begin
ShowWarningEx('
Fehler bei Download, Meldung: ' + E.
Message);
lStream.Free;
idFTP1.Disconnect;
Exit;
end;
end;
idFTP1.Disconnect;
lStream.Free;
strMsg := '
Download beendet. ' + #13#10#13#10 +
'
Das Programm wird nun beendet und aktualisiert. Nach der ' +
'
Aktualisierung wird es neu gestartet.';
ShowInfo(strMsg);
RunAndWaitShell(strDestFile, '
/sp- /silent', 0);
Close;
frmMain.Close;
end;