Цитата:
Сообщение от
AlexeyVS
Боюсь в 4ке это не будет работать (
Там используется более прозаический метод закачки файлов:
[/XPP]
Здесь, _name - имя файла без пути
странно метод runReport класса EPDocuGetWebLet
X++:
#define.BUFFER_SIZE(4096)
#File
client static void runReport(Common callerRecord, IISResponse response)
{
Query query = new Query();
QueryBuildDataSource qbds;
QueryRun queryRun;
EPSendDocument document;
BinData binData;
str fileName;
int fileOffset;
DictTable table = new DictTable(callerRecord.TableId);
str tempFileName;
boolean emptyReport;
;
if (WebLet::hasTableAccess(callerRecord.TableId))
{
qbds = query.addDataSource(callerRecord.TableId);
if (callerRecord && callerRecord.TableId != tablenum(DocuRef))
{
// Requery the record to test record level security
qbds.addRange(table.fieldName2Id('RecId')).value(SysQuery::value(callerRecord.RecId));
query.recordLevelSecurity(true);
queryRun = new QueryRun(query);
if (queryRun.next())
{
document = new EPSendDocument(callerRecord);
tempFileName = WinAPI::getTempFilename(WinAPI::getTempPath(), 'DAX');
document.parmOriginal(true);
document.parmFileName(tempFileName);
// Make document will run the report and send it to a PDF file with
// the path specified in tempFileName
document.makeDocument();
fileName = document.parmDocumentTitle();
// remove all ';' from the filename. These are treated as delimiters by Ie
fileName = strReplace(fileName, ';', '_');
emptyReport = (WinAPI::fileSize(document.parmFileName()) == 0);
response.clear();
response.contentType('application/Octet-Stream');
binData = new BinData();
if (emptyReport)
{
response.addHeader('Content-Disposition', 'attachment;filename="' + fileName + #txt + '"');
response.writeTxt(strfmt([EMAIL="'@SYS58533'"]'@SYS58533'[/EMAIL], fileName));
}
else
{
response.addHeader('Content-Disposition', 'attachment;filename="' + fileName + #pdf + '"');
// Loop over the stored file and chunk it down to the client
fileOffset = 0;
while(true)
{
// BP Deviation Documented
if (!binData.loadFile(tempFileName, fileOffset, #BUFFER_SIZE))
{
break;
}
fileOffset += #BUFFER_SIZE;
response.binaryWrite(binData.getVariant());
}
}
binData = null;
WinAPI::deleteFile(tempFileName);
}
}
}
}