ASNMTAP
view release on metacpan or search on metacpan
applications/custom/sde-supportRequest.pm-orig view on Meta::CPAN
# ----------------------------------------------------------------------------------------------------------
# © Copyright 2003-2011 Alex Peeters [alex.peeters@citap.be]
# ----------------------------------------------------------------------------------------------------------
# 2011/mm/dd, v3.002.003, module sde-supportRequest.pm for ASNMTAP::Asnmtap::Applications::CGI
# ----------------------------------------------------------------------------------------------------------
use strict;
use warnings; # Must be used in test mode only. This reduces a little process speed
#use diagnostics; # Must be used in test mode only. This reduces a lot of process speed
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BEGIN { if ( $ENV{ASNMTAP_PERL5LIB} ) { eval 'use lib ( "$ENV{ASNMTAP_PERL5LIB}" )'; } }
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
use ASNMTAP::Time qw(&get_datetimeSignal);
use ASNMTAP::Asnmtap::Plugins v3.002.003;
use ASNMTAP::Asnmtap::Plugins qw(:PLUGINS);
use ASNMTAP::Asnmtap::Plugins::SOAP qw(&get_soap_request);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
use ASNMTAP::Asnmtap::Applications::CGI v3.002.003;
use ASNMTAP::Asnmtap::Applications::CGI qw(:APPLICATIONS :CGI :DBREADONLY :DBTABLES);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
use SOAP::Lite;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub webserviceSupportRequest {
my ($catalogID, $uKey, $method, $whereClause, $fieldlist, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID, $debug) = @_;
# DATABASE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $CARTO_SERVER = 'crinaeadtbs01';
my $CARTO_DATABASE = 'carto';
my $CARTO_TABLE = 'TestRelationships';
# SOAP - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $tool = 'ASNMTAP';
my $cluster = 'http://itiltest1.smals-mvm.be/ivwse';
my $namespace = 'http://itiltest1.smals-mvm.be/ivwse/';
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my ($UserID, $customer, $source) = ('MonitoringOffice', "$tool MONITORING", 'Alarm');
my %soapService_NS = ('http://schemas.xmlsoap.org/wsdl/mime/' => 'mime',
'http://schemas.xmlsoap.org/wsdl/soap/' => 'soap',
'http://schemas.xmlsoap.org/wsdl/soap11/' => 'soap11',
'http://schemas.xmlsoap.org/soap/encoding/' => 'soapenc',
'http://www.w3.org/2001/XMLSchema' => 's',
'http://schemas.xmlsoap.org/wsdl/' => 'wsdl',
'http://schemas.xmlsoap.org/wsdl/http/' => 'http',
'http://microsoft.com/wsdl/mime/textMatching/' => 'tm',
'http://infravision.com/ivwse' => 's1'
);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub _getEventsData {
my ($catalogID, $uKey, $hash_valueEventsData, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID, $debug) = @_;
my $rv = 1;
my $dbh = DBI->connect("DBI:mysql:$DATABASE:$SERVERNAMEREADONLY:$SERVERPORTREADONLY", "$SERVERUSERREADONLY", "$SERVERPASSREADONLY") or $rv = error_trap_DBI(*STDOUT, "Cannot connect to the database", $debug, $pagedir, $pageset, $htmlTitle, $subTit...
applications/custom/sde-supportRequest.pm-orig view on Meta::CPAN
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub _getSupportRequestData {
my ($serverName, $database, $table, $catalogID, $uKey, $hash_valueSupportRequestData, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID, $debug) = @_;
$$hash_valueSupportRequestData{code} = '?';
$$hash_valueSupportRequestData{slaID} = '?';
$$hash_valueSupportRequestData{impact} = 'High';
$$hash_valueSupportRequestData{invoicedOrg} = '?';
$$hash_valueSupportRequestData{service} = '?';
$$hash_valueSupportRequestData{priority} = 'P01';
my $rv = 1;
my $dbh = DBI->connect("DBI:mysql:$database:$serverName:$SERVERPORTREADONLY", "$SERVERUSERREADONLY", "$SERVERPASSREADONLY") or $rv = error_trap_DBI(*STDOUT, "Cannot connect to the database", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, $ref...
if ($dbh and $rv) {
my $sql = "select SQL_NO_CACHE code, slaID, invoicedOrg, service, impact, priority from $table where catalogID = '$catalogID' and uKey = '$uKey'";
my $sth = $dbh->prepare( $sql ) or $rv = error_trap_DBI(*STDOUT, "Cannot dbh->prepare: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID);
$sth->execute or $rv = error_trap_DBI(*STDOUT, "Cannot sth->execute: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID) if $rv;
if ( $rv ) {
while (my $ref = $sth->fetchrow_hashref()) {
$$hash_valueSupportRequestData{code} = $ref->{code} if ( $ref->{code} );
$$hash_valueSupportRequestData{slaID} = $ref->{slaID} if ( $ref->{slaID} );
$$hash_valueSupportRequestData{impact} = $ref->{impact} if ( $ref->{impact} );
$$hash_valueSupportRequestData{invoicedOrg} = $ref->{invoicedOrg} if ( $ref->{invoicedOrg} );
$$hash_valueSupportRequestData{service} = $ref->{service} if ( $ref->{service} );
$$hash_valueSupportRequestData{priority} = $ref->{priority} if ( $ref->{priority} );
}
$sth->finish() or $rv = error_trap_DBI(*STDOUT, "Cannot sth->finish: $sql", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID);
}
$dbh->disconnect or $rv = error_trap_DBI(*STDOUT, "Sorry, the database was unable to add your entry.", $debug, $pagedir, $pageset, $htmlTitle, $subTitle, $refresh, $onload, $sessionID) if ($dbh and $rv);
}
return $rv;
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub _actionOnSoapResponse {
my ($asnmtapInherited, $som, $arguments) = @_;
my $root = $som->dataof ('/Envelope/Body');
my $WebServiceResults = $root->value;
if ( $asnmtapInherited->getOptionsValue('debug') ) {
use Data::Dumper;
print Dumper ($WebServiceResults), "\n";
}
my $response = $arguments->{method} .'Response';
my $returnCode = ( ( exists $WebServiceResults->{ $response } ) ? ( ( defined $WebServiceResults->{ $response } and $WebServiceResults->{ $response } ne '' ) ? $ERRORS{OK} : $ERRORS{WARNING} ) : $ERRORS{CRITICAL} );
unless ( $returnCode ) {
if ( $arguments->{method} eq 'InsertSupportRequest' ) {
# ...
} else { # $arguments->{method} =~ /^GetSupportRequest(?:List)*$/
if ( exists $WebServiceResults->{$response}->{SupportRequest} ) {
sub processGetSupportRequestResponse {
my ($supportRequest, $arguments, $counter) = @_;
if ( defined $supportRequest->{Number} ) {
my ($header, $data) = ('', '');
if ( defined $arguments->{fieldlist}->{'*'} ) {
while (my ($key, $value) = each %{ $supportRequest } ) {
$header .= '"'. $key .'",' unless ($counter);
$data .= '"'. $value .'",';
}
} else {
foreach my $key (sort keys %{ $arguments->{fieldlist} } ) {
my $value = $arguments->{fieldlist}->{$key};
if ( defined $supportRequest->{$value} ) {
$header .= '"'. $value .'",' unless ($counter);
$data .= '"'. $supportRequest->{$value} .'",';
}
}
}
unless ($counter) {
chop $header;
$header .= "\n";
}
chop $data;
$data .= "\n";
print $header, $data;
$counter++;
}
return ($counter);
}
if ( ref $WebServiceResults->{$response}->{SupportRequest} eq 'ARRAY' ) {
my $counter = 0;
foreach my $supportRequest ( @{$WebServiceResults->{$response}->{SupportRequest}} ) {
$counter = processGetSupportRequestResponse ( $supportRequest, \%$arguments, $counter );
}
} elsif ( exists $WebServiceResults->{$response}->{SupportRequest}->{Number} ) {
processGetSupportRequestResponse ( $WebServiceResults->{$response}->{SupportRequest}, \%$arguments, 0 );
}
}
}
}
$asnmtapInherited->pluginValues ( { stateValue => $returnCode, alert => $arguments->{method} ."\@". $arguments->{FQDN} .": ". $STATE{$returnCode} }, $TYPE{APPEND} );
return ($returnCode);
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $objectPlugins = ASNMTAP::Asnmtap::Plugins->new (
_programName => 'sde-supportRequest.pm',
_programDescription => 'SDE Support Request',
_programVersion => '1.0',
_timeout => 30,
_plugins => 0,
_debug => 0);
no warnings 'deprecated';
$objectPlugins->{_getOptionsValues}->{debug} = ($debug eq 'T') ? 1 : (($debug eq 'L') ? 2 : (($debug eq 'M') ? 3 : (($debug eq 'A') ? 4 : ((($debug eq 'S') ? 5 : 0)))));
use warnings;
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
my $succeeded = 0;
my %methods;
for ( $method ) {
/^InsertSupportRequest$/ && do {
%methods = (
"$method" => {
parameters => [
SOAP::Data->new(name => 'customer', type => 's:string', value => $customer, attr => {}),
SOAP::Data->new(name => 'UserID', type => 's:string', value => $UserID, attr => {}),
SOAP::Data->new(name => 'service', type => 's:string', attr => {}),
SOAP::Data->new(name => 'ci', type => 's:string', attr => {}),
SOAP::Data->new(name => 'Ci_Type', type => 's:int', attr => {}),
SOAP::Data->new(name => 'description', type => 's:string', attr => {}),
SOAP::Data->new(name => 'informationUpdate', type => 's:string', attr => {}),
SOAP::Data->new(name => 'source', type => 's:string', value => $source, attr => {}),
SOAP::Data->new(name => 'category', type => 's:string', attr => {}),
SOAP::Data->new(name => 'impact', type => 's:string', attr => {}),
SOAP::Data->new(name => 'group', type => 's:string', attr => {}),
SOAP::Data->new(name => 'OutageStart', type => 's:dateTime', attr => {})
], # end parameters
}, # end InsertSupportRequest
); # end my %methods
last; };
/^GetSupportRequest$/ && do {
unless ( defined $whereClause ) {
$objectPlugins->pluginValues ( { error => 'GetSupportRequest: whereClause NOT DEFINED' }, $TYPE{APPEND} );
$succeeded = error_SupportRequest(*STDOUT, $objectPlugins->pluginValue ('error'), $debug, $pagedir, $pageset, $htmlTitle, $subTitle, -2, $onload, $sessionID);
return ( $succeeded, $objectPlugins->pluginValue ( 'alert' ), $objectPlugins->pluginValue ( 'error' ) );
}
%methods = (
"$method" => {
( run in 0.837 second using v1.01-cache-2.11-cpan-39bf76dae61 )