public class DGS_FieldNameListTmp extends common
{
/// <summary>
///
/// </summary>
public static DGS_FieldNameListTmp populate(TableId _tableId)
{
SysDictTable dictTable = new SysDictTable(_tableId);
SysDictField dictField, extdictField;
DGS_FieldNameListTmp tempTable;
FieldId extFieldId;
FieldId fieldId = dictTable.fieldNext(0);
while (fieldId)
{
dictField = dictTable.fieldObject(fieldId);
if (dictField.isSql() && !dictField.isSystem() && dictField.name() != "Modified")
{
if(dictField.arraySize() == 1)
{
tempTable.FieldName = dictField.name();
tempTable.FieldLabel = dictField.label();
tempTable.FieldId = dictField.id();
tempTable.insert();
}
else if(dictField.arraySize() > 1)
{
for(int i = 1; i <= dictField.arraySize(); i++)
{
extFieldId = fieldId2Ext(fieldId, i);
extdictField = dictTable.fieldObject(extFieldId);
tempTable.FieldName = extdictField.name();
tempTable.FieldLabel = extdictField.label();
tempTable.FieldId = extdictField.id();
// info(strFmt("%1 , %2 , %3", extFieldId , extdictField.name(), extdictField.label()));
tempTable.insert();
}
}
}
fieldId = dictTable.fieldNext(fieldId);
}
return tempTable;
}
}
===================================
// 尋找query
_queryTable = DGS_WHSTemplateQueryTable::findWaveByCode(_waveTemplateType,_queryCode);
if(!_queryTable)
{
throw Error(strFmt('Query not find in settings.'));
}
else
{
//找尋QUERY中有多少DATASOURCEC:
_demoTable = DGS_TableNameListTmp::populateByQuery(_queryTable.WHSQueryName);
select firstOnly _demoTable where _demoTable.TableName == _tempTable;
if(!_demoTable)
{
throw Error(strFmt('%1 Table not exists in %2 Query.', _tempTable, _queryCode));
}
//找尋TABLE中有多少FIELD:
TableId _tableId = tableName2Id(_tempTable);
_demoFieldTable = DGS_FieldNameListTmp::populate(_tableId);
select firstOnly _demoFieldTable where (_demoFieldTable.FieldLabel == _tempField || _demoFieldTable.FieldName == _tempField );
if(!_demoFieldTable)
{
throw Error(strFmt('%1 Field not exists in %2 Table.', _tempField, _tempTable));
}
}
留言列表