示例#1
0
void SVConditionParam::addCondition()
{
    string szParam = m_pParam->text();
    if(szParam.empty())
        return;
    string szReturn = m_pReturnList->currentText();
    string szOperate = m_pOperateList->currentText();
    string szTemp = szReturn;
    if(!checkParamValue(szTemp, szParam))
        return;

    string szCondition ("");
    if(m_pConditionAND)
    {
        if(m_pConditionAND->isChecked())
            szCondition = " and ";
        else 
            szCondition = " or ";
    }

    if(m_pConditionArea)
    {
        string szValue = m_pConditionArea->text();
        if (szValue.empty())
            szValue = chLeftBracket + szReturn + " " + szOperate + " " + szParam + chRightBracket;
        else
            szValue = szValue + szCondition + chLeftBracket + szReturn + " " + szOperate + " " + szParam + chRightBracket;
        m_pConditionArea->setText(szValue);
    }
}
示例#2
0
bool SVConditionParam::checkCondition(MAPNODE &alertnode)
{
    bool bNoError = true;
    list<string> lstCondition;
    list<string> lstParam;
    list<string> lstOperate;

    string szValue = m_pConditionArea->text();

    if(!szValue.empty())
    {
        unsigned int nResult = getCondition(lstCondition, szValue);
        nResult = getParam(lstParam, szValue);

        if(lstCondition.size() != lstParam.size() - 1)
        {
            bNoError = false;
            showErrorMsg(sv_condition_relation_error);
            return bNoError;
        }

        char szCount[4] = {0}, szKey [32] = {0};
        int nCount = static_cast<int>(lstCondition.size());
        int nIndex = 1;
        string szExpression ("");
        if(nCount >= 1)
        {
            while(lstCondition.size())
            {
                string szConValue = *(lstCondition.begin());
                lstCondition.pop_front();

                string szParamCondition = *(lstParam.begin());
                lstParam.pop_front();
                string szCondition (""), szReturn (""), szParamValue ("");
                int nPos = getOperatePostion(szParamCondition, m_lsCondition, szCondition);

                if(nPos > 0 && !szCondition.empty())
                {
                    szReturn = szParamCondition.substr(0, nPos - 1);
                    szParamValue = szParamCondition.substr(nPos + szCondition.length() + 1, szParamCondition.length() - 
                        (nPos + szCondition.length() + 1));
                    if(! checkParamValue(szReturn, szParamValue))
                    {
                        bNoError = false;
                        break;
                    }
                }
                else
                {
                    showErrorMsg(sv_condition_relation_error);
                    bNoError = false;
                }
                nIndex ++;
            }
        }
        if(bNoError)
        {
            string szParamCondition = *(lstParam.begin());
            lstParam.pop_front();
            string szCondition (""), szReturn (""), szParamValue ("");
            int nPos = getOperatePostion(szParamCondition, m_lsCondition, szCondition);

            if(nPos > 0 && !szCondition.empty())
            {
                szReturn = szParamCondition.substr(0, nPos - 1);
                szParamValue = szParamCondition.substr(nPos + szCondition.length() + 1, szParamCondition.length() - 
                    (nPos + szCondition.length() + 1));
                bNoError = checkParamValue(szReturn, szParamValue);
            }
            else
            {
                showErrorMsg(sv_condition_relation_error);
                bNoError = false;
            } 
        }
    }
    else
    {
        showErrorMsg(sv_condition_is_null);
        bNoError = false;
    }
    if(bNoError)
    {
        showHelp(m_bShowHelp);
    }
    return bNoError ;
}
示例#3
0
bool SVConditionParam::SaveCondition(MAPNODE &alertnode)
{
    bool bNoError = true;
    list<string> lstCondition;
    list<string> lstParam;
    list<string> lstOperate;

    string szValue = m_pConditionArea->text();

    if(!szValue.empty())
    {
        unsigned int nResult = getCondition(lstCondition, szValue);
        nResult = getParam(lstParam, szValue);

        if(lstCondition.size() != lstParam.size() - 1)
        {
            bNoError = false;
            showErrorMsg(sv_condition_relation_error);
            return bNoError;
        }

        char szCount[4] = {0}, szKey [32] = {0};
        int nCount = static_cast<int>(lstCondition.size());
        int nIndex = 1;
        string szExpression ("");
        if(nCount >= 1)
        {
            while(lstCondition.size())
            {
                string szConValue = *(lstCondition.begin());
                lstCondition.pop_front();

                string szParamCondition = *(lstParam.begin());
                lstParam.pop_front();
                string szCondition (""), szReturn (""), szParamValue ("");
                int nPos = getOperatePostion(szParamCondition, m_lsCondition, szCondition);

                if(nPos > 0)
                {
                    szReturn = szParamCondition.substr(0, nPos - 1);
                    szParamValue = szParamCondition.substr(nPos + szCondition.length() + 1, szParamCondition.length() - 
                        (nPos + szCondition.length() + 1));
                }

                if(! checkParamValue(szReturn, szParamValue))
                {
                    bNoError = false;
                    break;
                }
                sprintf(szKey, "%d", nIndex);
                szExpression = szExpression + szKey + "#" + szConValue + "#";
                sprintf(szKey, "sv_relation%d", nIndex);
                if((bNoError = AddNodeAttrib(alertnode, szKey, szConValue)))
                {
                    sprintf(szKey, "sv_paramname%d", nIndex);
                    if((bNoError = AddNodeAttrib(alertnode, szKey, szReturn)))
                    {
                        sprintf(szKey, "sv_operate%d", nIndex);
                        if((bNoError = AddNodeAttrib(alertnode, szKey, szCondition)))
                        {
                            sprintf(szKey, "sv_paramvalue%d", nIndex);
                            bNoError = AddNodeAttrib(alertnode, szKey, szParamValue);
                        }
                    }
                }
                if(!bNoError)
                    break;
                nIndex ++;
            }
        }
        if(bNoError)
        {
            string szParamCondition = *(lstParam.begin());
            lstParam.pop_front();
            string szCondition (""), szReturn (""), szParamValue ("");
            int nPos = getOperatePostion(szParamCondition, m_lsCondition, szCondition);

            if(nPos > 0)
            {
                szReturn = szParamCondition.substr(0, nPos - 1);
                szParamValue = szParamCondition.substr(nPos + szCondition.length() + 1, szParamCondition.length() - 
                    (nPos + szCondition.length() + 1));
            }

            if(!checkParamValue(szReturn, szParamValue))
            {
                bNoError = false;
            }
            if(bNoError)
            {
                sprintf(szKey, "%d", nIndex);
                szExpression = szExpression + szKey;
                sprintf(szKey, "sv_paramname%d", nIndex);
                if((bNoError = AddNodeAttrib(alertnode, szKey, szReturn)))
                {
                    sprintf(szKey, "sv_operate%d", nIndex);
                    if((bNoError = AddNodeAttrib(alertnode, szKey, szCondition)))
                    {
                        sprintf(szKey, "sv_paramvalue%d", nIndex);
                        if(bNoError = AddNodeAttrib(alertnode, szKey, szParamValue))
                        {
                            if(bNoError = AddNodeAttrib(alertnode, "sv_expression", szExpression))
                            {
                                sprintf(szCount, "%d", nCount + 1);
                                bNoError = AddNodeAttrib(alertnode, "sv_conditioncount", szCount);
                            }
                        }
                    }
                }
            }     
        }
    }
    else
    {
        showErrorMsg(sv_condition_is_null);
        bNoError = false;
    }
    return bNoError ;
}
示例#4
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 校验当前填写的条件
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool SVConditionParam::checkCondition(MAPNODE &alertnode)
{
    bool bNoError = true;
    list<string> lstCondition;
    list<string> lstParam;
    list<string> lstOperate;

    if(m_pErrText)
        m_pErrText->hide();

    string szValue = m_pConditionArea->text();

    if(!szValue.empty())
    {   int condition,param;
        //unsigned int nResult = getCondition(lstCondition, szValue);
        // nResult = getParam(lstParam, szValue);
        condition=getCondition(lstCondition, szValue);
        param= getParam(lstParam, szValue);
        // if(lstCondition.size() != lstParam.size() - 1)
        if(condition!=param-1)
        {
            bNoError = false;
            showErrorMsg(sv_condition_relation_error);
            OutputDebugString("!!!!!!!!!!!!!!!!!!!!!!!!!!lstCondition.size   lstParam.size222222222222222222222\n");
            char t[200];
            OutputDebugString(itoa(condition,t,10)) ;
            OutputDebugString("\n");
            OutputDebugString(itoa(param,t,10));
            OutputDebugString("\n");
            return bNoError;
        }

        char szCount[4] = {0}, szKey [32] = {0};
        int nCount = static_cast<int>(lstCondition.size());
        int nIndex = 1;
        string szExpression ("");
        if(nCount >= 1)
        {
            while(lstCondition.size())
            {
                string szConValue = *(lstCondition.begin());
                lstCondition.pop_front();

                string szParamCondition = *(lstParam.begin());
                lstParam.pop_front();
                string szCondition (""), szReturn (""), szParamValue ("");
                int nPos = getOperatePostion(szParamCondition, m_lsCondition, szCondition);

                if(nPos > 0 && !szCondition.empty())
                {
                    szReturn = szParamCondition.substr(0, nPos - 1);
                    szParamValue = szParamCondition.substr(nPos + szCondition.length() + 1,
                                                           szParamCondition.length() - (nPos + szCondition.length() + 1));
                    if(! checkParamValue(szReturn, szParamValue))
                    {
                        bNoError = false;
                        break;
                    }
                }
                else
                {
                    showErrorMsg(sv_condition_relation_error);
                    bNoError = false;
                    OutputDebugString("22222222222222222222222222222222222nPosszCondition empty222222222222222222222222222222");
                }
                nIndex ++;
            }
        }
        if(bNoError)
        {
            string szParamCondition = *(lstParam.begin());
            lstParam.pop_front();
            string szCondition (""), szReturn (""), szParamValue ("");
            int nPos = getOperatePostion(szParamCondition, m_lsCondition, szCondition);

            if(nPos > 0 && !szCondition.empty())
            {
                szReturn = szParamCondition.substr(0, nPos - 1);
                szParamValue = szParamCondition.substr(nPos + szCondition.length() + 1,
                                                       szParamCondition.length() - (nPos + szCondition.length() + 1));
                bNoError = checkParamValue(szReturn, szParamValue);
            }
            else
            {
                showErrorMsg(sv_condition_relation_error);
                OutputDebugString("2222222222222222222222222222222222222inifbNoError22222222222222222222222");

                bNoError = false;
            }
        }
    }
    else
    {
        showErrorMsg(sv_condition_is_null);
        bNoError = false;
    }
    if(bNoError)
    {
        showHelp(m_bShowHelp);
    }
    return bNoError ;
}