Example #1
0
SVAPI_API
bool  DeleteTask(string taskname,string user,string addr)
{
	if(taskname.empty()||user.empty()||addr.empty())
		return false;

	SVDBQUERY querybuf={0};
	querybuf.len = sizeof(SVDBQUERY);
	querybuf.querytype=QUERY_DELETE;
	querybuf.datatype=S_TASK;
	strcpy(querybuf.qstr,taskname.c_str());
	strcpy(querybuf.idcuser,user.c_str());

    QueryData qd;
	S_UINT len=0;
	char *pdata=NULL;
	if(qd.Query(&querybuf,(void **)&pdata,len,addr))
	{
		if(pdata!=NULL)
		{
			if(len>0)
			{
				int *pret=(int*)pdata;
				if(*pret==SVDB_OK)
				{
					delete [] pdata;
					return true;
				}
			}
			delete [] pdata;
		}
	}

	return false;
}
Example #2
0
SVAPI_API 
bool GetAllSVSEObjInfo(PAIRLIST &retlist,string infoname,string user,string addr)
{
	if(user.empty()||addr.empty())
		return false;

	if(user.size()>MAXUSERLEN)
		return INVALID_VALUE;

	if(infoname.size()>MAXQUEREYSTRINGLEN)
		return INVALID_VALUE;

	SVDBQUERY querybuf={0};
	querybuf.len = sizeof(SVDBQUERY);
	querybuf.querytype=QUERY_INFO;
	querybuf.datatype=S_SVSE;
	strcpy(querybuf.idcuser,user.c_str());
	strcpy(querybuf.qstr,infoname.c_str());

    QueryData qd;
	S_UINT len=0;
	char *pdata=NULL;
	if(qd.Query(&querybuf,(void **)&pdata,len,addr))
	{
		StringMap *pmtp=new StringMap();
		if(pmtp)
		{
			MAPNODE ret=INVALID_VALUE;
			if(pdata!=NULL)
			{
				try{
					if(pmtp->CreateObjectByRawData(pdata,len))
					{
	     				delete [] pdata;
						ret=reinterpret_cast<MAPNODE>(pmtp);
						bool bret=::EnumNodeAttrib(ret,retlist);
						delete pmtp;
						return bret;
					}
				}catch(...)
				{
					return false;
				}
			    delete [] pdata;
			}
			delete pmtp;
		}
	}
	
	return false;
}
Example #3
0
SVAPI_API
bool GetForestData(ForestList & flist, string pid, bool onlySon, string addr)
{
	if(pid.empty()||addr.empty())
		return false;
	
	string sonstr("0");
	if(onlySon)
		sonstr="1";

	SVDBQUERY querybuf={0};
	querybuf.len = sizeof(SVDBQUERY);
	querybuf.querytype=QUERY_FAST_GET;
	querybuf.datatype=S_SVSE;
	strcpy(querybuf.qstr,pid.c_str());
	strcpy(querybuf.idcuser,sonstr.c_str());

    QueryData qd;
	S_UINT len=0;
	char *pdata=NULL;
	if(qd.Query(&querybuf,(void **)&pdata,len,addr))
	{
		try{
			std::list<SingelRecord> listrcd2;
			std::list<SingelRecord>::iterator lit;
			if( CreateMassRecordListByRawData(listrcd2,pdata,len) )
			{
				for(lit=listrcd2.begin(); lit!=listrcd2.end(); ++lit)
				{
					NodeData ndata;
					CreateNodeDataByRawData(ndata, lit->data ,lit->datalen);
					flist.push_back( ndata );					
				}
				if(pdata!=NULL)
					delete [] pdata;
				return true;
			}
		}catch(...)
		{
			printf("Exception to GetForestData.");
		}		
	}
	if(pdata!=NULL)
		delete [] pdata;
	return false;
}
Example #4
0
OBJECT	GetSVSEWithVer(string id,string user,string addr,S_UINT & ver)
{
	if(atoi(id.c_str())<=0)
		return INVALID_VALUE;
	if(user.empty()||addr.empty())
		return INVALID_VALUE;

	SVDBQUERY querybuf={0};
	querybuf.len = sizeof(SVDBQUERY);
	querybuf.querytype=QUERY_GET;
	querybuf.datatype=S_SVSE;
	strcpy(querybuf.qstr,id.c_str());
	strcpy(querybuf.idcuser,user.c_str());

    QueryData qd;
	S_UINT len=0;
	char *pdata=NULL;
	if(qd.Query(&querybuf,(void **)&pdata,len,addr))
	{
		SVSE *pmtp=new SVSE();
		if(pmtp)
		{
			OBJECT ret=INVALID_VALUE;
			if(pdata!=NULL)
			{
				try{
					if(pmtp->CreateObjectByRawData(pdata+sizeof(S_UINT),len-sizeof(S_UINT)))
						ret=reinterpret_cast<OBJECT>(pmtp);
					memmove(&ver,pdata,sizeof(S_UINT));
					if(pdata!=NULL)
						delete [] pdata;
				}catch(...)
				{
					if(pdata!=NULL)
						delete [] pdata;
					return INVALID_VALUE;
				}
				return ret;
			}
		}
	}
	if(pdata!=NULL)
		delete [] pdata;
	return INVALID_VALUE;
}
Example #5
0
OBJECT	GetGroupWithVer(string groupid,string user,string addr,S_UINT & ver)
{
	if(groupid.empty()||user.empty()||addr.empty())
		return INVALID_VALUE;
	if(user.size()>MAXUSERLEN)
		return INVALID_VALUE;

	SVDBQUERY query={0};
	query.len=sizeof(SVDBQUERY);
	query.datatype=S_GROUP;
	strcpy(query.idcuser,user.c_str());
	query.querytype=QUERY_GET;
	strcpy(query.qstr,groupid.c_str());

	QueryData qd;
	S_UINT len=0;
	char *pdata=NULL;

	if(qd.Query(&query,(void **)&pdata,len,addr))
	{
		Group *pg=new Group();
		if(pg)
		{
			OBJECT ret=INVALID_VALUE;
			try{
				if(pg->CreateObjectByRawData(pdata+sizeof(S_UINT),len-sizeof(S_UINT)))
					ret=reinterpret_cast<OBJECT>(pg);
				memmove(&ver,pdata,sizeof(S_UINT));
				if(pdata!=NULL)
					delete [] pdata;
			}catch(...)
			{
				if(pdata!=NULL)
					delete [] pdata;
				return INVALID_VALUE;
			}
			return ret;

		}
	}
	if(pdata!=NULL)
		delete [] pdata;
	return INVALID_VALUE;
}
Example #6
0
SVAPI_API
bool GetAllTaskName(std::list<string> &tasknamelist,string user,string addr)
{
	if(user.empty()||addr.empty())
		return false;

	if(user.size()>MAXUSERLEN)
		return INVALID_VALUE;


	SVDBQUERY querybuf={0};
	querybuf.len = sizeof(SVDBQUERY);
	querybuf.querytype=QUERY_INFO;
	querybuf.datatype=S_TASK;
//	strcpy(querybuf.qstr,infoname.c_str());
	strcpy(querybuf.idcuser,user.c_str());

	QueryData qd;
	S_UINT len=0;
	char *pdata=NULL;
	if(qd.Query(&querybuf,(void **)&pdata,len,addr))
	{
		if(pdata!=NULL)
		{
			try{

				tasknamelist.clear();
				if(::CreateStrListByRawData(tasknamelist,pdata,len))
				{
					delete [] pdata;
					return true;
				}
			}catch(...)
			{
				delete [] pdata;
				return false;
			}
			delete [] pdata;
		}
	}

	return false;
}
Example #7
0
SVAPI_API
OBJECT GetTask(string taskname,string user,string addr)
{
	if(taskname.empty()||user.empty()||addr.empty())
		return INVALID_VALUE;
	if(user.size()>MAXUSERLEN)
		return INVALID_VALUE;

	SVDBQUERY query={0};
	query.len=sizeof(SVDBQUERY);
	query.datatype=S_TASK;
	strcpy(query.idcuser,user.c_str());
	query.querytype=QUERY_GET;
	strcpy(query.qstr,taskname.c_str());

	QueryData qd;
	S_UINT len=0;
	char *pdata=NULL;

	if(qd.Query(&query,(void **)&pdata,len,addr))
	{
		Section *pe=new Section();
		if(pe)
		{
			OBJECT ret=INVALID_VALUE;
			try{
				if(pe->CreateObjectByRawData(pdata,len))
					ret=reinterpret_cast<OBJECT>(pe);
				if(pdata!=NULL)
    				delete [] pdata;
			}catch(...)
			{
				return INVALID_VALUE;
			}
			return ret;

		}
	}
	return INVALID_VALUE;
}
Example #8
0
SVAPI_API
OBJECT GetEntityGroup(string entitygroupid,string user,string addr)
{
	if(entitygroupid.empty()||user.empty()||addr.empty())
		return INVALID_VALUE;
	if(user.size()>MAXUSERLEN)
		return INVALID_VALUE;

	SVDBQUERY query={0};
	query.len=sizeof(SVDBQUERY);
	query.datatype=S_ENTITYGROUP;
	strcpy(query.idcuser,user.c_str());
	query.querytype=QUERY_GET;
	strcpy(query.qstr,entitygroupid.c_str());

	QueryData qd;
	S_UINT len=0;
	char *pdata=NULL;

	if(qd.Query(&query,(void **)&pdata,len,addr))
	{
		EntityGroup *pe=new EntityGroup();
		if(pe)
		{
			OBJECT ret=INVALID_VALUE;
			try{
				if(pe->CreateObjectByRawData(pdata,len))
					ret=reinterpret_cast<OBJECT>(pe);
				delete [] pdata;
			}catch(...)
			{
				return INVALID_VALUE;
			}
			return ret;

		}
	}
	return INVALID_VALUE;
}
Example #9
0
SVAPI_API
bool DelChildren(string pid, bool autoDelTable, string addr)
{
	if(pid.empty()||addr.empty())
		return false;
	if(pid.find(".")==std::string::npos)
		return false;

	string sonstr("0");
	if(autoDelTable)
		sonstr="1";

	SVDBQUERY querybuf={0};
	querybuf.len = sizeof(SVDBQUERY);
	querybuf.querytype=QUERY_FAST_DEL;
	querybuf.datatype=S_SVSE;
	strcpy(querybuf.qstr,pid.c_str());
	strcpy(querybuf.idcuser,sonstr.c_str());

    QueryData qd;
	S_UINT len=0;
	char *pdata=NULL;
	if(qd.Query(&querybuf,(void **)&pdata,len,addr))
	{
		if(pdata!=NULL && len>0)
		{
			int *pret=(int*)pdata;
			if(*pret==SVDB_OK)
			{
				delete [] pdata;
				return true;
			}
		}
	}
	if(pdata!=NULL)
		delete [] pdata;
	return false;
}
Example #10
0
SVAPI_API
string  CreatIdcUser(string userindex, string pid, string addr)
{
	string newid("");
	if(userindex.empty()||addr.empty() || pid.empty())
		return newid;

	try{
		S_UINT len=0;
		SVDBQUERY querybuf={0};
		querybuf.len = sizeof(SVDBQUERY);
		querybuf.querytype=QUERY_CREATIDC;
		querybuf.datatype=S_GROUP;
		strcpy(querybuf.idcuser,userindex.c_str());
		strcpy(querybuf.qstr,pid.c_str());
		querybuf.datalen=len;

		char *pdata=NULL;
		QueryData qd;
		if(qd.Query(&querybuf,(void **)&pdata,len,addr))
		{
			if(pdata)
			{
				if(len>0)
				{
					newid= pdata;
					delete [] pdata;
					return newid;
				}
				delete [] pdata;
			}
		}
	}catch(...)
	{
	}
	return newid;
}
Example #11
0
SVAPI_API
bool DeleteEntityGroup(string entitygroupid,string user,string addr)
{
	if(entitygroupid.empty()||user.empty()||addr.empty())
		return false;

	SVDBQUERY querybuf={0};
	querybuf.len = sizeof(SVDBQUERY);
	querybuf.querytype=QUERY_DELETE;
	querybuf.datatype=S_ENTITYGROUP;
	strcpy(querybuf.qstr,entitygroupid.c_str());
	strcpy(querybuf.idcuser,user.c_str());

    QueryData qd;
	S_UINT len=0;
	char *pdata=NULL;
	if(qd.Query(&querybuf,(void **)&pdata,len,addr))
	{
		if(pdata)
		{
			if(len>0)
			{
				int *pret=(int*)pdata;
				if(*pret==SVDB_OK)
				{
					delete [] pdata;
					return true;
				}
			}
			delete [] pdata;
		}
	}

	return false;

}
Example #12
0
SVAPI_API
bool PutValueIntoChildren(const NodeData & ndata, string pid, string addr)
{
	if(pid.empty()||addr.empty())
		return false;
	if(pid.find(".")==std::string::npos)
		return false;
	if(ndata.empty())
		return false;

	NodeData & ndata1= const_cast< NodeData & >( ndata );
	unsigned int tlen= GetNodeDataRawDataSize(ndata1);
	svutil::buffer tbuf;
	if(!tbuf.checksize(tlen))
		return false;
	const char *data= GetNodeDataRawData(ndata1,tbuf,tlen); 
	if(data==NULL)
		return false;

	QueryData qd;
	char *pdata=NULL;
	S_UINT rlen=0;

	S_UINT len=0;

	SVDBQUERY querybuf={0};
	querybuf.len = sizeof(SVDBQUERY);
	querybuf.querytype=QUERY_PUT_VALUE;
	querybuf.datatype=S_SVSE;
	strcpy(querybuf.qstr,pid.c_str());

	INIQUERY iquery={0};
	iquery.len=sizeof(INIQUERY);
	iquery.datatype=D_STRING;
	iquery.datalen=tlen;

	len+=sizeof(INIQUERY);
	len+=tlen;

	querybuf.datalen=len;

	buffer buf;
	if(!buf.checksize(len))
		return false;
	char *pt=buf.getbuffer();
	memcpy(pt,&iquery,sizeof(INIQUERY));
	pt+=sizeof(INIQUERY);
	memmove(pt,data,tlen);

	if(qd.Query(&querybuf,buf,len,(void **)&pdata,rlen,addr))
	{
		if(pdata!=NULL && rlen>0)
		{
			int *pret=(int*)pdata;
			if(*pret==SVDB_OK)
			{
				delete [] pdata;
				return true;
			}
		}
	}
	if(pdata!=NULL)
		delete [] pdata;
	return false;
}