|
- #!/usr/bin/perl
- #
-
- require '/usr/local/majormin/libUTILSgeneral.pl';
- require '/usr/local/majormin/web-lib.pl';
- #require './scheduler.pl';
- if ($ARGV[0] eq "asterisk_running"){
- # my %hash_call;
- # $hash_call{'mode'}= $ARGV[0];
- # $hash_call{'from'}= $ARGV[1];
- # $hash_call{'call_id'}= $ARGV[2];
- # $hash_call{'ntel'}=$ARGV[3];
- # $hash_call{'ackid'}=$ARGV[4];
- # $hash_call{'text_message'}=$ARGV[5];
- # $hash_call{'retry_message'}=$ARGV[6];
- # $hash_call{'timeout'}=$ARGV[7];
- # $hash_call{'retry'}=$ARGV[8];
- # $hash_call{'notification_send'}=$ARGV[9];
- # $hash_call{'notification_to'}=$ARGV[10];
- # $hash_call{'notification_bcc'}=$ARGV[11];
- # $hash_call{'tmpdir'}=$ARGV[13];
- # $hash_call{'status'}=$ARGV[12];
- # $hash_call{'fromemail'}=$ARGV[14];
- # $hash_call{'first_action'}=$ARGV[15];
- # ($sec,$min) = localtime();
- # $hash_call{'last_action'} = ($min*60)+$sec;
- # &deleteRecordXML("/opt/api_project_python/runningCalls.xml", "call_id", $hash_call{'call_id'});
- # &addRecordXML(\%hash_call, "/opt/api_project_python/runningCalls.xml", "/opt/api_project_python/runningCallsTmpl.xml", "call");
- };
- if ($ARGV[0] eq "asterisk_terminated"){
- my %hash_call;
- $hash_call{'mode'}= $ARGV[0];
- $hash_call{'from'}= $ARGV[1];
- $hash_call{'call_id'}= $ARGV[2];
- $hash_call{'ntel'}=$ARGV[3];
- $hash_call{'ackid'}=$ARGV[4];
- $hash_call{'text_message'}=$ARGV[5];
- $hash_call{'retry_message'}=$ARGV[6];
- $hash_call{'timeout'}=$ARGV[7];
- $hash_call{'retry'}=$ARGV[8];
- $hash_call{'notification_send'}=$ARGV[9];
- $hash_call{'notification_to'}=$ARGV[10];
- $hash_call{'notification_bcc'}=$ARGV[11];
- $hash_call{'status'}=$ARGV[12];
- $hash_call{'tmpdir'}=$ARGV[13];
- $hash_call{'fromemail'}=$ARGV[14];
- $hash_call{'first_action'}=$ARGV[15];
- ($sec,$min) = localtime();
- $hash_call{'last_action'} = ($min*60)+$sec;
- &deleteRecordXML("/opt/api_project_python/runningCalls.xml", "call_id", $hash_call{'call_id'});
- &addRecordXML(\%hash_call, "/opt/api_project_python/runningCalls.xml", "/opt/api_project_python/runningCallsTmpl.xml", "call");
-
- };
- if ($ARGV[0] eq "call_id"){
- $call_id = $ARGV[1];
- my @call = &getRecordXML("/opt/api_project_python/runningCalls.xml", "call", "call_id", $call_id);
- if (!$call[0]){
- @call = &getRecordXML("/opt/api_project_python/terminatedCalls.xml", "call", "call_id", $call_id);
-
- }
- my $call_id = &getFieldValue($call[0], "call_id");
- my $status = &getFieldValue($call[0], "status");
- my $ntel = &getFieldValue($call[0], "ntel");
- my $ackid = &getFieldValue($call[0], "ackid");
- $response = $call_id."|".$status."|".$status."|".$ntel."|".$ackid;
- print $response;
- };
- if ($ARGV[0] eq "voicegateway"){
- my %hash_call;
- $hash_call{'mode'}= $ARGV[0];
- $hash_call{'from'}= $ARGV[1];
- $hash_call{'call_id'}= $ARGV[2];
- $hash_call{'ntel'}=$ARGV[3];
- $hash_call{'ackid'}=$ARGV[4];
- $hash_call{'text_message'}=$ARGV[5];
- $hash_call{'retry_message'}=$ARGV[6];
- $hash_call{'timeout'}=$ARGV[7];
- $hash_call{'retry'}=$ARGV[8];
- $hash_call{'notification_send'}=$ARGV[9];
- $hash_call{'notification_to'}=$ARGV[10];
- $hash_call{'notification_bcc'}=$ARGV[11];
- $hash_call{'tmpdir'}=$ARGV[13];
- $hash_call{'status'}=$ARGV[12];
- $hash_call{'fromemail'}=$ARGV[14];
- $hash_call{'hw_id'}=$ARGV[15];
- # inserisco il nuovo record con i parametri della chiamata
- &addRecordXML(\%hash_call, "/opt/api_project_python/runningCalls.xml", "/opt/api_project_python/runningCallsTmpl.xml", "call");
- # leggo lo stato dello scheduler
- # se lo scheduler è già attivo (1), non faccio niente, se non è attivo (0) avvia lo scheduler
- $pidOfScheduler = `ps aux | grep "scheduler.pl" | grep -v "grep" | awk '{print $2}'`;
- if (!$pidOfScheduler){
-
- #$scheduler = &scheduler();
- $scheduler = `/usr/bin/perl /opt/api_project_python/scheduler.pl`;
- }
- print "Success";
- };
- if ($ARGV[0] eq "get_calls"){
- my @calls = &getRecordsXML("/opt/api_project_python/runningCalls.xml", "call");
- my $lenght = @calls;
- my $response = "";
- for( my $idx = 0; $idx < $lenght; $idx = $idx + 1 ) {
- my $call_id = $calls[$idx]{'call_id'};
- my $status = $calls[$idx]{'status'};
- my $ntel = $calls[$idx]{'ntel'};
- my $ackid = $calls[$idx]{'ackid'};
- $response = $response.$call_id."|".$status."|".$idx."|".$ntel."|".$ackid."||";
- }
- my @calls = &getRecordsXML("/opt/api_project_python/terminatedCalls.xml", "call");
- $lenght = @calls;
- for( my $idx = 0; $idx < $lenght; $idx = $idx + 1 ) {
- my $call_id = $calls[$idx]{'call_id'};
- my $status = $calls[$idx]{'status'};
- my $ntel = $calls[$idx]{'ntel'};
- my $ackid = $calls[$idx]{'ackid'};
- $response = $response.$call_id."|".$status."|".$idx."|".$ntel."|".$ackid."||";
- }
- print $response;
- };
- if ($ARGV[0] eq "delete_call"){
- $call_id = $ARGV[1];
- my @call = &getRecordXML("/opt/api_project_python/runningCalls.xml", "call", "call_id", $call_id);
- if ($call[0]){
- &deleteRecordXML("/opt/api_project_python/runningCalls.xml", "call_id", $call_id);
- $response = "Success";
- }
- else {
- @call = &getRecordXML("/opt/api_project_python/terminatedCalls.xml", "call", "call_id", $call_id);
- if ($call[0]){
- &deleteRecordXML("/opt/api_project_python/terminatedCalls.xml", "call_id", $call_id);
- $response = "Success";
- }
- else{
- $response = "Not found";
- }
- }
- print $response;
- };
|