- Модуль: sale
- Путь к файлу: ~/bitrix/modules/sale/lib/tradingplatform/ebay/feed/data/processors/sftpqueue.php
- Класс: BitrixSaleTradingPlatformEbayFeedDataProcessorsSftpQueue
- Вызов: SftpQueue::sendDataSftp
protected function sendDataSftp()
{
$directory = new BitrixMainIODirectory($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 = BitrixSaleTradingPlatformEbayHelper::getSftp($this->siteId);
if(!$sftp)
return false;
$sftp->connect();
for($i = 0; $i < count($filesToSend); $i++)
{
$directoryEntry = $filesToSend[$i];
$localPath = $directoryEntry->getPath();
if((!($directoryEntry instanceof BitrixMainIOFile)) || 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;
}