void CSVSortList::enumGroup(string &szGroupIndex) { list<string> lsGroupID; list<string>::iterator lsItem; OBJECT objGroup; base_param group; if(IsSVSEID(szGroupIndex)) { objGroup = GetSVSE(szGroupIndex, m_szIDCUser, m_szIDCPwd); if(objGroup != INVALID_VALUE) { GetSubGroupsIDBySE(objGroup, lsGroupID); CloseSVSE(objGroup); } } else { objGroup = GetGroup(szGroupIndex, m_szIDCUser, m_szIDCPwd); if(objGroup != INVALID_VALUE) { GetSubGroupsIDByGroup(objGroup, lsGroupID); CloseGroup(objGroup); } } int nIndex = 0; for(lsItem = lsGroupID.begin(); lsItem != lsGroupID.end(); lsItem ++) { string szID = (*lsItem).c_str(); bool bHasRight = true; if(m_pSVUser) bHasRight = m_pSVUser->haveGroupRight(szID, Tree_DEVICE); if(bHasRight) { objGroup = GetGroup(szID, m_szIDCUser, m_szIDCPwd); 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()) nIndex = FindIndexByID(szID); else nIndex = atoi(szIndex.c_str()); group.szIndex = szID; group.szName = szName; m_sortList[nIndex] = group; } CloseGroup(objGroup); } } } }
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); } }
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; }
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; }
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)); } } } } }