/** * Execute the console command. * * @return mixed */ public function fire() { try { $log = new Process(); $log->name = "get-links"; $log->status = "running"; $log->save(); //Check new links Rss::chunk(100, function ($rss) { foreach ($rss as $value) { $this->loadRss($value); $value->touch(); } }); //Remove old links $filterDate = new DateTime('now'); $filterDate->sub(new DateInterval('P1D')); Link::where('date', '<', $filterDate)->where('updated_at', '<', $filterDate)->delete(); $log->status = "finished"; $log->save(); } catch (Exception $e) { $this->info($url); $this->info($e->getMessage()); } }
/** * Execute the console command. * * @return mixed */ public function fire() { try { $log = new Process(); $log->name = "get-shares"; $log->status = "running"; $log->save(); $filterDate = new DateTime('now'); $filterDate->sub(new DateInterval('P1D')); //Load shares Link::where('date', '>', $filterDate)->chunk(100, function ($links) { foreach ($links as $value) { $shares = $this->getSharesCount($value->final_url); $ref = Stats::where('id_link', $value->id)->orderBy('created_at', 'DESC')->first(); if (!$ref) { $ref = new stdClass(); $ref->total = 0; } $stat = new Stats(); $stat->id_link = $value->id; $stat->facebook = $shares['facebook'] != null ? $shares['facebook'] : $value->facebook; $stat->twitter = $shares['twitter'] != null ? $shares['twitter'] : $value->twitter; $stat->linkedin = $shares['linkedin'] != null ? $shares['linkedin'] : $value->linkedin; $stat->googleplus = $shares['googleplus'] != null ? $shares['googleplus'] : $value->googleplus; $stat->total = $stat->facebook + $stat->twitter + $stat->linkedin + $stat->googleplus; $stat->dif_total = $stat->total - $ref->total; $stat->save(); $value->facebook = $stat->facebook; $value->twitter = $stat->twitter; $value->linkedin = $stat->linkedin; $value->googleplus = $stat->googleplus; $value->total = $stat->total; $value->save(); } }); $log->status = "finished"; $log->save(); } catch (Exception $e) { $this->info($url); $this->info($e->getMessage()); } }
/** * Execute the console command. * * @return mixed */ public function fire() { $log = new Process(); $log->name = "make-history"; $log->status = "running"; $log->save(); $today = Carbon::today(); $topToday = array(); $newspapers = Newspaper::select('id')->get(); $tags = Tag::select('id')->get(); foreach ($newspapers as $key => $n) { $top = $this->getTopLink($today, $n->id, false); if ($top) { $topToday[] = $top; } } foreach ($tags as $key => $t) { $top = $this->getTopLink($today, false, $t->id); if ($top) { $topToday[] = $top; } } $topToday = array_unique($topToday); //Remove links for today History::where('date', '=', $today)->delete(); //Save history foreach ($topToday as $key => $t) { $this->info($t->title); try { $h = new History(); $h->id_ref = $t->id; unset($t->id); $h->fill($t->toArray()); $h->date = $today; $h->save(); } catch (Exception $e) { } } $log->status = "finished"; $log->save(); }
/** * Stops a background process in progress. * * @param Process $process The process to stop. * @return bool True if the process was stopped, false if not. */ public static function stopProcess(Process $process) { if ($process->status == Process::STATUS_STARTING || $process->status == Process::STATUS_IN_PROGRESS) { $pid = $process->pid; $process->stopped = date('Y-m-d G:i:s'); if ($pid) { $command = "kill " . escapeshellarg($pid); exec($command); } // Consider a "STOPPED" status instead. $process->status = Process::STATUS_STOPPED; $process->pid = null; $process->save(); return true; } else { return false; } }
public function asyncNext() { $agent = AgentModel::find(Session::get('agent_id')); $agent->is_active = true; $agent->save(); $status = StatusModel::where('store_id', $agent->store_id)->first(); if (Session::has('process_id')) { $process = ProcessModel::find(Session::get('process_id')); $process->end_time = date('H:i:s'); if (Input::has('ticket_type') && Input::get('ticket_type') != '') { $process->ticket_type = Input::get('ticket_type'); } $process->save(); Session::forget('process_id'); } if (Input::get('is_next') == '1') { if ($status->current_queue_no + 1 <= $status->last_queue_no) { $status->current_queue_no = $status->current_queue_no + 1; $status->save(); $process = new ProcessModel(); $process->agent_id = Session::get('agent_id'); $process->queue_no = $status->current_queue_no; $process->start_time = date('H:i:s'); $process->save(); Session::set('process_id', $process->id); return Response::json(['result' => 'success', 'currentQueueNo' => $status->current_queue_no, 'lastQueueNo' => $status->last_queue_no, 'processId' => $process->id]); } else { $agent->is_active = false; $agent->save(); return Response::json(['result' => 'failed', 'msg' => 'The queue is empty']); } } else { $agent->is_active = false; $agent->save(); return Response::json(['result' => 'failed', 'msg' => 'Your status is DEACTIVE']); } }
/** * Implementation for 'POST' method for Rest API * * @param mixed $proUid Primary key * * @return array $result Returns array within multiple records or a single record depending if * a single selection was requested passing id(s) as param */ protected function post($proUid, $proParent, $proTime, $proTimeunit, $proStatus, $proTypeDay, $proType, $proAssignment, $proShowMap, $proShowMessage, $proShowDelegate, $proShowDynaform, $proCategory, $proSubCategory, $proIndustry, $proUpdateDate, $proCreateDate, $proCreateUser, $proHeight, $proWidth, $proTitleX, $proTitleY, $proDebug, $proDynaforms, $proDerivationScreenTpl) { try { $result = array(); $obj = new Process(); $obj->setProUid($proUid); $obj->setProParent($proParent); $obj->setProTime($proTime); $obj->setProTimeunit($proTimeunit); $obj->setProStatus($proStatus); $obj->setProTypeDay($proTypeDay); $obj->setProType($proType); $obj->setProAssignment($proAssignment); $obj->setProShowMap($proShowMap); $obj->setProShowMessage($proShowMessage); $obj->setProShowDelegate($proShowDelegate); $obj->setProShowDynaform($proShowDynaform); $obj->setProCategory($proCategory); $obj->setProSubCategory($proSubCategory); $obj->setProIndustry($proIndustry); $obj->setProUpdateDate($proUpdateDate); $obj->setProCreateDate($proCreateDate); $obj->setProCreateUser($proCreateUser); $obj->setProHeight($proHeight); $obj->setProWidth($proWidth); $obj->setProTitleX($proTitleX); $obj->setProTitleY($proTitleY); $obj->setProDebug($proDebug); $obj->setProDynaforms($proDynaforms); $obj->setProDerivationScreenTpl($proDerivationScreenTpl); $obj->save(); } catch (Exception $e) { throw new RestException(412, $e->getMessage()); } }
$session = array('id' => @$r['0'], 'court' => @$r['0.0'], 'clerk' => @$r['0.2'], 'scheduled' => @$r['0.3'], 'date of occurence' => @$r['0.4']); $session['judge'] = array(); for ($i0 = 0; isset($r['0.1.' . $i0]); $i0++) { $session['judge'][$i0] = @$r['0.1.' . $i0 . '']; } $case = array('id' => @$r['1'], 'area of law' => @$r['1.0']); $case['type of case'] = array(); for ($i0 = 0; isset($r['1.1.' . $i0]); $i0++) { $case['type of case'][$i0] = @$r['1.1.' . $i0 . '']; } $case['session'] = array(); for ($i0 = 0; isset($r['1.2.' . $i0]); $i0++) { $case['session'][$i0] = @$r['1.2.' . $i0 . '']; } $Process = new Process($ID, $session, $case); if ($Process->save() !== false) { die('ok:' . $_SERVER['PHP_SELF'] . '?Process=' . urlencode($Process->getId())); } else { die(''); } exit; // do not show the interface } $buttons = ""; if (isset($_REQUEST['new'])) { $new = true; } else { $new = false; } if (isset($_REQUEST['edit']) || $new) { $edit = true;