您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

138 行
5.5 KiB

  1. #!/usr/bin/perl
  2. #
  3. require '/usr/local/majormin/libUTILSgeneral.pl';
  4. require '/usr/local/majormin/web-lib.pl';
  5. #require './scheduler.pl';
  6. if ($ARGV[0] eq "asterisk_running"){
  7. # my %hash_call;
  8. # $hash_call{'mode'}= $ARGV[0];
  9. # $hash_call{'from'}= $ARGV[1];
  10. # $hash_call{'call_id'}= $ARGV[2];
  11. # $hash_call{'ntel'}=$ARGV[3];
  12. # $hash_call{'ackid'}=$ARGV[4];
  13. # $hash_call{'text_message'}=$ARGV[5];
  14. # $hash_call{'retry_message'}=$ARGV[6];
  15. # $hash_call{'timeout'}=$ARGV[7];
  16. # $hash_call{'retry'}=$ARGV[8];
  17. # $hash_call{'notification_send'}=$ARGV[9];
  18. # $hash_call{'notification_to'}=$ARGV[10];
  19. # $hash_call{'notification_bcc'}=$ARGV[11];
  20. # $hash_call{'tmpdir'}=$ARGV[13];
  21. # $hash_call{'status'}=$ARGV[12];
  22. # $hash_call{'fromemail'}=$ARGV[14];
  23. # $hash_call{'first_action'}=$ARGV[15];
  24. # ($sec,$min) = localtime();
  25. # $hash_call{'last_action'} = ($min*60)+$sec;
  26. # &deleteRecordXML("/opt/api_project_python/runningCalls.xml", "call_id", $hash_call{'call_id'});
  27. # &addRecordXML(\%hash_call, "/opt/api_project_python/runningCalls.xml", "/opt/api_project_python/runningCallsTmpl.xml", "call");
  28. };
  29. if ($ARGV[0] eq "asterisk_terminated"){
  30. my %hash_call;
  31. $hash_call{'mode'}= $ARGV[0];
  32. $hash_call{'from'}= $ARGV[1];
  33. $hash_call{'call_id'}= $ARGV[2];
  34. $hash_call{'ntel'}=$ARGV[3];
  35. $hash_call{'ackid'}=$ARGV[4];
  36. $hash_call{'text_message'}=$ARGV[5];
  37. $hash_call{'retry_message'}=$ARGV[6];
  38. $hash_call{'timeout'}=$ARGV[7];
  39. $hash_call{'retry'}=$ARGV[8];
  40. $hash_call{'notification_send'}=$ARGV[9];
  41. $hash_call{'notification_to'}=$ARGV[10];
  42. $hash_call{'notification_bcc'}=$ARGV[11];
  43. $hash_call{'status'}=$ARGV[12];
  44. $hash_call{'tmpdir'}=$ARGV[13];
  45. $hash_call{'fromemail'}=$ARGV[14];
  46. $hash_call{'first_action'}=$ARGV[15];
  47. ($sec,$min) = localtime();
  48. $hash_call{'last_action'} = ($min*60)+$sec;
  49. &deleteRecordXML("/opt/api_project_python/runningCalls.xml", "call_id", $hash_call{'call_id'});
  50. &addRecordXML(\%hash_call, "/opt/api_project_python/runningCalls.xml", "/opt/api_project_python/runningCallsTmpl.xml", "call");
  51. };
  52. if ($ARGV[0] eq "call_id"){
  53. $call_id = $ARGV[1];
  54. my @call = &getRecordXML("/opt/api_project_python/runningCalls.xml", "call", "call_id", $call_id);
  55. if (!$call[0]){
  56. @call = &getRecordXML("/opt/api_project_python/terminatedCalls.xml", "call", "call_id", $call_id);
  57. }
  58. my $call_id = &getFieldValue($call[0], "call_id");
  59. my $status = &getFieldValue($call[0], "status");
  60. my $ntel = &getFieldValue($call[0], "ntel");
  61. my $ackid = &getFieldValue($call[0], "ackid");
  62. $response = $call_id."|".$status."|".$status."|".$ntel."|".$ackid;
  63. print $response;
  64. };
  65. if ($ARGV[0] eq "voicegateway"){
  66. my %hash_call;
  67. $hash_call{'mode'}= $ARGV[0];
  68. $hash_call{'from'}= $ARGV[1];
  69. $hash_call{'call_id'}= $ARGV[2];
  70. $hash_call{'ntel'}=$ARGV[3];
  71. $hash_call{'ackid'}=$ARGV[4];
  72. $hash_call{'text_message'}=$ARGV[5];
  73. $hash_call{'retry_message'}=$ARGV[6];
  74. $hash_call{'timeout'}=$ARGV[7];
  75. $hash_call{'retry'}=$ARGV[8];
  76. $hash_call{'notification_send'}=$ARGV[9];
  77. $hash_call{'notification_to'}=$ARGV[10];
  78. $hash_call{'notification_bcc'}=$ARGV[11];
  79. $hash_call{'tmpdir'}=$ARGV[13];
  80. $hash_call{'status'}=$ARGV[12];
  81. $hash_call{'fromemail'}=$ARGV[14];
  82. $hash_call{'hw_id'}=$ARGV[15];
  83. # inserisco il nuovo record con i parametri della chiamata
  84. &addRecordXML(\%hash_call, "/opt/api_project_python/runningCalls.xml", "/opt/api_project_python/runningCallsTmpl.xml", "call");
  85. # leggo lo stato dello scheduler
  86. # se lo scheduler è già attivo (1), non faccio niente, se non è attivo (0) avvia lo scheduler
  87. $pidOfScheduler = `ps aux | grep "scheduler.pl" | grep -v "grep" | awk '{print $2}'`;
  88. if (!$pidOfScheduler){
  89. #$scheduler = &scheduler();
  90. $scheduler = `/usr/bin/perl /opt/api_project_python/scheduler.pl`;
  91. }
  92. print "Success";
  93. };
  94. if ($ARGV[0] eq "get_calls"){
  95. my @calls = &getRecordsXML("/opt/api_project_python/runningCalls.xml", "call");
  96. my $lenght = @calls;
  97. my $response = "";
  98. for( my $idx = 0; $idx < $lenght; $idx = $idx + 1 ) {
  99. my $call_id = $calls[$idx]{'call_id'};
  100. my $status = $calls[$idx]{'status'};
  101. my $ntel = $calls[$idx]{'ntel'};
  102. my $ackid = $calls[$idx]{'ackid'};
  103. $response = $response.$call_id."|".$status."|".$idx."|".$ntel."|".$ackid."||";
  104. }
  105. my @calls = &getRecordsXML("/opt/api_project_python/terminatedCalls.xml", "call");
  106. $lenght = @calls;
  107. for( my $idx = 0; $idx < $lenght; $idx = $idx + 1 ) {
  108. my $call_id = $calls[$idx]{'call_id'};
  109. my $status = $calls[$idx]{'status'};
  110. my $ntel = $calls[$idx]{'ntel'};
  111. my $ackid = $calls[$idx]{'ackid'};
  112. $response = $response.$call_id."|".$status."|".$idx."|".$ntel."|".$ackid."||";
  113. }
  114. print $response;
  115. };
  116. if ($ARGV[0] eq "delete_call"){
  117. $call_id = $ARGV[1];
  118. my @call = &getRecordXML("/opt/api_project_python/runningCalls.xml", "call", "call_id", $call_id);
  119. if ($call[0]){
  120. &deleteRecordXML("/opt/api_project_python/runningCalls.xml", "call_id", $call_id);
  121. $response = "Success";
  122. }
  123. else {
  124. @call = &getRecordXML("/opt/api_project_python/terminatedCalls.xml", "call", "call_id", $call_id);
  125. if ($call[0]){
  126. &deleteRecordXML("/opt/api_project_python/terminatedCalls.xml", "call_id", $call_id);
  127. $response = "Success";
  128. }
  129. else{
  130. $response = "Not found";
  131. }
  132. }
  133. print $response;
  134. };