void UserAf::addJob( JobAf * i_job) { appendLog( std::string("Adding a job: ") + i_job->getName()); updateTimeActivity(); m_jobslist.add( i_job ); m_jobs_num++; updateJobsOrder( i_job); i_job->setUser( this); }
void UserAf::v_action( Action & i_action) { bool was_permanent = isPermanent(); const JSON & operation = (*i_action.data)["operation"]; if( operation.IsObject()) { std::string type; af::jr_string("type", type, operation); if( type.find("move_jobs_") == 0 ) { std::vector<int32_t> jids; af::jr_int32vec("jids", jids, operation); if( type == "move_jobs_up" ) m_jobslist.moveNodes( jids, AfList::MoveUp); else if( type == "move_jobs_down" ) m_jobslist.moveNodes( jids, AfList::MoveDown); else if( type == "move_jobs_top" ) m_jobslist.moveNodes( jids, AfList::MoveTop); else if( type == "move_jobs_bottom" ) m_jobslist.moveNodes( jids, AfList::MoveBottom); updateJobsOrder(); i_action.monitors->addUser( this); } } const JSON & params = (*i_action.data)["params"]; if( params.IsObject()) jsonRead( params, &i_action.log); if( was_permanent != isPermanent()) { if( isPermanent()) AFCommon::QueueDBAddItem( this); else AFCommon::QueueDBDelItem( this); } if( i_action.log.size() ) { // Update database only is permanent parameter was not changed. // If it was, user is just added to or deleted from database. if( was_permanent == isPermanent()) AFCommon::QueueDBUpdateItem( this); i_action.monitors->addEvent( af::Msg::TMonitorUsersChanged, m_id); } }
void UserAf::v_action( Action & i_action) { const JSON & operation = (*i_action.data)["operation"]; if( operation.IsObject()) { std::string type; af::jr_string("type", type, operation); if( type.find("move_jobs_") == 0 ) { std::vector<int32_t> jids; af::jr_int32vec("jids", jids, operation); if( type == "move_jobs_up" ) m_jobslist.moveNodes( jids, AfList::MoveUp); else if( type == "move_jobs_down" ) m_jobslist.moveNodes( jids, AfList::MoveDown); else if( type == "move_jobs_top" ) m_jobslist.moveNodes( jids, AfList::MoveTop); else if( type == "move_jobs_bottom" ) m_jobslist.moveNodes( jids, AfList::MoveBottom); updateJobsOrder(); i_action.monitors->addUser( this); } else if( type == "delete") { if( m_jobs_num != 0 ) return; appendLog( std::string("Deleted by ") + i_action.author); deleteNode( i_action.monitors); return; } } const JSON & params = (*i_action.data)["params"]; if( params.IsObject()) jsonRead( params, &i_action.log); if( i_action.log.size() ) { store(); i_action.monitors->addEvent( af::Monitor::EVT_users_change, m_id); } }