void CCheckBoxTreeView::AddDeviceTreeNode(std::string szDeviceID, WTreeNode* parentNode) { WTreeNode* pNode; OBJECT objDevice = GetEntity(szDeviceID); if(objDevice != INVALID_VALUE) { MAPNODE node = GetEntityMainAttribNode(objDevice); if(node != INVALID_VALUE) { string szName = ""; FindNodeValue(node, "sv_name", szName); pNode=makeTreeFile(szName, szDeviceID, Tree_DEVICE, parentNode, false, true, "/Images/cbb-4server.gif", "/Images/cbb-4server.gif"); if(bDevice ==true) //树的最后一层是设备 { pNode->expandIcon_->hide(); } else { if(pNode!=NULL) connect(pNode,SIGNAL(addmonitor()),this, SLOT(ListMonitorInDevice())); } // if(szDeviceID=="1.11") pTestNode= pNode; } CloseEntity(objDevice); } }
void CSVSortList::enumDevice(string &szGroupIndex) { list<string> lsDeviceID; list<string>::iterator lsItem; OBJECT objGroup; base_param device; if(IsSVSEID(szGroupIndex)) { objGroup = GetSVSE(szGroupIndex, m_szIDCUser, m_szIDCPwd); if(objGroup != INVALID_VALUE) { GetSubEntitysIDBySE(objGroup, lsDeviceID); CloseSVSE(objGroup); } } else { objGroup = GetGroup(szGroupIndex, m_szIDCUser, m_szIDCPwd); if(objGroup != INVALID_VALUE) { GetSubEntitysIDByGroup(objGroup, lsDeviceID); CloseGroup(objGroup); } } int nIndex = 0; for(lsItem = lsDeviceID.begin(); lsItem != lsDeviceID.end(); lsItem ++) { string szID = (*lsItem).c_str(); bool bHasRight = true; if(m_pSVUser) bHasRight = m_pSVUser->haveGroupRight(szID, Tree_DEVICE); if(bHasRight) { OBJECT objDevice = GetEntity(szID, m_szIDCUser, m_szIDCPwd); if(objDevice != INVALID_VALUE) { MAPNODE node = GetEntityMainAttribNode(objDevice); if(node != INVALID_VALUE) { string szName (""), szIndex (""); FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szIndex); if(szIndex.empty()) nIndex = FindIndexByID(szID); else nIndex = atoi(szIndex.c_str()); device.szIndex = szID; device.szName = szName; m_sortList[nIndex] = device; } CloseEntity(objDevice); } } } }
//测试用的函数 std::string CCheckBoxTreeView::MyAddNode(std::string name, std::string id, std::string type, std::string index) { std::string strTmp = ""; OBJECT root; if(type == "1") root = CreateGroup(); else root = CreateEntity(); if (root != INVALID_VALUE) { MAPNODE attr; if(type == "1") attr = GetGroupMainAttribNode(root); else attr = GetEntityMainAttribNode(root); bool bState = false; if(attr != INVALID_VALUE) { if(AddNodeAttrib(attr, "sv_id", id)) { if(AddNodeAttrib(attr, "sv_type", type)) { bState = AddNodeAttrib(attr, "sv_name", name); } } } if(bState) { if(type == "1") strTmp = AddNewGroup(root, index); else strTmp = AddNewEntity(root, index); } if(type == "1") CloseGroup(root); else CloseEntity(root); } return strTmp; }
void CSVSortList::enumMonitor(string &szDeviceIndex) { OBJECT objDevice = GetEntity(szDeviceIndex, m_szIDCUser, m_szIDCPwd); if(objDevice != INVALID_VALUE) { list<string> lsMonitorID; list<string>::iterator lstItem; if (GetSubMonitorsIDByEntity(objDevice, lsMonitorID)) { string szDeviceName (""); MAPNODE mainnode = GetEntityMainAttribNode(objDevice); if(mainnode != INVALID_VALUE) FindNodeValue(mainnode, "sv_name", szDeviceName); int nIndex = 0; base_param monitor; for(lstItem = lsMonitorID.begin(); lstItem != lsMonitorID.end(); lstItem ++) { string szMonitorId = (*lstItem).c_str(); OBJECT objMonitor = GetMonitor(szMonitorId, m_szIDCUser, m_szIDCPwd); if(objMonitor != INVALID_VALUE) { MAPNODE node = GetMonitorMainAttribNode(objMonitor); if(node != INVALID_VALUE) { string szName (""), szIndex (""); FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szIndex); if(szIndex.empty()) nIndex = FindIndexByID(szMonitorId); else nIndex = atoi(szIndex.c_str()); monitor.szIndex = szMonitorId; monitor.szName = szDeviceName + ":" + szName; m_sortList[nIndex] = monitor; } CloseMonitor(objMonitor); } } } CloseEntity(objDevice); } }
//根据monitorid获取父设备的名称 string GetDeviceTitle(string strId) { string strTmp = ""; string strParentId = FindParentID(strId); //设备名称 OBJECT objDevice = GetEntity(strParentId); if(objDevice != INVALID_VALUE) { MAPNODE devicenode = GetEntityMainAttribNode(objDevice); if(devicenode != INVALID_VALUE) { FindNodeValue(devicenode, "sv_name", strTmp); } CloseEntity(objDevice); } return strTmp; }
void CSVSortList::saveDevice(map<int, string, less<int> > &lsDis) { map<int, string, less<int> >::iterator lsDisItem; for(lsDisItem = lsDis.begin(); lsDisItem != lsDis.end(); lsDisItem ++) { string szDeviceID = lsDisItem->second; OBJECT objDevice = GetEntity(szDeviceID, m_szIDCUser, m_szIDCPwd); if(objDevice != INVALID_VALUE) { char szIndex[8] = {0}; sprintf(szIndex, "%d", lsDisItem->first); MAPNODE mainnode = GetEntityMainAttribNode(objDevice); if(mainnode != INVALID_VALUE) AddNodeAttrib(mainnode, "sv_index", szIndex); SubmitEntity(objDevice); CloseEntity(objDevice); } } }
// EntityEx提交至ECC bool CNNM2ECC::SubmitEntityExToEcc(EntityEx* pEx) { if(pEx==NULL) return false; if(m_nnmGroupid.empty()) InitNNMGroup(); OBJECT objgroup= Cache_GetGroup( m_nnmGroupid.getword() ); if(objgroup==INVALID_VALUE) { InitNNMGroup(); objgroup= Cache_GetGroup( m_nnmGroupid.getword() ); if(objgroup==INVALID_VALUE) { InitNNMGroup(); myWriteLog->WriteLog( "InitNNMGroup Error!" ); printf("InitNNMGroup Error!\n"); return false; } } Entity* pEn = NULL; //新Entity标志 bool bNewEn = false; //是否已转化过 //获取 entity, 或者创建新 entity string eccEntityID= pEx->GetEccEntityID().getword(); OBJECT objentity= Cache_GetEntity(eccEntityID); if(eccEntityID.empty() || objentity==INVALID_VALUE ) { objentity= CreateEntity(); bNewEn = true; } if(objentity==INVALID_VALUE) return false; pEn= reinterpret_cast<Entity *>(objentity); if(pEn==NULL) return false; #ifdef _DEBUG //pEx->DisplayAllData(); #endif //如果设备名为空,那么直接返回,不发送到ECC中去 if (pEx->GetProperty()["_MachineName"].empty()) return true; (pEn->GetProperty())["sv_devicetype"] = pEx->GetType(); //设备类型 (pEn->GetProperty())["_MachineName"] = pEx->GetProperty()["_MachineName"]; //IP (pEn->GetProperty())["_sysObjectID"] = pEx->GetProperty()["_sysObjectID"]; //sysObjectID (pEn->GetProperty())["_Port"] = pEx->GetProperty()["_Port"]; //SNMP Port (pEn->GetProperty())["ifNumber"] = pEx->GetProperty()["ifNumber"]; //ifNumber 接口数量 //获得组号 word groupid = ""; std::string stype = pEx->GetProperty()["type"].getword(); int index= atoi( stype.c_str() ); if( index==0 && stype.compare("0")!=0 ) stype.clear(); if( stype.empty() || index<0 || index>6 ) groupid = m_nnmGroupid; else groupid = m_nnmSubGroupid[index]; //共同体 // Luowan 2007.5.23 std::string strcomm = "public"; try { strcomm = pEx->GetProperty()["_Community"].getword(); } catch(...) { } if(strcomm.length()<=0) strcomm = "public"; char outbuf[512] = {0}; if(!strcomm.empty()) { Des des; des.Encrypt(strcomm.c_str(),outbuf); strcomm = outbuf; } (pEn->GetProperty())["_Community"] = strcomm.c_str(); char pBuf[260]; sprintf(pBuf, "community:%s",strcomm.c_str()); myWriteLog->WriteLog(pBuf); //(pEn->GetProperty())["_Community"] = pEx->GetProperty()["_Community"]; if(bNewEn) { myWriteLog->WriteLog("New Entity"); svutil::buffer buftmp; buftmp.resetsize(2048); buftmp.zerobuf(); //sprintf(buftmp.getbuffer(),"%s %s",pEx->GetProperty()["manufact"].getword(),pEx->GetProperty()["model"].getword()); //std::string svname = buftmp.getbuffer(); string svname = (pEx->GetProperty()["name"].empty()) ? pEx->GetProperty()["ip"] : pEx->GetProperty()["name"]; if(svname.length()<2) { svname = pEx->GetProperty()["ip"]; } if(svname.empty()) svname = "Hub或其他"; //设备中文名 (pEn->GetProperty())["sv_name"] = svname; myWriteLog->WriteLog("End of processing New entity."); } else { myWriteLog->WriteLog("Entity that already exists."); std::string svname1 = pEx->GetProperty()["nameCN"]; if(svname1.length()<2) { svname1 = pEx->GetProperty()["ip"]; } if(svname1.empty()) svname1 = "Hub或其他"; (pEn->GetProperty())["sv_name"] = svname1; } //保存数据,submit 等 ,以上部分为设置 entity 数据 word entityid; if(bNewEn) { entityid= AddNewEntity( objentity,groupid.getword() ); pEn->PutID(entityid); } else entityid = pEn->GetID(); cout<<"entityid: \""<<entityid.getword()<<"\""<<endl; bool ret = SubmitEntity(objentity); if( ret ) { myWriteLog->WriteLog("SubmitEntity 成功。"); pEx->PutEccEntityID(entityid); } else myWriteLog->WriteLog("SubmitEntity 失败。"); // Luowan 2007.6.26 注释掉了以下5行 if(bNewEn) { myWriteLog->WriteLog("this->AddMonitor(pEn)"); AddMonitor(pEn); } if(bNewEn) CloseEntity(objentity); myWriteLog->WriteLog("End of SubmitEntityExToEcc()"); return ret; }
bool CSVWholeview::enumMonitors(const string &szDeviceID, const string &szDeviceName, WTableCell *pTableCell) { map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; OBJECT objDevice = GetEntity(szDeviceID, m_szIDCUser, m_szIDCPwd); if(objDevice != INVALID_VALUE) { list<string> lsMonitorID; list<string>::iterator lstItem; if (GetSubMonitorsIDByEntity(objDevice, lsMonitorID)) { base_param monitor; string szMonitorId(""); OBJECT objMonitor = INVALID_VALUE; MAPNODE node = INVALID_VALUE; string szName(""), szIndex(""); int nIndex = 0; for(lstItem = lsMonitorID.begin(); lstItem != lsMonitorID.end(); lstItem ++) { szMonitorId = (*lstItem).c_str(); objMonitor = GetMonitor(szMonitorId, m_szIDCUser, m_szIDCPwd); if(objMonitor != INVALID_VALUE) { node = GetMonitorMainAttribNode(objMonitor); if(node != INVALID_VALUE) { FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szIndex); if(szIndex.empty()) nIndex = FindIndexByID(szMonitorId); else nIndex = atoi(szIndex.c_str()); monitor.szIndex = szMonitorId; monitor.szName = szName; lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { nIndex ++;//= nMax; lsItem = sortList.find(nIndex); } sortList[nIndex] = monitor; } CloseMonitor(objMonitor); } } } CloseEntity(objDevice); } string szShowText(""), szContent(""); int nState = dyn_normal; bool bShowDevice = false; for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) { // get monitor's current state nState = getMonitorState(lsItem->second.szIndex, szShowText); WImage *pMonitor = NULL; if(m_nShowType == -1 || m_nShowType == nState || (m_nShowType == dyn_normal && nState == dyn_no_data) || (m_nShowType == dyn_error && nState == dyn_bad)) { bShowDevice = true; pMonitor = new WImage("/Images/state_green.gif", pTableCell); } if(pMonitor) { // change show image by state switch(nState) { case dyn_no_data: pMonitor->setImageRef("/Images/state_grey.gif"); break; case dyn_normal: pMonitor->setImageRef("/Images/state_green.gif"); break; case dyn_warnning: pMonitor->setImageRef("/Images/state_yellow.gif"); break; case dyn_error: case dyn_bad: pMonitor->setImageRef("/Images/state_red.gif"); break; case dyn_disable: pMonitor->setImageRef("/Images/state_stop.gif"); break; } // monitor's style && onclick event szContent = "style='cursor:pointer;' onclick = 'window.open(\"SimpleReport.exe?id=" + lsItem->second.szIndex + "\");'"; sprintf(pMonitor->contextmenu_, szContent.c_str()); pMonitor->setToolTip(szDeviceName + ":" + lsItem->second.szName + "\r\n" + szShowText); } } return bShowDevice; }
bool CSVWholeview::enumGroups(const string &szGroupID, WTable *pTable) { bool bShowGroup = false; bool gShowGroup = true;//jansion bool mShowGroup = true; //jansion pTable->setStyleClass("widthauto"); if(!szGroupID.empty()) { OBJECT objGroup = GetGroup(szGroupID); if(objGroup != INVALID_VALUE) { //PrintDebugString("In ------------------------------------\n"); string szIndex(""), szName(""), szShowIndex(""), szContext(""); string szShow(""), szHide(""), szSubTable(""); string szShowText(""), szHideText(""); bool bHasRight = true; int nIndex = 0, nRow = 0; MAPNODE node = INVALID_VALUE; list<string> lsGroupID; list<string> lsDeviceID; list<string>::iterator lstItem; //list<string>::iterator bcompItem; if(GetSubGroupsIDByGroup(objGroup, lsGroupID)) { map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; map<int, base_param, less<int> >::iterator bcompItem; //bool gShow = false; base_param group; OBJECT objSubGroup = INVALID_VALUE; for(lstItem = lsGroupID.begin(); lstItem != lsGroupID.end(); lstItem ++) { //PrintDebugString("In --------------- for ---------------------\n"); szIndex =(*lstItem); bHasRight = true; if(m_pSVUser) bHasRight = m_pSVUser->haveGroupRight(szIndex, Tree_GROUP); if(bHasRight) { objSubGroup = GetGroup(szIndex, m_szIDCUser, m_szIDCPwd); if(objGroup != INVALID_VALUE) { node = GetGroupMainAttribNode(objSubGroup); if(node != INVALID_VALUE) { FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szShowIndex); if(szShowIndex.empty()) nIndex = FindIndexByID(szIndex); else nIndex = atoi(szShowIndex.c_str()); group.szIndex = szIndex; group.szName = szName; lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { nIndex ++; lsItem = sortList.find(nIndex); } sortList[nIndex] = group; } else { gShowGroup = false; } CloseGroup(objSubGroup); } } else { gShowGroup =false; } } //if (lsGroupID.empty()) // PrintDebugString("In group is ====== false\n"); for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) { //PrintDebugString("In emnuGroup " + lsItem->second.szName + "\n"); //bool gShow = false; nRow = pTable->numRows(); //WImage *pShow = new WImage("../Images/foldopen.gif", pTable->elementAt(nRow, 0)); //WImage *pHide = new WImage("../Images/foldclose.gif", pTable->elementAt(nRow, 0)); //if(!enumGroups(lsItem->second.szIndex, pSub)) //{ WImage *pShow = new WImage("/Images/cb1-unwrap.gif", pTable->elementAt(nRow, 0)); WImage *pHide = new WImage("/Images/cb1-fold.gif", pTable->elementAt(nRow, 0)); //} new WText(" ",pTable->elementAt(nRow, 0)); //new WImage("../Images/group.gif", pTable->elementAt(nRow, 1)); new WImage("/Images/cbb-3group.gif", pTable->elementAt(nRow, 1)); new WText(" ",pTable->elementAt(nRow, 1)); WText *pName = new WText(lsItem->second.szName, pTable->elementAt(nRow, 2)); if(pName) { szContext = "onclick='parent.document.frames(\"left\").location.replace(\"/fcgi-bin/menu.exe?cmd=treeview.exe?groupid=" + lsItem->second.szIndex + "\");' style='color:#669;cursor:pointer;' onmouseover='this.style.textDecoration=\"underline\"'" + "onmouseout='this.style.textDecoration=\"none\"'"; sprintf(pName->contextmenu_, szContext.c_str()); } WTable * pSub = new WTable(pTable->elementAt(nRow + 1, 2)); if(pSub) { if(pShow && pHide) { szShow = pHide->formName(); szHide = pShow->formName(); szSubTable = pSub->formName(); szShowText = "onclick='showsubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='display:none;cursor:pointer'"; szHideText = "onclick='hidesubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='cursor:pointer'"; sprintf(pShow->contextmenu_, szShowText.c_str()); sprintf(pHide->contextmenu_, szHideText.c_str()); } if(!enumGroups(lsItem->second.szIndex, pSub)) { //gShow = true; //pTable->deleteRow(nRow); pShow->hide(); pHide->hide(); } else { //bShowGroup = true; //pShow->hide(); //pHide->hide(); } } } if (sortList.empty()) gShowGroup = false; } else { gShowGroup = false; } if(GetSubEntitysIDByGroup(objGroup, lsDeviceID)) { map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; base_param device; OBJECT objDevice = INVALID_VALUE; for(lstItem = lsDeviceID.begin(); lstItem != lsDeviceID.end(); lstItem ++) { szIndex =(*lstItem); bHasRight = true; if(m_pSVUser) bHasRight = m_pSVUser->haveGroupRight(szIndex, Tree_DEVICE); if(bHasRight) { objDevice = GetEntity(szIndex, m_szIDCUser, m_szIDCPwd); if(objDevice != INVALID_VALUE) { node = GetEntityMainAttribNode(objDevice); if(node != INVALID_VALUE) { FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szShowIndex); if(szShowIndex.empty()) nIndex = FindIndexByID(szIndex); else nIndex = atoi(szShowIndex.c_str()); device.szIndex = szIndex; device.szName = szName; lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { nIndex ++; lsItem = sortList.find(nIndex); } sortList[nIndex] = device; } else { mShowGroup = false; } CloseEntity(objDevice); } } } for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) { //PrintDebugString("In emnuGroup " + lsItem->second.szName + "------------------------\n"); nRow = pTable->numRows(); //new WImage("../Images/device.gif", pTable->elementAt(nRow, 1)); new WImage("/Images/cbb-4server.gif", pTable->elementAt(nRow, 1)); new WText(" ",pTable->elementAt(nRow, 1)); WText *pName = new WText(lsItem->second.szName, pTable->elementAt(nRow, 2)); if(pName) { szContext = "onclick='parent.document.frames(\"left\").location.replace(\"/fcgi-bin/menu.exe?cmd=treeview.exe?deviceid=" + lsItem->second.szIndex + "\");' style='color:#669;cursor:pointer;' onmouseover='this.style.textDecoration=\"underline\"'" + "onmouseout='this.style.textDecoration=\"none\"'"; sprintf(pName->contextmenu_, szContext.c_str()); } if(!enumMonitors(lsItem->second.szIndex, lsItem->second.szName, pTable->elementAt(nRow, 2))) { bShowGroup = false; //bShowGroup = true; //pTable->deleteRow(nRow); } else bShowGroup = true; } //84200891 if (sortList.empty()) { mShowGroup = false; } } else { mShowGroup = false; } CloseGroup(objGroup); } else { mShowGroup = false; gShowGroup = false; } } else { mShowGroup = false; gShowGroup = false; } bool bbShowGroup; bbShowGroup = gShowGroup || mShowGroup; return bbShowGroup; }
void CSVWholeview::enumSVSE() { if(!m_pContent) return; PAIRLIST selist; string szRootname(""); int nRow = 0; WTable *pTable = m_pContent; if(GetIniFileInt("solover","solover",1,"general.ini") == 1) { sv_pair svpair; svpair.name = "1"; OBJECT objSE = GetSVSE("1");//, m_szIDCUser, m_szIDCPwd); if(objSE != INVALID_VALUE) { svpair.value = GetSVSELabel(objSE); CloseSVSE(objSE); } selist.push_back(svpair); } else { GetAllSVSEInfo(selist); szRootname = GetIniFileString("segroup","name","","general.ini"); if(szRootname.empty()) szRootname = "SiteView ECC 7.0"; nRow = m_pContent->numRows(); //WImage *pShow = new WImage("../Images/foldopen.gif", m_pContent->elementAt(nRow, 0)); //WImage *pHide = new WImage("../Images/foldclose.gif", m_pContent->elementAt(nRow, 0)); WImage *pShow = new WImage("/Images/cb1-unwrap.gif", m_pContent->elementAt(nRow, 0)); WImage *pHide = new WImage("/Images/cb1-fold.gif", m_pContent->elementAt(nRow, 0)); new WText(" ",m_pContent->elementAt(nRow, 0)); //new WImage("../Images/home.gif", m_pContent->elementAt(nRow, 1)); new WImage("/Images/cbb-2main.gif", m_pContent->elementAt(nRow, 1)); new WText(" ",m_pContent->elementAt(nRow, 1)); WText *pName = new WText(szRootname, m_pContent->elementAt(nRow, 2)); if(pName) { sprintf(pName->contextmenu_, "style='color:#669;cursor:pointer;' onmouseover='" \ "this.style.textDecoration=\"underline\"' " \ "onmouseout='this.style.textDecoration=\"none\"'"); } pTable = new WTable(m_pContent->elementAt(nRow + 1, 2)); pTable->setStyleClass("widthauto"); if(!pTable) return; else { if(pShow && pHide) { string szShow = "", szHide = "", szSubTable = ""; szShow = pHide->formName(); szHide = pShow->formName(); szSubTable = pTable->formName(); string szShowText = "onclick='showsubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='display:none;cursor:pointer'"; string szHideText = "onclick='hidesubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='cursor:pointer'"; sprintf(pShow->contextmenu_, szShowText.c_str()); sprintf(pHide->contextmenu_, szHideText.c_str()); } } } PAIRLIST::iterator iSe; bool bHasRight = true; int nChildCount = 0, nIndex = 0; OBJECT objSE = INVALID_VALUE; OBJECT objGroup = INVALID_VALUE; MAPNODE node = INVALID_VALUE; string szSEID(""), szSubGroupID(""), szEntityID(""); string szName(""), szIndex(""); string szContext(""), szShow(""), szHide(""), szSubTable(""); string szShowText(""), szHideText(""); list<string> lsGroupID; list<string> lsDeviceID; list<string>::iterator lstItem; for(iSe= selist.begin(); iSe!=selist.end(); iSe++) { szSEID = (*iSe).name; bHasRight = true; if(m_pSVUser) bHasRight = m_pSVUser->haveGroupRight(szSEID, Tree_SE); if(bHasRight) { nRow = pTable->numRows(); //WImage *pShow = new WImage("../Images/foldopen.gif", pTable->elementAt(nRow, 0)); //WImage *pHide = new WImage("../Images/foldclose.gif", pTable->elementAt(nRow, 0)); WImage *pShow = new WImage("/Images/cb1-unwrap.gif", pTable->elementAt(nRow, 0)); WImage *pHide = new WImage("/Images/cb1-fold.gif", pTable->elementAt(nRow, 0)); new WText(" ",pTable->elementAt(nRow, 0)); new WImage("/Images/cbb-2main.gif", pTable->elementAt(nRow, 1)); new WText(" ",pTable->elementAt(nRow, 1)); WText *pName = new WText((*iSe).value, pTable->elementAt(nRow, 2)); if(pName) { szContext = "onclick='parent.document.frames(\"left\").location.replace(\"/fcgi-bin/menu.exe?cmd=treeview.exe?svseid=" + szSEID + "\");' style='color:#669;cursor:pointer;' onmouseover='this.style.textDecoration=\"underline\"'" + "onmouseout='this.style.textDecoration=\"none\"'"; sprintf(pName->contextmenu_, szContext.c_str()); } WTable *pSubTable = new WTable(pTable->elementAt(nRow + 1, 2)); pSubTable->setStyleClass("widthauto"); if(!pSubTable) return; else { if(pShow && pHide) { szShow = pHide->formName(); szHide = pShow->formName(); szSubTable = pSubTable->formName(); szShowText = "onclick='showsubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='display:none;cursor:pointer'"; szHideText = "onclick='hidesubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='cursor:pointer'"; sprintf(pShow->contextmenu_, szShowText.c_str()); sprintf(pHide->contextmenu_, szHideText.c_str()); } } objSE = GetSVSE(szSEID); if(objSE != INVALID_VALUE) { lsGroupID.clear(); if(GetSubGroupsIDBySE(objSE, lsGroupID)) { map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; map<int, base_param, less<int> >::iterator compItem; base_param group; for(lstItem = lsGroupID.begin(); lstItem != lsGroupID.end(); lstItem ++) { szSubGroupID =(*lstItem); bHasRight = true; if(m_pSVUser) bHasRight = m_pSVUser->haveGroupRight(szSubGroupID, Tree_GROUP); if(bHasRight) { objGroup = GetGroup(szSubGroupID, m_szIDCUser, m_szIDCPwd); if(objGroup != INVALID_VALUE) { node = GetGroupMainAttribNode(objGroup); if(node != INVALID_VALUE) { FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szIndex); if(szIndex.empty()) nIndex = FindIndexByID(szSubGroupID); else nIndex = atoi(szIndex.c_str()); group.szIndex = szSubGroupID; group.szName = szName; lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { nIndex ++; lsItem = sortList.find(nIndex); } sortList[nIndex] = group; } CloseGroup(objGroup); } } } nChildCount += static_cast<int>(sortList.size()); for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) { //PrintDebugString("In first setting ---------" + lsItem->second.szName + "\n"); //bool bbbb = false; nRow = pSubTable->numRows(); WImage *pShow = new WImage("/Images/cb1-unwrap.gif", pSubTable->elementAt(nRow, 0)); WImage *pHide = new WImage("/Images/cb1-fold.gif", pSubTable->elementAt(nRow, 0)); new WText(" ",pSubTable->elementAt(nRow, 0)); new WImage("/Images/cbb-3group.gif", pSubTable->elementAt(nRow, 1)); new WText(" ",pSubTable->elementAt(nRow, 1)); WText *pName = new WText(lsItem->second.szName, pSubTable->elementAt(nRow, 2)); if(pName) { string szContext = "onclick='parent.document.frames(\"left\").location.replace(\"/fcgi-bin/menu.exe?cmd=treeview.exe?groupid=" + lsItem->second.szIndex + "\");' style='color:#669;cursor:pointer;' onmouseover='this.style.textDecoration=\"underline\"'" + "onmouseout='this.style.textDecoration=\"none\"'"; sprintf(pName->contextmenu_, szContext.c_str()); } WTable * pSub = new WTable(pSubTable->elementAt(nRow + 1, 2)); if(pSub) { if(pShow && pHide) { szShow = pHide->formName(); szHide = pShow->formName(); szSubTable = pSub->formName(); string szShowText = "onclick='showsubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='display:none;cursor:pointer'"; string szHideText = "onclick='hidesubtable(\"" + szShow + "\", \"" + szHide + "\", \"" + szSubTable + "\")' " + "style='cursor:pointer'"; sprintf(pShow->contextmenu_, szShowText.c_str()); sprintf(pHide->contextmenu_, szHideText.c_str()); } if(!enumGroups(lsItem->second.szIndex, pSub)) { //bbbb = true; //pSubTable->deleteRow(nRow); pShow->hide(); pHide->hide(); } } } } lsDeviceID.clear(); if(GetSubEntitysIDBySE(objSE, lsDeviceID)) { map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; base_param device; for(lstItem = lsDeviceID.begin(); lstItem != lsDeviceID.end(); lstItem ++) { szEntityID =(*lstItem); bHasRight = true; if(m_pSVUser) bHasRight = m_pSVUser->haveGroupRight(szEntityID, Tree_DEVICE); if(bHasRight) { OBJECT objDevice = GetEntity(szEntityID, m_szIDCUser, m_szIDCPwd); if(objDevice != INVALID_VALUE) { MAPNODE node = GetEntityMainAttribNode(objDevice); if(node != INVALID_VALUE) { FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szIndex); if(szIndex.empty()) nIndex = FindIndexByID(szEntityID); else nIndex = atoi(szIndex.c_str()); device.szIndex = szEntityID; device.szName = szName; lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { nIndex ++; lsItem = sortList.find(nIndex); } sortList[nIndex] = device; } CloseEntity(objDevice); } } } nChildCount += static_cast<int>(sortList.size()); for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) { nRow = pSubTable->numRows(); new WText(" ",pSubTable->elementAt(nRow , 0)); new WImage("/Images/cbb-4server.gif", pSubTable->elementAt(nRow, 1)); new WText(" ",pSubTable->elementAt(nRow , 1)); WText *pName = new WText(lsItem->second.szName, pSubTable->elementAt(nRow, 2)); if(pName) { szContext = "onclick='parent.document.frames(\"left\").location.replace(\"/fcgi-bin/menu.exe?cmd=treeview.exe?deviceid=" + lsItem->second.szIndex + "\");' style='color:#669;cursor:pointer;' onmouseover='this.style.textDecoration=\"underline\"'" + "onmouseout='this.style.textDecoration=\"none\"'"; sprintf(pName->contextmenu_, szContext.c_str()); } if(!enumMonitors(lsItem->second.szIndex, lsItem->second.szName, pSubTable->elementAt(nRow, 2))) { //pSubTable->deleteRow(nRow); } } } CloseSVSE(objSE); if(nChildCount <= 0) { new WText(m_szNoChild, pSubTable->elementAt(nRow, 2)); } } } } }
bool CCheckBoxTreeView::InitTree(std::string strFirstNode_, bool bDevice_ ,bool bCheck_ ,bool bMain_ ,std::string strUser_, std::string szSEID) { vector<string >::iterator iSelItor; m_pOldSelNode =NULL; if(treeroot) delete treeroot; if (m_menutable) { while ( m_menutable->numRows() > 1) { m_menutable->deleteRow(m_menutable->numRows() - 1); } } strFirstNode=strFirstNode_; bDevice=bDevice_; bCheck=bCheck_; bMain=bMain_; strUser=strUser_; pTreeSelNode =NULL; if (bDevice_) //增加权限table cell { if(pRightTbl==NULL) { InitRightCell(); } Scrolltable->resize(WLength(100,WLength::Percentage), 450); this->setStyleClass("margin_top"); }else { this->setStyleClass("margin_top"); Scrolltable->setStyleClass("widthauto"); } int nAdmin = GetIniFileInt(strUser, "nAdmin", -1, "user.ini"); if(nAdmin==-1) bAdmin = false; else bAdmin= true; if(!bAdmin) { std::string groupright= GetIniFileString(strUser, "groupright", "", "user.ini"); ParserToken(pUserSelGroupList,groupright.c_str(),","); vector<string>::iterator result1; for( result1=pUserSelGroupList.begin();result1!=pUserSelGroupList.end();result1++) PushGroup(result1->c_str(),pUserTreeGroupList); } WTreeNode *FistNode; { OBJECT root = GetSVSE(szSEID); list<string> lsGroupID; list<string>::iterator lstItem; WTreeNode *tmpNode = NULL; if(treeroot!=NULL) { FistNode= makeTreeFile(GetSVSELabel(root), szSEID, Tree_SE, treeroot, false, false, "/Images/cbb-2main.gif", "/Images/cbb-2main.gif"); }else{ FistNode= makeTreeMap(GetSVSELabel(root), szSEID, Tree_SE, m_menutable, false, false, "/Images/cbb-2main.gif", "/Images/cbb-2main.gif"); treeroot= FistNode; } if (root != INVALID_VALUE) { //第一层组 if(GetSubGroupsIDBySE(root, lsGroupID)) { map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; base_param group; for(lstItem = lsGroupID.begin(); lstItem != lsGroupID.end(); lstItem ++) { string szSubGroupID = (*lstItem).c_str(); bool bSelTree = true;// 是否增加组或者设备到树上 if(!bAdmin) { iSelItor = find(pUserTreeGroupList.begin(),pUserTreeGroupList.end(),szSubGroupID); if(iSelItor == pUserTreeGroupList.end()) bSelTree= false; } if(bSelTree) { OBJECT objGroup = GetGroup(szSubGroupID); if(objGroup != INVALID_VALUE) { MAPNODE node = GetGroupMainAttribNode(objGroup); if(node != INVALID_VALUE) { string szName = "", szIndex = ""; FindNodeValue(node, "sv_index", szIndex); if(szIndex.empty()) szIndex = findIndexByRealID(szSubGroupID); group.szIndex = szSubGroupID; group.szName = szName; int nIndex = atoi(szIndex.c_str()); lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { nIndex ++; lsItem = sortList.find(nIndex); } sortList[nIndex] = group; } CloseGroup(objGroup); } } } for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) { bool bTreehaveCheck=true; if(bCheck_) bTreehaveCheck =true; else { iSelItor =find(pUserSelGroupList.begin(),pUserSelGroupList.end(), lsItem->second.szIndex); if(iSelItor ==pUserSelGroupList.end()) bTreehaveCheck= false; } tmpNode=AddGroupTreeNode(lsItem->second.szIndex, FistNode, bTreehaveCheck); if(tmpNode!=NULL) EnumGroup(lsItem->second.szIndex, tmpNode, bTreehaveCheck); } } if(GetSubEntitysIDBySE(root, lsGroupID)) { map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; base_param device; for(lstItem = lsGroupID.begin(); lstItem != lsGroupID.end(); lstItem ++) { string szEntityID = (*lstItem).c_str(); bool bSelTree =true;// 是否增加组或者设备到树上 if(!bAdmin) { iSelItor =find(pUserTreeGroupList.begin(),pUserTreeGroupList.end(),szEntityID); if(iSelItor ==pUserTreeGroupList.end()) bSelTree= false; } if(bSelTree) { OBJECT objDevice = GetEntity(szEntityID); if(objDevice != INVALID_VALUE) { MAPNODE node = GetEntityMainAttribNode(objDevice); if(node != INVALID_VALUE) { string szName = "", szIndex = ""; //FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szIndex); if(szIndex.empty()) szIndex = findIndexByRealID(szEntityID); device.szIndex = szEntityID; device.szName = szName; int nIndex = atoi(szIndex.c_str()); lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { //nMax ++; nIndex ++; lsItem = sortList.find(nIndex); } sortList[nIndex] = device; } CloseEntity(objDevice); } //AddDeviceTreeNode(szEntityID, parentNode ); } } for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) AddDeviceTreeNode(lsItem->second.szIndex, FistNode); } CloseSVSE(root); } } makeTreeFile("无依靠", "-2", Tree_MONITOR, FistNode, false, false, "/Images/cbb-6application.gif","/Images/cbb-6application.gif"); return true; }
void CCheckBoxTreeView::EnumGroup(std::string szIndex, WTreeNode* parentNode, bool bhaveCheck ) { list<string> lsGroupID; list<string> lsEntityID; list<string>::iterator lstItem; WTreeNode *tmpNode; vector<string >::iterator iSelItor; if(!szIndex.empty()) { OBJECT group = GetGroup(szIndex); if(group != INVALID_VALUE) { /////////////////////////////////////////////////////////////////////////////////////////////////// // 删除每一个设备 /////////////////////////////////////////////////////////////////////////////////////////////////// // 删除每一个子组 if(GetSubGroupsIDByGroup(group, lsGroupID)) { map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; base_param group; for(lstItem = lsGroupID.begin(); lstItem != lsGroupID.end(); lstItem ++) { string szSubGroupID = (*lstItem).c_str(); bool bSelTree =true;// 是否增加组或者设备到树上 if(!bAdmin) { iSelItor =find(pUserTreeGroupList.begin(),pUserTreeGroupList.end(),szSubGroupID); if(iSelItor ==pUserTreeGroupList.end()) bSelTree= false; } if(bSelTree) { OBJECT objGroup = GetGroup(szSubGroupID); if(objGroup != INVALID_VALUE) { MAPNODE node = GetGroupMainAttribNode(objGroup); if(node != INVALID_VALUE) { string szName = "", szIndex = ""; //FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szIndex); if(szIndex.empty()) szIndex = findIndexByRealID(szSubGroupID); group.szIndex = szSubGroupID; group.szName = szName; int nIndex = atoi(szIndex.c_str()); lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { nIndex ++; lsItem = sortList.find(nIndex); } sortList[nIndex] = group; } CloseGroup(objGroup); } } } for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) { bool bTreehaveCheck=true; if(bhaveCheck) bTreehaveCheck =true; else { iSelItor =find(pUserSelGroupList.begin(),pUserSelGroupList.end(), lsItem->second.szIndex); if(iSelItor ==pUserSelGroupList.end()) bTreehaveCheck= false; } tmpNode=AddGroupTreeNode(lsItem->second.szIndex, parentNode, bTreehaveCheck); if(tmpNode!=NULL) EnumGroup(lsItem->second.szIndex, tmpNode, bTreehaveCheck); } } if(GetSubEntitysIDByGroup(group, lsEntityID)) { map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; base_param device; for(lstItem = lsEntityID.begin(); lstItem != lsEntityID.end(); lstItem ++) { string szEntityID = (*lstItem).c_str(); bool bSelTree =true;// 是否增加组或者设备到树上 if(!bAdmin) { iSelItor =find(pUserTreeGroupList.begin(),pUserTreeGroupList.end(),szEntityID); if(iSelItor ==pUserTreeGroupList.end()) bSelTree= false; } if(bSelTree) { OBJECT objDevice = GetEntity(szEntityID); if(objDevice != INVALID_VALUE) { MAPNODE node = GetEntityMainAttribNode(objDevice); if(node != INVALID_VALUE) { string szName = "", szIndex = ""; //FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szIndex); if(szIndex.empty()) szIndex = findIndexByRealID(szEntityID); device.szIndex = szEntityID; device.szName = szName; int nIndex = atoi(szIndex.c_str()); lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { //nMax ++; nIndex ++; lsItem = sortList.find(nIndex); } sortList[nIndex] = device; } CloseEntity(objDevice); } //AddDeviceTreeNode(szEntityID, parentNode ); } } for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) AddDeviceTreeNode(lsItem->second.szIndex, parentNode); } CloseGroup(group); } } }
void CCheckBoxTreeView::AddMontiorInDevice(WTreeNode* pDeviceNode,bool bExpand) { OutputDebugString("AddMonitorInDevice()\n"); if(pDeviceNode!=NULL) { //OutputDebugString("AddMontiorInDevice\n"); map<int, base_param, less<int> > sortList; map<int, base_param, less<int> >::iterator lsItem; pDeviceNode->bMExpand=true; OBJECT objDevice = GetEntity(pDeviceNode->strId); if(objDevice != INVALID_VALUE) { list<string> lsMonitorID; list<string>::iterator lstItem; if (GetSubMonitorsIDByEntity(objDevice, lsMonitorID)) { base_param monitor; //nMax = lsMonitorID.size(); for(lstItem = lsMonitorID.begin(); lstItem != lsMonitorID.end(); lstItem ++) { string szMonitorId = (*lstItem).c_str(); OBJECT objMonitor = GetMonitor(szMonitorId); if(objMonitor != INVALID_VALUE) { MAPNODE node = GetMonitorMainAttribNode(objMonitor); if(node != INVALID_VALUE) { string szName = "", szIndex = ""; FindNodeValue(node, "sv_name", szName); FindNodeValue(node, "sv_index", szIndex); if(szIndex.empty()) szIndex = findIndexByRealID(szMonitorId); monitor.szIndex = szMonitorId; monitor.szName = szName; int nIndex = atoi(szIndex.c_str()); lsItem = sortList.find(nIndex); while(lsItem != sortList.end()) { //PrintDebugString("be found"); //nMax ++; nIndex ++;//= nMax; lsItem = sortList.find(nIndex); } sortList[nIndex] = monitor; } CloseMonitor(objMonitor); } } } CloseEntity(objDevice); } for(lsItem = sortList.begin(); lsItem != sortList.end(); lsItem ++) { WTreeNode *pNode=makeTreeFile(lsItem->second.szName,lsItem->second.szIndex, Tree_MONITOR, pDeviceNode, false, true,"/Images/cbb-6application.gif","/Images/cbb-6application.gif"); if(bExpand) { if(pDeviceNode->treeCheckBox_->isChecked()) pNode->treeCheckBox_->setChecked(true); } } } }