Показать сообщение отдельно
Старый 30.09.2008, 09:42   #11  
niktata is offline
niktata
Участник
 
17 / 10 (1) +
Регистрация: 23.07.2008
Адрес: Санкт-Петербург
Всем спасибо за помощь, вроде разобрался.

Сделал несколько функций:
X++:
    str strPropertyGet(str _property)
    {
        str             ret;
        ComVariant      varOut = new ComVariant(ComVariantInOut::Out_retVal,ComVariantType::VT_BSTR);
        ComDispFunction _propertyGet = new COMDispFunction(Choose, _property, COMDispContext::PropertyGet);
        ;
        ret = (_propertyGet.call(varOut) ? "" : varOut.bStr());
        varOut.finalize();
        _propertyGet.finalize();
        return strLTrim(strRTrim(ret));
    }

    int intPropertyGet(str _property)
    {
        int             ret;
        ComVariant      varOut = new ComVariant(ComVariantInOut::Out_retVal,ComVariantType::VT_I4);
        ComDispFunction _propertyGet = new COMDispFunction(Choose, _property, COMDispContext::PropertyGet);
        ;
        ret = (_propertyGet.call(varOut) ? 0 : varOut.int());
        varOut.finalize();
        _propertyGet.finalize();
        return ret;
    }

    date datePropertyGet(str _property)
    {
        date            ret;
        ComVariant      varOut = new ComVariant(ComVariantInOut::Out_retVal,ComVariantType::VT_DATE);
        ComDispFunction _propertyGet = new COMDispFunction(Choose, _property, COMDispContext::PropertyGet);
        ;
        ret = (_propertyGet.call(varOut) ? dateNull() : varOut.date());
        varOut.finalize();
        _propertyGet.finalize();
        return ret;
    }
Для того, чтобы код не вываливался при попытке достать изображение, если изображение отсутвует пришлось сделать немного подругому. Возможно, кривовато, но работает

X++:
        emplId = strPropertyGet("Код");
        select forupdate firstonly firstfast
            emplTable
                where emplTable.EmplId == emplId;
        select forupdate firstonly firstfast companyImage
            where companyImage.RefRecId == emplTable.RecId;

        retVal              = new ComVariant(ComVariantInOut::Out_retVal, ComVariantType::VT_DISPATCH);
        propertyGet         = new COMDispFunction(Choose, "Хранилище", COMDispContext::PropertyGet);

        propertyGet.call(retVal);

        if (retVal.variantType() != ComVariantType::VT_NULL)
        {
            pic = Choose.(); // ХранилищеДополнительнойИнформации.Хранилище как Хранилище
            kart = con.NewObject("Картинка");
            kart = pic.();
            kart.("C:\\tmp.jpg");
            binData = new BinData();
            binData.loadFile("C:\\tmp.jpg");
            cont = binData.getData();

            companyImage.RefTableId     = 103;
            companyImage.RefRecId       = emplTable.RecId;
            companyImage.HasImage       = NoYes::Yes;
            companyImage.RefCompanyId   = 'etl';
            companyImage.Image          = cont;

            if (companyImage.RecId)
                emplTable.update();
            else
                companyImage.insert();
        }
        retVal.finalize();
        propertyGet.finalize();