131 lines
4.7 KiB
PHP
131 lines
4.7 KiB
PHP
<?php
|
|
// --------------------------------------------------------------------------- //
|
|
// monitor-events.php
|
|
// --------------------------------------------------------------------------- //
|
|
require_once '../../config/prepend.php';
|
|
require_once 'user/permissions.php';
|
|
require_once 'user/override.php';
|
|
require_once 'scoresws/scoresws.php';
|
|
require_once 'dbbootstrap.php';
|
|
setDbConn('giant');
|
|
|
|
header('Content-Type: text/html; charset=utf-8');
|
|
|
|
define( 'NDEBUG', '1');
|
|
define('VERSION', '1.0');
|
|
|
|
// client pour scoresws_identite
|
|
$client =
|
|
new SoapClient(null,
|
|
array('trace' => 1,
|
|
'soap_version' => SOAP_1_1,
|
|
'location' => WEBSERVICE_URL,
|
|
'uri' => WEBSERVICE_URI,
|
|
'login' => 'sbeaugrand',
|
|
'password' => 'seb2010'));
|
|
|
|
$gServiceHeader = new StdClass;
|
|
$gServiceHeader->ConsumerId = 1234;
|
|
$gServiceHeader->Provider = new StdClass;
|
|
$gServiceHeader->Provider->ProviderId = 2345;
|
|
$gServiceHeader->Provider->CountryCode = 'FR';
|
|
$gServiceHeader->TimeStamp = date('Y-m-d\TH:i:s');
|
|
$gServiceHeader->TestIndication = true;
|
|
|
|
if (NDEBUG) {
|
|
$soap_header =
|
|
new SoapHeader('http://extranet.devlocal.com/services/'.
|
|
'schema/services/shared/1.0', 'ServiceHeader',
|
|
$gServiceHeader);
|
|
$soap_client =
|
|
new SoapClient('http://extranet.devlocal.com/services/'.
|
|
'wsdl/monitor-events-service-1.0.wsdl',
|
|
array('soap_version' => SOAP_1_1,
|
|
'trace' => true));
|
|
$soap_client->__setSoapHeaders($soap_header);
|
|
}
|
|
|
|
$date = date('Y-m-d');
|
|
if (isset($_SERVER['argc']) == true && $_SERVER['argc'] > 1) {
|
|
$params = array('providerOrderId');
|
|
$argv = $_SERVER['argv'];
|
|
for ($i = 1; $i < $_SERVER['argc']; ++$i) {
|
|
list($label, $valeur) = explode('=', $argv[$i]);
|
|
$var = lcfirst($label);
|
|
if (in_array($var, $params) == false) {
|
|
print 'attention: parametre non reconnu '.$var."\n";
|
|
continue;
|
|
}
|
|
$$var = $valeur;
|
|
}
|
|
if (isset($providerOrderId) == false) {
|
|
print 'usage: php '.$argv[0]." ProviderOrderId=<n>\n";
|
|
exit;
|
|
}
|
|
$monitors = Doctrine_Query::create()
|
|
->from('Monitors')
|
|
->where('ProviderOrderId = ?', $providerOrderId)
|
|
->fetchArray();
|
|
} else {
|
|
$monitors = Doctrine_Query::create()
|
|
->from('Monitors')
|
|
->fetchArray();
|
|
}
|
|
$i = 0;
|
|
foreach ($monitors as $m) {
|
|
if ($date < $m['ActualStartDate'] ||
|
|
$date > $m['ActualEndDate']) {
|
|
continue;
|
|
}
|
|
|
|
$event = new StdClass;
|
|
$event->Date = $date;
|
|
$event->EventCode = 'GENERAL.NEWS';
|
|
//$event->ProviderEventCode = ; // A developper sur demande
|
|
$event->Source = 'Moi';
|
|
$event->Description = 'Coucou';
|
|
//$event->ParameterizedDescription = ;
|
|
//$event->FreeText = ;
|
|
//$event->Value = ;
|
|
//$event->EventId = ;
|
|
//$event->CorrelationEventId = ;
|
|
$company = new StdClass;
|
|
$company->CompanyId = $m['CompanyId'];
|
|
$company->CompanyName = $m['CompanyName'];
|
|
$company->Event = $event;
|
|
$monitor_event1 = new StdClass;
|
|
$monitor_event1->ProviderEventId = ++$i;
|
|
$monitor_event1->ProviderOrderId = $m['ProviderOrderId'];
|
|
$monitor_event1->Company = $company;
|
|
$monitor_event2 = new StdClass;
|
|
$monitor_event2->ProviderEventId = ++$i;
|
|
$monitor_event2->ProviderOrderId = $m['ProviderOrderId'];
|
|
$monitor_event2->Company = $company;
|
|
$monitor_events = new StdClass;
|
|
$monitor_events->MonitoringEvent = array($monitor_event1, $monitor_event2);
|
|
$o = new StdClass;
|
|
$o->NumberOfEvents = 2;
|
|
$o->MonitoringEvents = $monitor_events;
|
|
$fonction = 'SignalMonitoringEvents';
|
|
|
|
print '<pre>';
|
|
if (NDEBUG) {
|
|
print_r($soap_header);
|
|
}
|
|
print '<br/>';
|
|
print_r($o);
|
|
print '<br/>';
|
|
if (NDEBUG) {
|
|
print_r($soap_client->__call($fonction, array($o)));
|
|
//print '<br/>';
|
|
//print 'Requete: '.htmlspecialchars($soap_client->__getLastRequest());
|
|
//print '<br/>';
|
|
//print 'Reponse: '.htmlspecialchars($soap_client->__getLastResponse());
|
|
} else {
|
|
require_once 'monitor-events/v1/index.php';
|
|
print_r(call_user_func($fonction, $o));
|
|
}
|
|
print "</pre>";
|
|
}
|
|
?>
|