1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
agent.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Sale\TradingPlatform\Ebay
;
4
5
use
Bitrix\Main\ArgumentNullException
;
6
use
Bitrix\Sale\TradingPlatform\Timer
;
7
use
Bitrix\Sale\TradingPlatform\Logger
;
8
use
Bitrix\Main\ArgumentOutOfRangeException
;
9
use
Bitrix\Sale\TradingPlatform\Ebay\Feed\Manager
;
10
use
Bitrix\Sale\TradingPlatform\TimeIsOverException
;
11
17
class
Agent
18
{
29
30
public
static
function
start
($feedType,
$siteId
, $startPosition=
""
, $once =
false
)
31
{
32
if
(empty(
$siteId
))
33
throw
new
ArgumentNullException
(
'siteId'
);
34
35
$siteId
=
\EscapePHPString
(
$siteId
);
36
37
if
(!in_array($feedType,
array
(
"ORDER"
,
"PRODUCT"
,
"INVENTORY"
,
"IMAGE"
,
"PROCESS_RESULT"
,
"RESULTS"
,
"ORDER_ACK"
)))
38
throw
new
ArgumentOutOfRangeException
(
'feedType'
);
39
40
$result
=
""
;
41
$timeLimit = 300;
42
Ebay::log
(
Logger::LOG_LEVEL_DEBUG
,
"EBAY_AGENT_FEED_STARTED"
, $feedType,
"Feed: "
.$feedType.
", site: "
.
$siteId
.
", start position: "
.$startPosition,
$siteId
);
43
44
try
45
{
46
if
(in_array($feedType,
array
(
"ORDER"
,
"PROCESS_RESULT"
,
"RESULTS"
)))
47
{
48
$ebayFeed = Manager::createFeed($feedType,
$siteId
, $timeLimit);
49
$ebayFeed->processData($startPosition);
50
}
51
else
52
{
53
$timer =
new
Timer
($timeLimit);
54
$queue = Manager::createSftpQueue($feedType,
$siteId
, $timer);
55
$queue->sendData();
56
}
57
}
58
catch
(
TimeIsOverException
$e)
59
{
60
$result
=
'Bitrix\Sale\TradingPlatform\Ebay\Agent::start("'
.$feedType.
'","'
.
$siteId
.
'","'
.$e->
getEndPosition
().
'",, '
.($once ?
'true'
:
'false'
).
');'
;
61
}
62
catch
(\
Exception
$e)
63
{
64
Ebay::log
(
Logger::LOG_LEVEL_ERROR
,
"EBAY_FEED_ERROR"
, $feedType, $e->getMessage(),
$siteId
);
65
}
66
67
if
(
$result
==
''
&& !$once)
68
$result
=
'Bitrix\Sale\TradingPlatform\Ebay\Agent::start("'
.$feedType.
'","'
.
$siteId
.
'");'
;
69
70
return
$result
;
71
}
72
82
public
static
function
add
($feedType,
$siteId
, $interval, $once =
false
)
83
{
84
if
($interval <= 0)
85
return
0;
86
87
if
(empty(
$siteId
))
88
throw
new
ArgumentNullException
(
'siteId'
);
89
90
$siteId
=
\EscapePHPString
(
$siteId
);
91
92
if
($feedType ==
"ORDER"
)
93
$sort = 50;
94
elseif
($feedType ==
"PRODUCT"
|| $feedType ==
"PROCESS_RESULT"
|| $feedType ==
"RESULTS"
)
95
$sort = 100;
96
elseif
($feedType ==
"INVENTORY"
|| $feedType ==
"IMAGE"
|| $feedType ==
"ORDER_ACK"
)
97
$sort = 150;
98
else
99
throw
new
ArgumentOutOfRangeException
(
'feedType'
);
100
101
$intervalSeconds = $interval*60;
102
$timeToStart = ConvertTimeStamp(strtotime(date(
'Y-m-d H:i:s'
, time() + $intervalSeconds)),
'FULL'
);
103
104
$result
= \CAgent::AddAgent(
105
self::createAgentNameForAdd($feedType,
$siteId
, $once),
106
'sale'
,
107
"N"
,
108
$interval*60,
109
$timeToStart,
110
"Y"
,
111
$timeToStart,
112
$sort);
113
114
Ebay::log
(
Logger::LOG_LEVEL_DEBUG
,
"EBAY_AGENT_ADDING_RESULT"
, $feedType,
"Feed: "
.$feedType.
", site: "
.
$siteId
.
", interval: "
.$interval.
" once: "
.($once ?
'true'
:
'false'
).
" agentId: '"
.
$result
.
"'"
,
$siteId
);
115
116
return
$result
;
117
}
118
119
protected
static
function
createAgentNameForAdd
($feedType,
$siteId
, $once =
false
)
120
{
121
return
'Bitrix\Sale\TradingPlatform\Ebay\Agent::start("'
.$feedType.
'","'
.
$siteId
.
'", "", '
.($once ?
'true'
:
'false'
).
');'
;
122
}
123
124
131
public
static
function
update
(
$siteId
,
array
$feedSettings)
132
{
133
foreach
($feedSettings as $feedType => $feedParams)
134
{
135
$interval = intval($feedParams[
"INTERVAL"
]);
136
137
$dbRes
= \CAgent::GetList(
138
array
(),
139
array
(
140
'NAME'
=> self::createAgentNameForAdd($feedType,
$siteId
)
141
)
142
);
143
144
if
($agent =
$dbRes
->Fetch())
145
{
146
if
($interval <= 0)
147
{
148
\CAgent::Delete($agent[
"ID"
]);
149
$feedSettings[$feedType][
"AGENT_ID"
] = 0;
150
continue
;
151
}
152
153
\CAgent::Update(
154
$agent[
"ID"
],
155
array
(
'AGENT_INTERVAL'
=> $interval*60)
156
);
157
158
$feedSettings[$feedType][
"AGENT_ID"
] = $agent[
"ID"
];
159
}
160
else
161
{
162
$feedSettings[$feedType][
"AGENT_ID"
] =
self::add
($feedType,
$siteId
, $feedParams[
"INTERVAL"
]);
163
}
164
}
165
166
return
$feedSettings;
167
}
168
}
Bitrix\Main\ArgumentNullException
Определения
ArgumentNullException.php:9
Bitrix\Main\ArgumentOutOfRangeException
Определения
ArgumentOutOfRangeException.php:9
Bitrix\Main\Diag\Logger
Определения
logger.php:18
Bitrix\Sale\TradingPlatform\Ebay\Agent
Определения
agent.php:18
Bitrix\Sale\TradingPlatform\Ebay\Agent\add
static add($feedType, $siteId, $interval, $once=false)
Определения
agent.php:82
Bitrix\Sale\TradingPlatform\Ebay\Agent\start
static start($feedType, $siteId, $startPosition="", $once=false)
Определения
agent.php:30
Bitrix\Sale\TradingPlatform\Ebay\Agent\createAgentNameForAdd
static createAgentNameForAdd($feedType, $siteId, $once=false)
Определения
agent.php:119
Bitrix\Sale\TradingPlatform\Ebay\Agent\update
static update($siteId, array $feedSettings)
Определения
agent.php:131
Bitrix\Sale\TradingPlatform\Ebay\Ebay\log
static log($level, $type, $itemId, $description, $siteId)
Определения
ebay.php:161
Bitrix\Sale\TradingPlatform\Ebay\Feed\Manager
Определения
manager.php:11
Bitrix\Sale\TradingPlatform\Logger\LOG_LEVEL_DEBUG
const LOG_LEVEL_DEBUG
Определения
logger.php:17
Bitrix\Sale\TradingPlatform\Logger\LOG_LEVEL_ERROR
const LOG_LEVEL_ERROR
Определения
logger.php:15
Bitrix\Sale\TradingPlatform\TimeIsOverException
Определения
timeisoverexception.php:13
Bitrix\Sale\TradingPlatform\TimeIsOverException\getEndPosition
getEndPosition()
Определения
timeisoverexception.php:31
Bitrix\Sale\TradingPlatform\Timer
Определения
timer.php:10
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$result
$result
Определения
get_property_values.php:14
$siteId
$siteId
Определения
ajax.php:8
EscapePHPString
EscapePHPString($str, $encloser='"')
Определения
tools.php:4917
Bitrix\Main\DI\Exception
Определения
circulardependencyexception.php:3
Bitrix\Sale\TradingPlatform\Ebay
Определения
agent.php:3
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$dbRes
$dbRes
Определения
yandex_detail.php:168
bitrix
modules
sale
lib
tradingplatform
ebay
agent.php
Создано системой
1.14.0