Показать сообщение отдельно
Старый 28.01.2016, 10:34   #1  
Art_Tanis is offline
Art_Tanis
Участник
 
225 / 36 (2) +++
Регистрация: 04.02.2014
Проблема с экспортом ресурса AOT
Добрый день!
Помогите пожалуйста - написал джоб чтобы экспортировал ресурс AOT в файл - все работает.
Написал класс - наследник RunBaseBatch и вот тут не работает - сначала ругался на FileIOPermissions, права вроде дал, однако теперь выпадает ошибка Unable to save data to the file "\\Client\P$\StdPriceTemplate.xlsx".

X++:
public void run()
{
    FileIOPermission        readPermission;
    FileIOPermission        readPermission2;
    FileIOPermission        readPermission3;
    Set                     permissionSet = new Set(Types::Class);
    ;

    resourcesNode = infolog.findNode(#ResourcesPath);
    templatePath = templateFolder_W() + templateName;
    resNode = resourcesNode.AOTfindChild(templateName);
    openResourcePath = SysResource::saveToTempFile(resNode);
    [path, filenameOnly, type] = fileNameSplit(openResourcePath);
    userInputPath = WinApi::getSaveFileName(0, ['All Files', '*.*'], '', "@SYS54846", '', filenameOnly);

    readPermission3 = new FileIOPermission(filenameOnly,"rw");
    if (userInputPath)
    {
        nodeData = SysResource::getResourceNodeData(resNode);

        switch (typeof(conpeek(nodeData, 1)))
        {
            case Types::String :
                textBuffer = new TextBuffer();
                textBuffer.setText(conpeek(nodeData, 1));

                if (filenameOnly && textBuffer.size() > 0)
                    if (strscan(userInputPath, '.', strlen(userInputPath), -strlen(userInputPath)) != 0)
                        textBuffer.toFile(userInputPath);
                    else
                        textBuffer.toFile(userInputPath + type);
            break;
            default :
            binData = new BinData();
            readPermission = new FileIOPermission(openResourcePath,"rw");
            readPermission2 = new FileIOPermission(userInputPath + type,"rw");
            permissionSet.add(readPermission);
            permissionSet.add(readPermission2);
            permissionSet.add(readPermission3);
            CodeAccessPermission::assertMultiple(permissionSet);
            binData.loadFile(openResourcePath);

            if (filenameOnly && conlen(binData.getData()))
                 if (strscan(userInputPath, '.', strlen(userInputPath), -strlen(userInputPath)) != 0)
                    binData.saveFile(userInputPath);
                else
                    binData.saveFile(userInputPath + type);
            break;

        }
    }
}
Вываливается на этапе binData.saveFile(userInputPath + type);