Esempio n. 1
0
af::Msg * JobContainer::registerJob( JSON & i_object, UserContainer * i_users, MonitorContainer * i_monitoring)
{
	JobAf * job = new JobAf( i_object);

	int32_t id = 0; int64_t serial = 0; std::string err;
	if( registerJob( job, err, i_users, i_monitoring))
	{
		id = job->getId();
		serial = job->getSerial();
	}
	else
		job = NULL;

	std::ostringstream oss;
	oss << "{";
	oss << "\n\"id\":" << id;
	oss << ",\n\"serial\":" << serial;

	if( err.size())
	{
		oss << ",\n\"error\":\"" << err << "\"";
	}
	else if( job == NULL )
	{
		oss << ",\n\"error\":\"Job registration failed. See server log for details.\"";
	}


	oss << "\n}";

	return af::jsonMsg( oss);
}
Esempio n. 2
0
const std::vector<int32_t> JobContainer::getIdsBySerials( const std::vector<int64_t> & i_serials)
{
	std::vector<int32_t> ids;

	JobContainerIt jobsIt( this);
	for( JobAf *job = jobsIt.job(); job != NULL; jobsIt.next(), job = jobsIt.job())
	{
		for( int i = 0; i < i_serials.size(); i++)
		{
			if( i_serials[i] == job->getSerial())
			{
				ids.push_back( job->getId());
				break;
			}
		}
	}

	if( ids.size() == 0 )
		ids.push_back(-1);

	return ids;
}