RemoteDataCenterClientClass.php
2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* @class RemoteDataCenterClientClass
* @brief
* @details
*/
class RemoteDataCenterClientClass
{
public $baseDom = null, $dataCenter = null;
public $baseDomName;
public $baseID = null;
public $ViId = null, $ParamId = null;
protected $client;
public $infoFile = null;
/*
* @brief Constructor
*/
function __construct()
{
$this->baseID = get_class($this);
$this->baseDom = new DomDocument("1.0");
$this->baseDomName = RemoteData.$this->baseID."/base.xml";
// if (!file_exists($this->baseDomName))
// return -1;
// if (!$this->baseDom->load($this->baseDomName))
// return -2;
$this->baseDom->load($this->baseDomName);
date_default_timezone_set('UTC');
try {
$this->client = new SoapClient(DD_WSDL);
}
catch (SoapFault $exception) {
$msg = $exception->faultstring.PHP_EOL;
exit($msg);
}
// return 0;
}
public function param2dd($paramID)
{
$pairs = array(" " => "_","-" => "_","/" => "_","%" => "_","\\" => "_","$" => "_",":" => "_","+" =>"_",
"#" => "_","@" => "_","." => "_", ">" => "_", "<" => "_", "," => "_", ")" => "", "(" => "_");
return strtr($paramID,$pairs);
}
public function setViId($id)
{
$this->ViId = $id;
}
public function setParamId($id)
{
$this->ParamId = $id;
}
public function addViToDD()
{
if (!$this->ViId) return false;
$this->setInfoFile();
//check if VI already added
try {
$res = $this->client->isRemoteViAdded($this->baseID, strtolower($this->ViId));
if (!$res)
{
// call to DD Server to create new VI
$command = 'AddVI '.$this->dataset2dd($this->ViId).' '.$this->ViId.' '.$this->baseID;
system($command, $err);
return ($err == 0);
}
return true;
}
catch (SoapFault $exception) {
// echo $this->client->__getLastRequest();
// echo $this->client->__getLastResponse();
$msg = $exception->faultstring.PHP_EOL;
return false;
}
}
protected function dataset2dd($id){}
public function setInfoFile(){}
public function getParamSize(){}
public function getParamComponents(){}
}
?>