Exemplo n.º 1
0
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);
            }
        }
    }
}
Exemplo n.º 2
0
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("&nbsp;",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("&nbsp;",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("&nbsp;",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;
}
Exemplo n.º 3
0
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);

        }        
    }
}