22. Juni 2015 08:30
IF URL = '' THEN EXIT;
IF NOT CONFIRM(Text016,TRUE,URL) THEN EXIT;
IF GUIALLOWED THEN BEGIN
Window.OPEN('#1#############################################\\' + Text017 + '\' + Text018);
Window.UPDATE(1,STRSUBSTNO(Text012,URL));
END;
IF ISSERVICETIER THEN BEGIN
HTTPRequest := HTTPRequest.XMLHTTPRequestClass;
HTTPRequest.open('GET',URL,FALSE,'','');
HTTPRequest.send('');
IF HTTPRequest.status <> 200 THEN
ERROR(Text013,HTTPRequest.status,HTTPRequest.statusText);
END ELSE BEGIN
CREATE(WinHTTP,TRUE,TRUE);
WinHTTP.open('GET',URL,FALSE);
WinHTTP.send('');
IF WinHTTP.status <> 200 THEN
ERROR(Text013,WinHTTP.status,WinHTTP.statusText);
END;
IF ISCLEAR(SystemShellFilesSystem) THEN
CREATE(SystemShellFilesSystem,TRUE,TRUE);
IF ISCLEAR(SystemShellControl) THEN
CREATE(SystemShellControl,TRUE,TRUE);
TempFolderName := GetTempPath;
TempFileName := TempFolderName + '\NAV_NR.JPG';
TempFolderName := TempFolderName + '\NAV_NR';
IF SystemShellFilesSystem.FolderExists(TempFolderName) THEN BEGIN
SystemShellFilesSystem.DeleteFolder(TempFolderName,TRUE);
SLEEP(100);
END;
SystemShellFilesSystem.CreateFolder(TempFolderName);
IF SystemShellFilesSystem.FileExists(TempFileName) THEN
SystemShellFilesSystem.DeleteFile(TempFileName);
IF ISSERVICETIER THEN BEGIN
ClientFile.WriteAllBytes(TempFileName,HTTPRequest.responseBody);
END ELSE BEGIN
TempFile.CREATE(TempFileName);
TempFile.CREATEOUTSTREAM(OutStr);
InStr := WinHTTP.responseStream;
COPYSTREAM(OutStr,InStr);
TempFile.CLOSE;
END;
//Fehler entsteht ab dieser Befehlszeile
SystemShellItems := SystemShellControl.NameSpace(TempFileName).Items;
SystemShellControl.NameSpace(TempFolderName).CopyHere(SystemShellItems);
FOR Index := 1 TO SystemShellItems.Count DO BEGIN
SystemShellItem := SystemShellItems.Item(Index - 1);
FileName := RemovePath(SystemShellItem.Path);
IF ISSERVICETIER THEN BEGIN
TempText.ADDTEXT(ClientFile.ReadAllText(TempFolderName + '\' + FileName));
TempBlob.Blob.CREATEOUTSTREAM(OutStr);
TempText.WRITE(OutStr);
TempBlob.Blob.CREATEINSTREAM(InStr);
END ELSE BEGIN
TempFile.OPEN(TempFolderName + '\' + FileName);
TempFile.CREATEINSTREAM(InStr);
END;
IF GUIALLOWED THEN
Window.UPDATE(1,STRSUBSTNO(Text019,FileName));
// ReadTextStream(InStr,ConvertCP);
IF NOT ISSERVICETIER THEN
TempFile.CLOSE;
SystemShellFilesSystem.DeleteFile(TempFolderName + '\' + FileName);
END;
IF SystemShellFilesSystem.FileExists(TempFileName) THEN
SystemShellFilesSystem.DeleteFile(TempFileName);
IF SystemShellFilesSystem.FolderExists(TempFolderName) THEN
SystemShellFilesSystem.DeleteFolder(TempFolderName,TRUE);
CLEAR(WinHTTP);
CLEAR(SystemShellFilesSystem);
CLEAR(SystemShellControl);
IF GUIALLOWED THEN
Window.CLOSE;