コード例 #1
0
ファイル: index.php プロジェクト: adntec/queueManage
function shutdown()
{
    if (Database::hasBeenUsed()) {
        Database::commit();
    }
    // Jobs must not write to database!
    $queue = JobQueue::getInstance();
    $jobs = $queue->executeJobs();
    gfDebug("Request ended.\n");
}
コード例 #2
0
ファイル: Output.php プロジェクト: adntec/queueManage
 public function output()
 {
     $jobs = JobQueue::getInstance();
     if ($jobs->countJobs() > 0 && !$this->willCloseConnection) {
         gfDebug(__METHOD__ . " Forced close connection for background jobs.");
         $this->closeConnection(true);
     }
     $this->outputHttpHeaders();
     $this->outputHttpBody();
     if ($this->willCloseConnection) {
         @ini_set('zlib.output_compression', 'Off');
         @apache_setenv('no-gzip', 1);
         header("Connection: close");
         $outputSize = ob_get_length();
         header("Content-Length: {$outputSize}");
     }
     ob_end_flush();
     ob_flush();
     flush();
     if ($this->willCloseConnection && session_id()) {
         session_write_close();
     }
 }
コード例 #3
0
ファイル: Ticket.php プロジェクト: adntec/queueManage
 protected function sendYourTurn()
 {
     if ($this->getSource() != 'app') {
         return;
     }
     /*
      * Hack: cannot pass $this to closures.
      * They are objects and define their
      * own $this.
      */
     $ref = $this;
     $call = function () use($ref) {
         $sender = new AppPushSender($ref->getSourceId());
         $sender->sendYourTurn($ref);
     };
     $jobs = JobQueue::getInstance();
     $jobs->addJob($call);
 }
コード例 #4
0
ファイル: Job.php プロジェクト: johsbk/penguin
 public function create()
 {
     $this->created_at = new \DateTime();
     $jq = JobQueue::getInstance();
     $jq->add($this);
 }
コード例 #5
0
ファイル: TicketStats.php プロジェクト: adntec/queueManage
 public static function newFromTicket($ticket, $ts_time_out = null)
 {
     if (!$ts_time_out) {
         $ts_time_out = time();
     }
     $ret = self::newRecord();
     $ret->setCode($ticket->getCode());
     $ret->setTimeIn($ticket->getTimeIn());
     $ret->setSource($ticket->getSource());
     if ($ticket->getTable() == 'ticket_in') {
         $ret->setTimeExec(null);
         $ret->setIsTrash(false);
         $ret->setTimeOut($ts_time_out);
     } else {
         global $gvTrashThreshold, $gvSessionTimeout;
         $ret->setOpCode($ticket->getOpCode());
         $ret->setDeskNumber($ticket->getDeskNumber());
         $ret->setTimeExec($ticket->getTimeExec());
         if ($ts_time_out - $ticket->getTimeExec() > $gvSessionTimeout) {
             // Never set exec duration beyond sessionTimeout
             $ts_time_out = $ticket->getTimeExec() + $gvSessionTimeout;
         }
         $ret->setTimeOut($ts_time_out);
         if (in_array($ret->ts_source, array('app', 'web')) && $ret->ts_time_out - $ret->ts_time_exec < $gvTrashThreshold) {
             // This ticket is trash
             $ret->setIsTrash(true);
             Ban::recordTicketTrash($ticket);
             // Send trash notice (only for app)
             if ($ticket->getSource() == 'app') {
                 $call = function () use($ticket) {
                     $sender = new AppPushSender($ticket->getSourceId());
                     $sender->sendTrashNotice();
                 };
                 $jobs = JobQueue::getInstance();
                 $jobs->addJob($call);
             }
         }
     }
     return $ret;
 }