Esempio n. 1
0
TTime MakeTTime(string strTime)
{
	if(strTime.empty())
	{
		TTime time;
		return time;
	}

	std::list<string> pTmpList;	
	ParserToken(pTmpList, strTime.c_str(), " ");
	
	string strYear, strMonth, strDay;
	std::list<string> pTmpList1;
	ParserToken(pTmpList1, pTmpList.front().c_str(), "-");
	
	strYear = pTmpList1.front();
	pTmpList1.pop_front();
	strMonth = pTmpList1.front();
	pTmpList1.pop_front();
	strDay = pTmpList1.front();
	pTmpList1.pop_front();
	
	string strHour, strMinute, strSecond;
	std::list<string> pTmpList2;
	ParserToken(pTmpList2, pTmpList.back().c_str(), ":");

	strHour = pTmpList2.front();
	pTmpList2.pop_front();
	strMinute = pTmpList2.front();
	pTmpList2.pop_front();
	strSecond = pTmpList2.front();
	pTmpList2.pop_front();
	
	int nYear, nMonth, nDay, nHour, nMinute, nSecond;
	sscanf(strYear.c_str(), "%d", &nYear);
	sscanf(strMonth.c_str(), "%d", &nMonth);
	sscanf(strDay.c_str(), "%d", &nDay);
	sscanf(strHour.c_str(), "%d", &nHour);
	sscanf(strMinute.c_str(), "%d", &nMinute);
	sscanf(strSecond.c_str(), "%d", &nSecond);	
	
	TTime time(nYear, nMonth, nDay, nHour, nMinute, nSecond);

	return time;
}
Esempio n. 2
0
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;
}