2012年7月14日星期六

How to get Occenabled table from AOT

static void THK_tableOccenabledFromAOT01(Args _args)
{
    #AOT
    #properties
    TreeNode        TreeNode = TreeNode::findNode(#TablesPath);
    str             tableName;
    str             temporaryProperty;
    sysdictTable    m_dictTable;
    int             i,records,m;
    dictionary      m_dictionary = new dictionary();
    #File
    #WinAPI
    #Avifiles
    CommaIo                 commaIO;
    SysOperationProgress    sysProgress;
    fileName                fileName;
    FileIOPermission        permission;
    int                     start;
;
    if(!Box::yesNo("Are your sure lookup Occenabled table infomation?",dialogButton::No,"Occenabled Table"))
        return;
    fileName = WinAPI::getFolderPath(#CSIDL_Personal) + "\\" + "A02AvgPrice.csv";// + date2str(systemdateget(),321,2,0,2,0,2) + ".CSV";
    permission  = new FileIOPermission(fileName,#io_write);
    permission.assert();
    commaIo = new CommaIo(fileName,#io_write);
    if(!commaIo)
    {
        warning("Please close your csv file and try again. Thanks!");
        return;
    }
    if(commaIo.status() == IO_Status::Ok)
        CommaIo.outFieldDelimiter(",");
    else
        return;
    start = timeNow();
    records = m_dictionary.tableCnt();
    sysProgress = SysOperationProgress::newGeneral(#AviUpdate,"Waitting ... write CSV file",records);
    CommaIo.writeExp(["Id","Table Id","Table Name","Table Label","Occenabled","utilElementType"]);
    for (i = 1; i < records; i++)
    {
        m_dictTable = new sysdictTable(m_dictionary.tableCnt2Id(i));
        sysProgress.incCount(1);
        sysProgress.setText(strfmt("completed %1 [%2]: %3",i/ records * 100, i, m_dictTable.name()));
        if(!m_dictTable.occEnabled())
        {
            m++;
            CommaIo.writeExp([m,m_dictTable.id(),m_dictTable.name(),m_dictTable.label(),m_dictTable.occEnabled(),m_dictTable.utilElementType()]);
        }
        sysProgress.update(true);
    }
    if(m)
    {
        if (winAPI::fileExists(fileName))
        {
            winAPI::shellExecute(fileName);
        }
    }
    CodeAccessPermission::revertAssert();
    info(strfmt("It takes time %1",global::time2StrHMS(timenow() - start)));
    info(strfmt("completed %1 records",m));
}
------------------
static void THK_tableOccenabledFromAOT02(Args _args)
{
    #AOT
    #properties
    TreeNode        TreeNode = TreeNode::findNode(#TablesPath);
    str             tableName;
    AnyType         occenabledProperty;
    sysdictTable    m_dictTable;
    int             i,records,m;
    Dictionary      dictionary = new dictionary();
    #File
    #WinAPI
    #Avifiles
    CommaIo                 commaIO;
    SysOperationProgress    sysProgress;
    fileName                fileName;
    FileIOPermission        permission;
    int                     start;
    ;
    if(!Box::yesNo("Are your sure lookup Occenabled table infomation?",dialogButton::No,"Occenabled Table"))
        return;
    fileName = WinAPI::getFolderPath(#CSIDL_Personal) + "\\" + "A02AvgPrice.csv";// + date2str(systemdateget(),321,2,0,2,0,2) + ".CSV";
    permission  = new FileIOPermission(fileName,#io_write);
    permission.assert();
    commaIo = new CommaIo(fileName,#io_write);
    if(!commaIo)
    {
        warning("Please close your csv file and try again. Thanks!");
        return;
    }
    if(commaIo.status() == IO_Status::Ok)
        CommaIo.outFieldDelimiter(",");
    else
        return;
    start = timeNow();
    records = dictionary.tableCnt();
    sysProgress = SysOperationProgress::newGeneral(#AviUpdate,"Waitting ... write CSV file",records);
    CommaIo.writeExp(["Id","Table Id","Table Name","Table Label","Occenabled"]);
    TreeNode = TreeNode.AOTfirstChild();
    while (TreeNode)
    {
        i++;
        tableName = findProperty(TreeNode.AOTgetProperties(), #PropertyName); //table - > Name
        sysProgress.incCount(1);
        sysProgress.setText(strfmt("completed %1 [%2 / %3]: %4",i/ records * 100, i,records, tableName));
        occenabledProperty = findProperty(TreeNode.AOTgetProperties(),"Occenabled");
        if(occenabledProperty == "No")
        {
            m++;
            CommaIo.writeExp([m,"",tableName,"",occenabledProperty]);
        }
        TreeNode = TreeNode.AOTnextSibling();
        sysProgress.update(true);
    }
    if(m)
    {
        if (winAPI::fileExists(fileName))
        {
            winAPI::shellExecute(fileName);
        }
    }
    CodeAccessPermission::revertAssert();
    info(strfmt("It takes time %1",global::time2StrHMS(timenow() - start)));
    info(strfmt("completed %1 records",m));
}

没有评论:

发表评论