void HandleJson::EndTask(json::value jsonObj)
{
    /// Get the value for Json Object.
    int jobId = jsonObj.at(U("JobId")).as_integer();
    int taskId = jsonObj.at(U("TaskId")).as_integer();

    JobTaskDb::GetInstance().EndTask(jobId, taskId);
}
StartTaskArgs StartTaskArgs::FromJson(const json::value& j)
{
    StartTaskArgs args(
        JsonHelper<int>::Read("JobId", j.at("m_Item1")),
        JsonHelper<int>::Read("TaskId", j.at("m_Item1")),
        ProcessStartInfo::FromJson(j.at("m_Item2")));

    return std::move(args);
}
void HandleJson::StartTask(json::value jsonObj, std::string callBackUri)
{
    std::cout << "StartTask ... " << std::endl;

    // Get value from Json Object.
    auto arg = jsonObj.at(U("m_Item1"));
    auto startInfoJson = jsonObj.at(U("m_Item2"));
    int jobId = arg.at(U("JobId")).as_integer();
    int taskId = arg.at(U("TaskId")).as_integer();
    ProcessStartInfo *startInfo = ProcessStartInfo::FromJson(startInfoJson);

    std::cout << "start the task: " << startInfo->commandLine << std::endl;

    JobTaskDb::GetInstance().StartJobAndTask(jobId, taskId, startInfo, callBackUri);
}
Beispiel #4
0
static string_t get_string( const json::value& obj, const string_t& key, const string_t& def ) {
	if( !obj.has_field( key ) ) {
		return def;
	}

	json::value val = obj.at( key );
	if( val.is_null( ) ) {
		return def;
	}
	return val.as_string( );
}
void Leanplum::ParserResponse(json::value response)
{
	if (response.is_null()){
		return;
	}

	CString key;
	VARIABLE_TYPE type;
	typedef std::map<CString, std::pair<VARIABLE_TYPE, CString>>::iterator it_type;
	for(it_type iterator = m_variablesMap.begin(); iterator != m_variablesMap.end(); iterator++) {
		key = iterator->first;
		type = iterator->second.first;
		if (VARIABLE_TYPE::INT == type) {
			 int v = response.at(key.GetBuffer()).as_integer();
			 iterator->second.second.Format(_T("%d"), v);
		} else if (VARIABLE_TYPE::BOOL == type) {
			bool v = response.at(key.GetBuffer()).as_bool();
			iterator->second.second = v? _T("true"):_T("false");
		} else if (VARIABLE_TYPE::STRING == type) {
			iterator->second.second = response.at(key.GetBuffer()).as_string().c_str();
		}
	}
}
void HandleJson::EndJob(json::value jsonObj)
{
    int jobId = jsonObj.at(U("JobId")).as_integer();

    JobTaskDb::GetInstance().EndJob(jobId);
}