Example #1
0
function getServiceFields($serviceName, $app)
{
    try {
        $clientObj = new CherwellSoap('api.wsdl');
        $clientObj->login(getenv('user_id'), getenv('password'));
        $title_array = explode(" ", $serviceName);
        $first_word = $title_array[0];
        $response = $clientObj->getQueryResultsUsingPromptInfo("Team", getenv('netops_team_scope_owner_id'), getenv('services_prompt_stored_query_def'), getenv('services_bus_ob_id'), '<Inputs><Input InputId="Prompt">%' . $first_word . '%</Input></Inputs>');
        $xml = simplexml_load_string($response);
        $title = $xml->Record->TitleText;
        $bodyText = $xml->Record->BodyText;
        $response = $clientObj->queryByFieldValue('KnowledgeArticle', 'Service', $serviceName);
        var_dump($response);
        $recId = $xml->Record['RecId'];
        $response = $clientObj->getBusinessObject('Service', $recId);
        $xml = simplexml_load_string($response);
        $index = 0;
        $fields = array();
        foreach ($xml->FieldList->Field as $field) {
            $fields[$index]['name'] = $field['Name'];
            $fields[$index]['value'] = $field;
            $index++;
        }
        $app->view()->setData(array('base' => $app->base, 'title' => $title, 'bodyText' => $bodyText, 'fields' => $fields));
        $app->render("fields.html");
    } catch (Exception $e) {
        var_dump($response);
    }
}
Example #2
0
function getListOfArticles($app)
{
    $response = '';
    try {
        $clientObj = new CherwellSoap('api.wsdl');
        $clientObj->login(getenv('user_id'), getenv('password'));
        $filter = getHttpQueryParams($app);
        if ($filter['searchBy'] === 'queryByPrompt' && !empty($filter['prompt'])) {
            $response = $clientObj->getQueryResultsUsingPromptInfo("Team", getenv('keyword_scope_owner'), getenv('keyword_stored_query_id_def'), getenv('keyword_bus_ob_id'), '<Inputs><Input InputId="Prompt">%' . $filter['prompt'] . '%</Input></Inputs>');
            $xmlk = simplexml_load_string($response);
            if (count($xmlk->xpath('Record')) == 0) {
                $response = '';
            }
        } else {
            $response = $clientObj->queryByFieldValue('KnowledgeArticle', $filter['queryName'], $filter['prompt']);
        }
    } catch (Exception $e) {
        var_dump($e->getMessage());
    }
    if (!empty($response)) {
        $xml = simplexml_load_string($response);
        $pageNumber = getPageNumber($app, $xml);
        $ids = getRecordsForDisplay($xml, $pageNumber);
        $index = 0;
        $links = array();
        foreach ($ids as $record) {
            if ($filter['searchBy'] === 'queryByPrompt' && !empty($filter['prompt'])) {
                $response = $clientObj->getBusinessObject('KnowledgeArticle', $record['RecId']);
            } else {
                $response = $clientObj->getBusinessObjectByPublicId('KnowledgeArticle', $record);
            }
            $xml1 = simplexml_load_string($response);
            $links[$index]['title'] = $xml1->FieldList->Field[19];
            $links[$index]['id'] = $xml1->FieldList->Field[13];
            $links[$index]['recId'] = $xml1->FieldList->Field[0];
            $index++;
        }
    } else {
        $pageNumber = 1;
        $links = array();
    }
    $app->view()->setData(array('base' => $app->base, 'currentPage' => $pageNumber, 'links' => $links, 'filter' => $filter));
    $app->render("articles.html");
}
Example #3
0
<?php

// GET page for specific knowledge article
$app->get('/fields/:id', function ($id) use($app) {
    try {
        $clientObj = new CherwellSoap('api.wsdl');
        $clientObj->login(getenv('user_id'), getenv('password'));
        $response = $clientObj->getBusinessObjectByPublicId('KnowledgeArticle', $id);
        $xml = simplexml_load_string($response);
        $title = "Knowledge Article Fields";
        $index = 0;
        $fields = array();
        foreach ($xml->FieldList->Field as $field) {
            $fields[$index]['name'] = $field['Name'];
            $fields[$index]['value'] = $field;
            $index++;
        }
        $app->view()->setData(array('base' => $app->base, 'title' => $title, 'fields' => $fields));
        $app->render("fields.html");
    } catch (Exception $e) {
        $app->redirect('/', 301);
    }
});
Example #4
0
                $index++;
            }
        } else {
            $links = array();
        }
        $app->view()->setData(array('title' => 'Available Services', 'base' => $app->base, 'links' => $links));
        $app->render("portfolio.html");
    } catch (Exception $e) {
        var_dump($e->getMessage());
        //$app->redirect('/', 301);
    }
});
// Main index list for Services
$app->get('/portfolios', function () use($app) {
    try {
        $clientObj = new CherwellSoap('api.wsdl');
        $clientObj->login(getenv('user_id'), getenv('password'));
        $response = $clientObj->getQueryResults("Team", getenv('netops_team_scope_owner_id'), getenv('list_stored_query_def_id'), getenv('service_portfolio_bus_ob_id'));
        $xmlk = simplexml_load_string($response);
        if (count($xmlk->xpath('Record')) == 0) {
            $response = '';
        }
    } catch (Exception $e) {
        var_dump($e->getMessage());
    }
    if (!empty($response)) {
        $xml = simplexml_load_string($response);
        $index = 0;
        $links = array();
        foreach ($xml->Record as $record) {
            $response = $clientObj->getBusinessObject('Service Portfolio Category', $record['RecId']);
Example #5
0
 public function testCherwellFetchPerformance()
 {
     // Arrange
     $clientObj = new CherwellSoap('api.wsdl');
     $clientObj->login(getenv('user_id'), getenv('password'));
     // The GetServiceInfo api function will only work if there is a valid login session
     // Use it for a first order performance test
     $t = microtime(true);
     $i = 0;
     while ($i < 1000) {
         $response = $clientObj->client->GetServiceInfo();
         ++$i;
     }
     $response = $clientObj->getLastError();
     // Assert
     $this->assertEquals(true, empty($response));
     var_dump((microtime(true) - $t) / 1000);
 }