From e5402b28c9a3f22030f40a4fa179a3bcf6480b7c Mon Sep 17 00:00:00 2001 From: "jaysmith6811@gmail.com" Date: Tue, 25 Sep 2012 15:50:03 +0000 Subject: Execution info object, getExecutionInfo method --- library/SSRS/Object/ExecutionInfo.php | 32 +++++++++++++--- library/SSRS/Object/ExecutionParameters.php | 9 +++-- library/SSRS/Object/Properties.php | 58 +++++++++++++++++++++++++++++ library/SSRS/Object/Report.php | 14 ------- library/SSRS/Report.php | 32 ++++++++++++++-- library/SSRS/Soap/Exception.php | 14 ++++++- library/SSRS/Soap/NTLM.php | 2 +- samples/LoadReportWithParameters.php | 19 +++++----- 8 files changed, 141 insertions(+), 39 deletions(-) create mode 100644 library/SSRS/Object/Properties.php delete mode 100755 library/SSRS/Object/Report.php diff --git a/library/SSRS/Object/ExecutionInfo.php b/library/SSRS/Object/ExecutionInfo.php index 55998fd..97c74f9 100755 --- a/library/SSRS/Object/ExecutionInfo.php +++ b/library/SSRS/Object/ExecutionInfo.php @@ -7,23 +7,43 @@ */ class SSRS_Object_ExecutionInfo extends SSRS_Object_Abstract { - public function setExecutionInfo(stdClass $info) { - $this->setData($info); + /** + * Copy of self for backwards compatibility + * + * @var SSRS_Object_ExecutionInfo + */ + public $executionInfo; + + public function __construct(stdClass $info) { + $this->setData($info->executionInfo); + $this->executionInfo = $this; } public function setParameters(stdClass $params) { + return $this->setReportParameters($params); + } + + public function setReportParameters(stdClass $params) { $parameters = array(); foreach ($params->ReportParameter AS $reportParam) { - $parameter = new SSRS_Object_ReportParameter($reportParam->Name, null); + $parameter = new SSRS_Object_ReportParameter($reportParam->Name, isset($reportParam->Value) ? $reportParam->Value : null); $parameter->setData($reportParam); $parameters[] = $parameter; } - $execParams = new SSRS_Object_ExecutionParameters(); - $execParams->setParameters($parameters); + $this->data['ReportParameters'] = $parameters; + return $this; + } - $this->data['Parameters'] = $execParams; + /** + * Returns all report parameters in an array + * + * @return array parameters + * + */ + public function getReportParameters() { + return $this->data['ReportParameters']; } } diff --git a/library/SSRS/Object/ExecutionParameters.php b/library/SSRS/Object/ExecutionParameters.php index 95f4dee..bf3b819 100755 --- a/library/SSRS/Object/ExecutionParameters.php +++ b/library/SSRS/Object/ExecutionParameters.php @@ -23,10 +23,13 @@ class SSRS_Object_ExecutionParameters extends SSRS_Object_ArrayIterator { foreach ($parameters AS $key => $parameter) { if (($parameter instanceof SSRS_Object_ReportParameter) === false) { - $parameter = new SSRS_Object_ReportParameter($key, $parameter); + $values = (array) $parameter; + foreach ($values AS $value) { + $this->data['Parameters'][] = new SSRS_Object_ReportParameter($key, $value); + } + } else { + $this->data['Parameters'][] = $parameter; } - - $this->data['Parameters'][] = $parameter; } } diff --git a/library/SSRS/Object/Properties.php b/library/SSRS/Object/Properties.php new file mode 100644 index 0000000..6765450 --- /dev/null +++ b/library/SSRS/Object/Properties.php @@ -0,0 +1,58 @@ +addProperties($properties); + } + + public function __get($name){ + return $this->getProperty($name); + } + + /** + * + * @param array $properties + */ + public function addProperties(array $properties) { + foreach ($properties AS $key => $value) { + if (is_object($value) && isset($value->Name)) { + $key = $value->Name; + $value = isset($value->Value)? $value->Value : null; + } + + $this->addProperty($key, $value); + } + } + + /** + * + * @param string $key + * @param mixed $value + * @return \SSRS_Object_Properties + */ + public function addProperty($key, $value) { + $this->_properties[$key] = $value; + return $this; + } + + /** + * + * @return array + */ + public function getProperties() { + return $this->_properties; + } + + /** + * + * @param string $key + * @return mixed + */ + public function getProperty($key) { + return array_key_exists($key, $this->_properties) ? $this->_properties[$key] : null; + } + +} \ No newline at end of file diff --git a/library/SSRS/Object/Report.php b/library/SSRS/Object/Report.php deleted file mode 100755 index 6733e28..0000000 --- a/library/SSRS/Object/Report.php +++ /dev/null @@ -1,14 +0,0 @@ -data['executionInfo'] = new SSRS_Object_ExecutionInfo($info); - } - -} diff --git a/library/SSRS/Report.php b/library/SSRS/Report.php index 83f7ca3..97a3362 100755 --- a/library/SSRS/Report.php +++ b/library/SSRS/Report.php @@ -21,7 +21,6 @@ require_once('Object/ExecutionInfo.php'); require_once('Object/Extensions.php'); require_once('Object/Extension.php'); require_once('Object/ReportParameter.php'); -require_once('Object/Report.php'); require_once('Object/ReportOutput.php'); require_once('Report/Exception.php'); @@ -205,6 +204,21 @@ class SSRS_Report { } /** + * Returns item properties + * + * @param string $path + * @return \SSRS_Object_Properties + */ + public function getProperties($itemPath) { + $params = array( + 'ItemPath' => $itemPath, + ); + + $result = $this->getSoapService()->GetProperties($params); + return new SSRS_Object_Properties($result->Values->Property); + } + + /** * Returns item definition details in a XML string. * Used to backup report definitions into a XML based RDL file. * @@ -233,7 +247,7 @@ class SSRS_Report { * * @param string $Report * @param string $HistoryId - * @return SSRS_Object_Report + * @return SSRS_Object_ExecutionInfo */ public function loadReport($Report, $HistoryId = null) { $params = array( @@ -242,7 +256,17 @@ class SSRS_Report { ); $result = $this->getSoapExecution()->LoadReport($params); - return new SSRS_Object_Report($result); + return new SSRS_Object_ExecutionInfo($result); + } + + /** + * Get current execution info + * + * @return \SSRS_Object_ExecutionInfo + */ + public function getExecutionInfo(){ + $result = $this->getSoapExecution()->GetExecutionInfo2(); + return new SSRS_Object_ExecutionInfo($result); } /** @@ -273,7 +297,7 @@ class SSRS_Report { * @param string $PaginationMode * @return SSRS_Object_ReportOutput */ - public function render($format, $deviceInfo = array(), $PaginationMode='Estimate') { + public function render($format, $deviceInfo = array(), $PaginationMode = 'Estimate') { $this->checkSessionId(); $deviceInfo = array('DeviceInfo' => array_merge(array('Toolbar' => 'false'), $deviceInfo)); diff --git a/library/SSRS/Soap/Exception.php b/library/SSRS/Soap/Exception.php index c2c0977..9d0902a 100755 --- a/library/SSRS/Soap/Exception.php +++ b/library/SSRS/Soap/Exception.php @@ -1,3 +1,15 @@ httpCode = $code; + $this->response = $response; + + parent::__construct($message, $code); + } + +} \ No newline at end of file diff --git a/library/SSRS/Soap/NTLM.php b/library/SSRS/Soap/NTLM.php index 9132eae..0562c6d 100755 --- a/library/SSRS/Soap/NTLM.php +++ b/library/SSRS/Soap/NTLM.php @@ -154,7 +154,7 @@ class SSRS_Soap_NTLM extends SoapClient { $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE); if ($httpCode !== 200) { - throw new SSRS_Soap_Exception('HTTP error: ' . $httpCode . ' ' . $response, $httpCode); + throw new SSRS_Soap_Exception('HTTP error: ' . $httpCode . ' ' . $response, $httpCode, $response); } curl_close($handle); diff --git a/samples/LoadReportWithParameters.php b/samples/LoadReportWithParameters.php index 62728b9..a99c582 100755 --- a/samples/LoadReportWithParameters.php +++ b/samples/LoadReportWithParameters.php @@ -1,19 +1,18 @@ 'testing', - 'password' => 'password' + 'username' => 'CaymanUnreg', + 'password' => 'Gottex2011' ); -$ssrs = new SSRS_Report('http://localhost/reportserver/', $options); -$result = $ssrs->loadReport('/Reports/Reference_Report'); - +$ssrs = new SSRS_Report('http://212.203.112.85/reportserver/', $options); +$result = $ssrs->loadReport('/Off Shore/Cayman Weekly Risk'); +Zend_Debug::dump($result); +//die(); $reportParameters = array( - 'key1' => 'value1', - 'key2' => 'value2', -); + 'managedaccount' => '1' + ); $parameters = new SSRS_Object_ExecutionParameters($reportParameters); -- cgit v1.1