public function ProcessFlight($extId) { if (is_int($extId)) { $flightId = $extId; $avaliableFlights = $this->_user->GetAvaliableFlights($this->_user->username); if (in_array($flightId, $avaliableFlights)) { $Fl = new Flight(); $flightInfo = $Fl->GetFlightInfo($flightId); $apTableName = $flightInfo["apTableName"]; $bpTableName = $flightInfo["bpTableName"]; $excEventsTableName = $flightInfo["exTableName"]; $startCopyTime = $flightInfo["startCopyTime"]; $tableGuid = substr($apTableName, 0, 14); unset($Fl); $Bru = new Bru(); $bruInfo = $Bru->GetBruInfo($flightInfo["bruType"]); $excListTableName = $bruInfo["excListTableName"]; $apGradiTableName = $bruInfo["gradiApTableName"]; $bpGradiTableName = $bruInfo["gradiBpTableName"]; $stepLength = $bruInfo["stepLength"]; if ($excListTableName != "") { $bruInfo = $Bru->GetBruInfo($flightInfo["bruType"]); $excListTableName = $bruInfo["excListTableName"]; $apGradiTableName = $bruInfo["gradiApTableName"]; $bpGradiTableName = $bruInfo["gradiBpTableName"]; $FEx = new FlightException(); $FEx->DropFlightExceptionTable($excEventsTableName); $flightExTableName = $FEx->CreateFlightExceptionTable($flightId, $tableGuid); //Get exc refParam list $excRefParamsList = $FEx->GetFlightExceptionRefParams($excListTableName); $exList = $FEx->GetFlightExceptionTable($excListTableName); //file can be accesed by ajax what can cause warning error_reporting(E_ALL ^ E_WARNING); //perform proc be cached table for ($i = 0; $i < count($exList); $i++) { // $fp = fopen($tempFilePath, "w"); // fwrite($fp, json_encode($exList[$i]["code"])); // fclose($fp); $curExList = $exList[$i]; $FEx->PerformProcessingByExceptions($curExList, $flightInfo, $flightExTableName, $apTableName, $bpTableName, $startCopyTime, $stepLength); } error_reporting(E_ALL); // unlink($tempFilePath); } else { // unlink($tempFilePath); } unset($Bru); $result = true; return $result; } else { error_log("Not avaliable for current user. ProcessFlight id - " . $id . ". " . "Username - " . $this->_user->username . ". Page FlightsController.php"); $result['status'] = false; return $result['status']; } } else { error_log("Incorrect input data. DeleteFlight id - " . json_encode($extId) . ". Page FlightsController.php"); $result['status'] = false; return $result['status']; } }
public function ProccesFlightException($extFlightId, $extTempFileName) { $flightId = $extFlightId; $tempFile = $extTempFileName; $tempFilePath = UPLOADED_FILES_PATH . "proccessStatus/" . $tempFile; $tmpProccStatusFilesDir = UPLOADED_FILES_PATH . "proccessStatus"; if (!is_dir($tmpProccStatusFilesDir)) { mkdir($tmpProccStatusFilesDir); } $tmpStatus = $this->lang->startFlExcProcc; $fp = fopen($tempFilePath, "w"); fwrite($fp, json_encode($tmpStatus)); fclose($fp); $Fl = new Flight(); $flightInfo = $Fl->GetFlightInfo($flightId); $apTableName = $flightInfo["apTableName"]; $bpTableName = $flightInfo["bpTableName"]; $excEventsTableName = $flightInfo["exTableName"]; $startCopyTime = $flightInfo["startCopyTime"]; $tableGuid = substr($apTableName, 0, 14); unset($Fl); $Bru = new Bru(); $bruInfo = $Bru->GetBruInfo($flightInfo["bruType"]); $excListTableName = $bruInfo["excListTableName"]; $apGradiTableName = $bruInfo["gradiApTableName"]; $bpGradiTableName = $bruInfo["gradiBpTableName"]; $stepLength = $bruInfo["stepLength"]; if ($excListTableName != "") { $bruInfo = $Bru->GetBruInfo($flightInfo["bruType"]); $excListTableName = $bruInfo["excListTableName"]; $apGradiTableName = $bruInfo["gradiApTableName"]; $bpGradiTableName = $bruInfo["gradiBpTableName"]; $FEx = new FlightException(); $flightExTableName = $FEx->CreateFlightExceptionTable($flightId, $tableGuid); //Get exc refParam list $excRefParamsList = $FEx->GetFlightExceptionRefParams($excListTableName); $exList = $FEx->GetFlightExceptionTable($excListTableName); //file can be accesed by ajax what can cause warning error_reporting(E_ALL ^ E_WARNING); //perform proc be cached table for ($i = 0; $i < count($exList); $i++) { //50 because we think previous 50 ware used during proc $tmpStatus = round(50 + 50 / count($exList) * $i) . "%"; $fp = fopen($tempFilePath, "w"); fwrite($fp, json_encode($tmpStatus)); fclose($fp); $curExList = $exList[$i]; $FEx->PerformProcessingByExceptions($curExList, $flightInfo, $flightExTableName, $apTableName, $bpTableName, $startCopyTime, $stepLength); } unlink($tempFilePath); error_reporting(E_ALL); } else { unlink($tempFilePath); } unset($Bru); }