//START-004
DSVFileName:='CC'+CONVERTSTR(FORMAT(TODAY,0,'<day,2><month,2><year4>'),' ','0')+'.txt';
IF EXISTS(CustClrSetup.Filepath+DSVFileName) THEN
CustClrSetup."BAT Text File":= CustClrSetup.Filepath+DSVFileName;
//STOP-004
FileName := CustClrSetup."BAT Text File";
WHILE STRPOS(FileName,'\') > 0 DO
FileName := COPYSTR(FileName,STRPOS(FileName,'\') + 1);
PathName := CustClrSetup.Filepath;
NewFileName:= 'CC'+CONVERTSTR(FORMAT(TODAY,0,'<day,2><month,2><year4>') ,' ','0')+'.txt';
IF CustClrSetup."BAT Text File" <> PathName + FileName THEN
ERROR(Text50000);
FTPFile.WRITEMODE(TRUE);
FTPFile.TEXTMODE(TRUE);
FTPFile.CREATE(PathName + CustClrSetup."FTP File Name");
FTPFile.WRITE(CustClrSetup."User Name");
FTPFile.WRITE(CustClrSetup.Password);
FTPFile.WRITE('lcd C:\');
FTPFile.WRITE('cd order_sys');
FTPFile.WRITE('hash');
FTPFile.WRITE('get ' + FileName);
FTPFile.WRITE('bye');
FTPFile.CLOSE;
BATFile.WRITEMODE(TRUE);
BATFile.TEXTMODE(TRUE);
BATFile.CREATE(PathName + CustClrSetup."BAT File Name");
BATFile.WRITE('C:');
BATFile.WRITE('FTP -s:' + PathName + CustClrSetup."FTP File Name" + CustClrSetup."Server Address");
BATFile.CLOSE;
ReturnCode := SHELL(PathName + CustClrSetup."BAT File Name");
ERASE(PathName + CustClrSetup."FTP File Name");
ERASE(PathName + CustClrSetup."BAT File Name");
}
IF EXISTS(PathName+FileName) THEN BEGIN
COPY(PathName+FileName,CustClrSetup."Backup Filepath"+NewFileName);
ERASE(PathName+FileName);
END ELSE
ERROR('Cannot find %1',PathName+FileName);
ImportFile.TEXTMODE(TRUE);
ImportFile.OPEN(CustClrSetup."Backup Filepath"+NewFileName);