Application->getModule('api')->get(array('jobs', $jobId))->output; $this->JobName->Text = $jobdata->job; $this->JobID->Text = $jobdata->jobid; $joblog = $this->Application->getModule('api')->get(array('joblog', $jobdata->jobid))->output; $this->Estimation->Text = is_array($joblog) ? implode(PHP_EOL, $joblog) : Prado::localize("Output for selected job is not available yet or you do not have enabled logging job logs to catalog database." . PHP_EOL . PHP_EOL . "For watching job log there is need to add to the job Messages resource next directive:" . PHP_EOL . PHP_EOL . "console = all, !skipped, !saved" . PHP_EOL); $this->Level->dataSource = $this->Application->getModule('misc')->getJobLevels(); $this->Level->SelectedValue = $jobdata->level; $this->Level->dataBind(); $clients = $this->Application->getModule('api')->get(array('clients'))->output; $clientsList = array(); foreach($clients as $client) { $clientsList[$client->clientid] = $client->name; } $this->Client->dataSource = $clientsList; $this->Client->SelectedValue = $jobdata->clientid; $this->Client->dataBind(); $filesetsAll = $this->Application->getModule('api')->get(array('filesets'))->output; $filesetsList = array(); foreach($filesetsAll as $director => $filesets) { $filesetsList = array_merge($filesets, $filesetsList); } if($jobdata->filesetid != 0) { $selectedFileset = $this->Application->getModule('api')->get(array('filesets', $jobdata->filesetid))->output; } $this->FileSet->dataSource = array_combine($filesetsList, $filesetsList); $this->FileSet->SelectedValue = @$selectedFileset->fileset; $this->FileSet->dataBind(); $pools = $this->Application->getModule('api')->get(array('pools'))->output; $poolList = array(); foreach($pools as $pool) { $poolList[$pool->poolid] = $pool->name; } $this->Pool->dataSource = $poolList; $this->Pool->SelectedValue = $jobdata->poolid; $this->Pool->dataBind(); $storages = $this->Application->getModule('api')->get(array('storages'))->output; $storagesList = array(); foreach($storages as $storage) { $storagesList[$storage->storageid] = $storage->name; } $this->Storage->dataSource = $storagesList; $this->Storage->dataBind(); $this->Priority->Text = ($jobdata->priorjobid == 0) ? self::DEFAULT_JOB_PRIORITY : $jobdata->priorjobid; $this->DeleteButton->Visible = true; $this->CancelButton->Visible = in_array($jobdata->jobstatus, $this->runningJobStates); } public function status($sender, $param) { $joblog = $this->Application->getModule('api')->get(array('joblog', $this->JobID->Text))->output; $this->Estimation->Text = is_array($joblog) ? implode(PHP_EOL, $joblog) : Prado::localize("Output for selected job is not available yet or you do not have enabled logging job logs to catalog database." . PHP_EOL . PHP_EOL . "For watching job log there is need to add to the job Messages resource next directive:" . PHP_EOL . PHP_EOL . "console = all, !skipped, !saved" . PHP_EOL); } public function delete($sender, $param) { $this->Application->getModule('api')->remove(array('jobs', $this->JobID->Text)); $this->DeleteButton->Visible = false; } public function cancel($sender, $param) { $this->Application->getModule('api')->set(array('jobs', 'cancel', $this->JobID->Text), array('a' => 'b')); $this->CancelButton->Visible = false; } public function run_again($sender, $param) { if($this->PriorityValidator->IsValid === false) { return false; } $params = array(); $params['id'] = $this->JobID->Text; $params['level'] = $this->Level->SelectedValue; $params['fileset'] = $this->FileSet->SelectedValue; $params['clientid'] = $this->Client->SelectedValue; $params['storageid'] = $this->Storage->SelectedValue; $params['poolid'] = $this->Pool->SelectedValue; $params['priority'] = $this->Priority->Text; $result = $this->Application->getModule('api')->create(array('jobs', 'run'), $params)->output; $this->Estimation->Text = implode(PHP_EOL, $result); } public function estimate($sender, $param) { $params = array(); $params['id'] = $this->JobID->Text; $params['level'] = $this->Level->SelectedValue; $params['fileset'] = $this->FileSet->SelectedValue; $params['clientid'] = $this->Client->SelectedValue; $params['accurate'] = (integer)$this->Accurate->Checked; $result = $this->Application->getModule('api')->create(array('jobs', 'estimate'), $params)->output; $this->Estimation->Text = implode(PHP_EOL, $result); } public function priorityValidator($sender, $param) { $isValid = preg_match('/^[0-9]+$/',$this->Priority->Text) === 1 && $this->Priority->Text > 0; $param->setIsValid($isValid); } } ?>