コード例 #1
0
ファイル: order.php プロジェクト: Satariall/izurit
 protected function receiveFiles()
 {
     $result = array();
     $timeToKeepFiles = 24;
     $tmpDir = \CTempFile::GetDirectoryName($timeToKeepFiles);
     CheckDirPath($tmpDir);
     $sftp = \Bitrix\Sale\TradingPlatform\Ebay\Helper::getSftp($this->siteId);
     $sftp->connect();
     /*
     $orderFiles = $sftp->getFilesList($this->remotePath);
     
     foreach($orderFiles as $file)
     {
     	if($sftp->downloadFile($this->remotePath."/".$file, $tmpDir.$file))
     	{
     		$result[] = $tmpDir.$file;
     		Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_DATA_SOURCE_ORDERFILE_RECEIVED", $file, "File received successfully.", $this->siteId);
     	}
     }
     */
     $file = "orderLatest";
     if ($sftp->downloadFile($this->orderLatest, $tmpDir . $file)) {
         $result[] = $tmpDir . $file;
         Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_DATA_SOURCE_ORDERFILE_RECEIVED", $file, "File received successfully.", $this->siteId);
     }
     return $result;
 }
コード例 #2
0
ファイル: results.php プロジェクト: Satariall/izurit
 protected function getFileContent($feedData)
 {
     $result = "";
     $timeToKeepFiles = 24;
     $tmpDir = \CTempFile::GetDirectoryName($timeToKeepFiles);
     CheckDirPath($tmpDir);
     $sftp = \Bitrix\Sale\TradingPlatform\Ebay\Helper::getSftp($this->siteId);
     $sftp->connect();
     $remotePath = $this->createRemotePath($feedData);
     $files = $sftp->getFilesList($remotePath);
     foreach ($files as $file) {
         if (!strstr($file, $feedData["FILENAME"])) {
             continue;
         }
         if ($sftp->downloadFile($remotePath . "/" . $file, $tmpDir . $file)) {
             $result = file_get_contents($tmpDir . $file);
             Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_DATA_SOURCE_RESULTS_RECEIVED", $file, "File received successfully.", $this->siteId);
         } else {
             Ebay::log(Logger::LOG_LEVEL_ERROR, "EBAY_DATA_SOURCE_RESULTS_ERROR", $tmpDir . $file, "Can't receive file content.", $this->siteId);
         }
     }
     return $result;
 }
コード例 #3
0
ファイル: sftpqueue.php プロジェクト: Satariall/izurit
 protected function sendDataSftp()
 {
     $directory = new \Bitrix\Main\IO\Directory($this->path . "/zip");
     if (!$directory->isExists()) {
         throw new SystemException("Directory" . $this->path . "/zip does not exist! " . __METHOD__);
     }
     $filesToSend = $directory->getChildren();
     if (empty($filesToSend)) {
         return false;
     }
     $sftp = \Bitrix\Sale\TradingPlatform\Ebay\Helper::getSftp($this->siteId);
     $sftp->connect();
     for ($i = 0; $i < count($filesToSend); $i++) {
         $directoryEntry = $filesToSend[$i];
         $localPath = $directoryEntry->getPath();
         if (!$directoryEntry instanceof \Bitrix\Main\IO\File || GetFileExtension($localPath) != "zip") {
             continue;
         }
         $remote = $this->remotePath . "/" . $directoryEntry->getName();
         while (!$this->checkOuterConditions($sftp)) {
             if ($this->timer !== null && !$this->timer->check(15)) {
                 return false;
             }
             sleep(10);
         }
         if ($sftp->uploadFile($localPath, $remote)) {
             $directoryEntry->delete();
             ResultsTable::add(array("FILENAME" => $directoryEntry->getName(), "FEED_TYPE" => $this->feedType, "UPLOAD_TIME" => DateTime::createFromTimestamp(time())));
             Ebay::log(Logger::LOG_LEVEL_INFO, "EBAY_DATA_PROCESSOR_SFTPQUEUE_SEND", $remote, "File sent successfully.", $this->siteId);
         }
     }
     return true;
 }