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); } }
void SVResString::loadConditionStrings(MAPNODE &objNode) { string szOr(""), szAnd(""), szSet(""), szCondition(""); string szConditionIsNull(""), szRelationErr(""), szMatchingErr(""), szTypeError(""); FindNodeValue(objNode, "IDS_Or", szOr); // 或 FindNodeValue(objNode, "IDS_And", szAnd); // 与 FindNodeValue(objNode, "IDS_Condition", szSet); // 条件 FindNodeValue(objNode, "IDS_Relation", szCondition); // FindNodeValue(objNode, "IDS_Alert_Condition_NULL", szConditionIsNull); FindNodeValue(objNode, "IDS_Alert_Condition_Relation_Error", szRelationErr); FindNodeValue(objNode, "IDS_Alert_Condition_Return_Param_Error", szMatchingErr); FindNodeValue(objNode, "IDS_Alert_Condition_Param_Error", szTypeError); m_lsResource["IDS_Or"] = szOr; m_lsResource["IDS_And"] = szAnd; m_lsResource["IDS_Condition"] = szSet; m_lsResource["IDS_Relation"] = szCondition; m_lsResource["IDS_Alert_Condition_NULL"] = szConditionIsNull; m_lsResource["IDS_Alert_Condition_Relation_Error"] = szRelationErr; m_lsResource["IDS_Alert_Condition_Return_Param_Error"] = szMatchingErr; m_lsResource["IDS_Alert_Condition_Param_Error"] = szTypeError; }
///////////////////////////////////////////////////////////////////////////////////////////////////////////// // 设置条件 ///////////////////////////////////////////////////////////////////////////////////////////////////////////// void SVConditionParam::SetCondition(MAPNODE &alertnode) { string szRelationCount (""); // 条件文本置空 if(m_pConditionArea) m_pConditionArea->setText(""); // 设置帮助文本 if(m_pHelpText) m_pHelpText->setText(m_szHelp); // 设置错误提示信息 if(m_pErrText) m_pErrText->setText(m_szTip); // 得到条件 FindNodeValue(alertnode, svConditionCount, szRelationCount); char szKey [16] = {0}; string szCondition (""), szReturn (""), szParamValue ("") , szRelation (""); int nCount = 0; // 展示条件 if(!szRelationCount.empty()) { nCount = atoi(szRelationCount.c_str()); for(int i = 1; i <= nCount; i++) { szRelation = ""; sprintf(szKey, svRelation, i); FindNodeValue(alertnode, szKey, szRelation); sprintf(szKey, svParamName, i); FindNodeValue(alertnode, szKey, szReturn); sprintf(szKey, svOperate, i); FindNodeValue(alertnode, szKey, szCondition); sprintf(szKey, svParamValue, i); FindNodeValue(alertnode, szKey, szParamValue); getParamLabel(szReturn); if(m_pConditionArea) { string szValue(""); if(!szRelation.empty()) szValue = chLeftBracket + szReturn + " " + szCondition + " " + szParamValue + chRightBracket + " " + szRelation + " "; else szValue = chLeftBracket + szReturn + " " + szCondition + " " + szParamValue + chRightBracket; m_pConditionArea->setText(m_pConditionArea->text() + szValue); } } } }
void SVConditionParam::SetCondition(MAPNODE &alertnode) { string szRelationCount (""); if(m_pConditionArea) m_pConditionArea->setText(""); FindNodeValue(alertnode, "sv_conditioncount", szRelationCount); char szKey [16] = {0}; string szCondition (""), szReturn (""), szParamValue ("") , szRelation (""); int nCount = 0; if(!szRelationCount.empty()) { nCount = atoi(szRelationCount.c_str()); for(int i = 1; i <= nCount; i++) { szRelation = ""; sprintf(szKey, "sv_relation%d", i); FindNodeValue(alertnode, szKey, szRelation); sprintf(szKey, "sv_paramname%d", i); FindNodeValue(alertnode, szKey, szReturn); sprintf(szKey, "sv_operate%d", i); FindNodeValue(alertnode, szKey, szCondition); sprintf(szKey, "sv_paramvalue%d", i); FindNodeValue(alertnode, szKey, szParamValue); getParamLabel(szReturn); if(m_pConditionArea) { string szValue(""); if(!szRelation.empty()) szValue = chLeftBracket + szReturn + " " + szCondition + " " + szParamValue + chRightBracket + " " + szRelation + " "; else szValue = chLeftBracket + szReturn + " " + szCondition + " " + szParamValue + chRightBracket; m_pConditionArea->setText(m_pConditionArea->text() + szValue); } } } }
void SVResString::loadGeneralStrings(MAPNODE &objNode) { string szTranslate(""), szTranslateTip(""), szEdit(""), szDevice(""), szHelp(""), szTest(""), szDepends(""), szSave(""), szSaveTip(""), szAdd(""), szAddTitle(""), szCancel(""), szHostLabel(""), szTestTip(""), szSelAll(""), szMonitorTitle(""), szCancelAdd(""), szGeneralTitle(""), szSaveSelTip(""), szAddMonitorErr(""), szGroup(""), szFriendless(""), szDescriptionHelp(""), szCondition(""), szConditionHelp(""), szDependHelp(""), szErr(""), szNormal(""), szWarn(""), szAffir(""), szPoint(""); FindNodeValue(objNode, "IDS_Translate", szTranslate); // 翻译 FindNodeValue(objNode, "IDS_Translate_Tip", szTranslateTip); // 翻译 FindNodeValue(objNode, "IDS_Device", szDevice); // 设备 FindNodeValue(objNode, "IDS_Help", szHelp); // 帮助 FindNodeValue(objNode, "IDS_Depends_On", szDepends); // 依靠 FindNodeValue(objNode, "IDS_Add", szAdd); // 添加 FindNodeValue(objNode, "IDS_Edit", szEdit); // 编辑 FindNodeValue(objNode, "IDS_Save", szSave); // 保存 FindNodeValue(objNode, "IDS_Test", szTest); // 测试 FindNodeValue(objNode, "IDS_Save_Tip", szSaveTip); // 保存 FindNodeValue(objNode, "IDS_Cancel", szCancel); // 取消 FindNodeValue(objNode, "IDS_Title", szHostLabel); // FindNodeValue(objNode, "IDS_Add_Title", szAddTitle); // 添加 FindNodeValue(objNode, "IDS_Curent_Test_Tip", szTestTip); // 测试此设备 FindNodeValue(objNode, "IDS_All_Select", szSelAll); // 全选 FindNodeValue(objNode, "IDS_Monitor_Title", szMonitorTitle); // 监测器 FindNodeValue(objNode, "IDS_Cancel_Add", szCancelAdd); // 取消添加 FindNodeValue(objNode, "IDS_General_Title", szGeneralTitle); // 基本选项 FindNodeValue(objNode, "IDS_Save_Sel_Monitor_Tip", szSaveSelTip); // 保存所选的监测器 FindNodeValue(objNode, "IDS_Monitor_Point_Lack_Tip",szAddMonitorErr); // 点数不足 FindNodeValue(objNode, "IDS_Group", szGroup); // 组 FindNodeValue(objNode, "IDS_Friendless", szFriendless); // 无依靠 FindNodeValue(objNode, "IDS_Advance_Desc_Help", szDescriptionHelp); // FindNodeValue(objNode, "IDS_Depends_Condition", szCondition); // 依靠条件 FindNodeValue(objNode, "IDS_Depends_Condition_Help",szConditionHelp); // FindNodeValue(objNode, "IDS_Depends_On_Help", szDependHelp); // FindNodeValue(objNode, "IDS_Error", szErr); // 错误 FindNodeValue(objNode, "IDS_Normal", szNormal); // 普通 FindNodeValue(objNode, "IDS_Warnning", szWarn); // 警告 FindNodeValue(objNode, "IDS_Affirm", szAffir); // 警告 FindNodeValue(objNode, "IDS_PointPoor", szPoint); // 警告 m_lsResource["IDS_Translate"] = szTranslate; m_lsResource["IDS_Translate_Tip"] = szTranslateTip; m_lsResource["IDS_Edit"] = szEdit; m_lsResource["IDS_Device"] = szDevice; m_lsResource["IDS_Help"] = szHelp; m_lsResource["IDS_Test"] = szTest; m_lsResource["IDS_Depends_On"] = szDepends; m_lsResource["IDS_Save"] = szSave; m_lsResource["IDS_Save_Tip"] = szSaveTip; m_lsResource["IDS_Add"] = szAdd; m_lsResource["IDS_Cancel"] = szCancel; m_lsResource["IDS_Title"] = szHostLabel; m_lsResource["IDS_Add_Title"] = szAddTitle; m_lsResource["IDS_Curent_Test_Tip"] = szTestTip; m_lsResource["IDS_All_Select"] = szSelAll; m_lsResource["IDS_Monitor_Title"] = szMonitorTitle; m_lsResource["IDS_Cancel_Add"] = szCancelAdd; m_lsResource["IDS_General_Title"] = szGeneralTitle; m_lsResource["IDS_Save_Sel_Monitor_Tip"] = szSaveSelTip; m_lsResource["IDS_Monitor_Point_Lack_Tip"] = szAddMonitorErr; m_lsResource["IDS_Group"] = szGroup; m_lsResource["IDS_Friendless"] = szFriendless; m_lsResource["IDS_Advance_Desc_Help"] = szDescriptionHelp; m_lsResource["IDS_Depends_Condition"] = szCondition; m_lsResource["IDS_Depends_Condition_Help"] = szConditionHelp; m_lsResource["IDS_Depends_On_Help"] = szDependHelp; m_lsResource["IDS_Error"] = szErr; m_lsResource["IDS_Normal"] = szNormal; m_lsResource["IDS_Warnning"] = szWarn; m_lsResource["IDS_Affirm"] = szAffir; m_lsResource["IDS_PointPoor"] = szPoint; }
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 ; }
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 ; }
///////////////////////////////////////////////////////////////////////////////////////////////////////////// // 校验当前填写的条件 ///////////////////////////////////////////////////////////////////////////////////////////////////////////// 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 ; }