Exemplo n.º 1
0
 public function revertPublish($request)
 {
     $internalProvider = Application_Model_General::getSettings('InternalProvider');
     // check if this not the internal provider publish
     //TODO oc666: check if necessary
     if (substr($request['request_id'], 2, 2) != $internalProvider) {
         $where[] = "request_id = " . $resultFetch['request_id'] . "";
         $where[] = "trx_no NOT LIKE '" . $internalProvider . "%'";
         $req_tbl = new Application_Model_DbTable_Requests(Np_Db::master());
         $res = $req_tbl->update(array('last_transaction' => 'Publish_response'), $where);
         return $res;
     }
     $publish_response_providers = array();
     if ($publish_response_providers) {
         //problem! - send providers again
         $ret = array();
         foreach ($publish_response_providers as $provider) {
             $request['provider'] = $provider;
             Application_Model_General::forkProcess("/cron/cancelpublish", $request);
             $ret[] = $request;
         }
         return $ret;
     } else {
         //no problem - update publish_response
         $req_tbl = new Application_Model_DbTable_Requests(Np_Db::master());
         $req_tbl->update(array('last_transaction' => 'Publish_response', 'status' => 0), 'id=' . $request['id']);
         //send to internal!
     }
     return TRUE;
 }
Exemplo n.º 2
0
 public function sendAction()
 {
     $params = $this->getRequest()->getParams();
     $url = 'Internal';
     $method = $params['MSG_TYPE'];
     Application_Model_General::prefixPhoneNumber($params['NUMBER']);
     $args = array('method' => Application_Model_Internal::getMethodName($method), 'msg_type' => $method, 'provider' => $params['TO'], 'number' => $params['NUMBER'], 'request_time' => time());
     if ($method == 'Request' || $method == 'Update') {
         $args['transfer_time'] = $params['porttime'];
     } else {
         if ($method == 'Execute_response') {
             $args['more']['connect_time'] = time();
         }
     }
     $success = Application_Model_General::forkProcess($url, $args, true);
     if ($success) {
         $params['success'] = 1;
         $params['message'] = 'Request sent';
     } else {
         $params['success'] = 0;
         $params['message'] = 'Request failed';
     }
     $this->_redirect(Application_Model_General::getBaseUrl() . '/monitor/request?' . http_build_query($params));
 }
Exemplo n.º 3
0
 /**
  * automatic response for  CheckResponse,RequestResponse and UpdateResponse
  * sent to internal/provider via GET in new PROCESS
  * @param string $type 
  */
 public function sendAutoRequest($type)
 {
     $request = null;
     switch ($type) {
         case "CheckResponse":
             if (($transfer_time = Application_Model_General::isAutoCheck($this->params['REQUEST_ID'])) !== FALSE) {
                 $request = array("REQUEST_ID" => $this->params['REQUEST_ID'], "MSG_TYPE" => "Request", "TO" => $this->params['FROM'], "PORT_TIME" => $transfer_time, "PHONE_NUMBER" => $this->params['PHONE_NUMBER'], "PROCESS_TYPE" => $this->params['PROCESS_TYPE'], "FROM" => $this->params['TO'], "RETRY_DATE" => Application_Model_General::getDateTimeIso(), "RETRY_NO" => $this->params['RETRY_NO'], "VERSION_NO" => Application_Model_General::getSettings("VersionNo"));
             }
             break;
         case "RequestResponse":
         case "UpdateResponse":
         case "CancelResponse":
             $request = array("REQUEST_ID" => $this->params['REQUEST_ID'], "MSG_TYPE" => "KD_update", "FROM" => Application_Model_General::getSettings("InternalProvider"), "TO" => "KD", "KD_update_type" => strtoupper(str_ireplace("Response", "", $type)), "PROCESS_TYPE" => $this->params['PROCESS_TYPE'], "PHONE_NUMBER" => $this->params['PHONE_NUMBER'], "RETRY_DATE" => Application_Model_General::getDateTimeIso(), "RETRY_NO" => $this->params['RETRY_NO'], "VERSION_NO" => Application_Model_General::getSettings("VersionNo"));
             break;
     }
     if ($request) {
         Application_Model_General::forkProcess("/internal/provider", $request, false, Application_Model_General::getSettings('fork-sleep-internal', 1));
     }
 }
Exemplo n.º 4
0
 /**
  * If "Publish response" 
  * saves to transactions table then sends to internal
  * if other response 
  * sends to internal without saving to transactions
  * if not response 
  * Sends Params to provider/ineternal via GET in New Process 
  * 
  * @return BOOL 
  */
 public function Execute()
 {
     if (TRUE === ($requestValidate = $this->RequestValidate())) {
         $msg_type = explode("_", $this->request->getHeaderField("MSG_TYPE"));
         if (isset($msg_type[1]) && $msg_type[1] == "response") {
             // if is response
             if ($msg_type[0] == "Publish") {
                 //if is publish response
                 //don't pass to Internal - it is saved and taking care of in our system
                 $this->request->setAck("Ack00");
             }
             $this->ExecuteResponse();
         } elseif (count($msg_type) > 1 && $msg_type[1] == 'publish' && $msg_type[2] == 'response') {
             // if is cancel publish response
             $this->ExecuteResponse();
         } elseif ($this->request->getHeaderField("MSG_TYPE") == "Inquire_number_response") {
             // if is inquire publish response
             $this->request->setAck("Ack00");
             $this->ExecuteResponse();
         } else {
             //if not response
             if (Application_Model_General::forkProcess("/provider/internal", $this->data, false, Application_Model_General::getSettings('fork-sleep-provider', 1))) {
                 // create new process for not responses
                 $someAck = $this->request->getAck();
                 $this->request->setAck("Ack00");
             } else {
                 $this->request->setAck("Inv01");
             }
         }
     } else {
         // if doesnt validate
         //			$this->saveTransactionsDB();
     }
     // TODO oc666: not required for all cases (set ack as reject reason code)
     return $this->request->setRejectReasonCode($this->request->getAck());
 }