2013年1月10日星期四

How to transfer files from client to server.


public server static void  Main(args _args)
{
    BinData             binData = new BinData();
    Container           con;
    myClass             myclass;
    FileIoPermission    perm;
    Filename            filename = "C:\\Sunset.jpg";
    Filename            tofilename = "D:\\1111.jpg";
    ;

    perm = new FileIoPermission(tofilename, "w");
    perm.assert();

    con = myclass::GetFileDataOnClient(filename);
    binData.setData(con);
    binData.saveFile(tofilename);
    CodeAccessPermission::revertAssert();
}
public client static container GetFileDataOnClient(FileName _fileName)
{
    BinData  binData = new BinData();
    FileIoPermission    perm;
    ;

    if (WinAPI::fileExists(_filename))
    {
        perm = new FileIoPermission(_filename,"r");
        perm.assert();
        binData.loadFile(_fileName);
        CodeAccessPermission::revertAssert();
        return BinData.getData();
    }

    return conNull();
}

2013年1月5日星期六

How to control one of table field allowEdit for dataSource on Form

AX2009

//VAR Changed on 1/5/2013 at 14:49:48 by Tectura7 SOM16
private void THK_allowEditFieldList(FormDataSource   _tableDS,
                                    boolean          _allowEdit = false)
{
    int             field;
    DictTable       dictTable;
    DictField       dictField;
    tableId         tableId = _tableDS.table();
    fieldId         fieldId;
    fieldId         agreeStatue,tmpId;
    Name            tmpName;
;
    agreeStatue = fieldnum(PurchAgreementHeader, AgreementState);
    dictTable = new DictTable(tableId);
    setPrefix(dictTable.name());
    for (field = 1; field <= dictTable.fieldCnt(); field++)
    {
        fieldId     = dictTable.fieldCnt2Id(field);
        dictField   = new DictField(tableId, fieldId);
        tmpId       = dictField.id();
        tmpName     = dictField.name();
        if(! dictField.isSystem())
        {
            info(tmpName);
            if( tmpId != agreeStatue)
                _tableDS.object(tmpId).allowEdit(_allowEdit);
            //else
            //    info(tmpName);
        }
    }
}

AX2012
private void THK_allowEditFieldList(FormDataSource   _tableDS,
                                    boolean          _allowEdit = false)
{
    TableId     tableId     = _tableDS.table();
    fieldid     tmpId, agreeStatue = fieldnum(PurchAgreementHeader, AgreementState);
    void allowEditAllField(TableId _tableId)
    {
        SysDictTable    sysDictTable = new SysDictTable(_tableId);
        SysDictField    sysDictField;
        FieldId         fieldId = 0;
        TableId         parentTableId = sysDictTable.extends();
        ;
        setPrefix(sysDictTable.name());
        if (parentTableId)
        {
            allowEditAllField(parentTableId);
        }
        fieldId = sysDictTable.fieldNext(fieldId);
        while (fieldId)
        {
            sysDictField    = new SysDictField(_tableId, fieldId);
            tmpId           = sysDictField.id();
            fieldId         = sysDictTable.fieldNext(fieldId);
            if (sysDictField.isSystem())
                continue;
            if(tmpId != agreeStatue)
            {
                _tableDS.object(tmpId).allowEdit(_allowEdit);
            }
            //info(strFmt("%1[%2]",sysDictField.name(),sysDictField.id()));
        }
    }
;
    allowEditAllField(tableId);
}