changes to SIP code logging, added caller_code field to carrier_log table

git-svn-id: svn://192.168.202.10@1956 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2013-04-13 08:16:54 +00:00
parent 53851e58b6
commit ce2e286be7
4 changed files with 17 additions and 13 deletions
+6 -6
View File
@@ -669,7 +669,7 @@ while($one_day_interval > 0)
$result = $command_line[6];
$result =~ s/Result: |\s*$//gi;
@result_details=split(/\|/, $result);
if ( (length($result)>0) && ($result_details[0] !~ /^407|^487/) )
if ( (length($result)>0) && ($result_details[0] !~ /^407/) )
{
$lead_id = substr($callid, 10, 10);
$lead_id = ($lead_id + 0);
@@ -681,7 +681,7 @@ while($one_day_interval > 0)
if($DB){print "|$affected_rows dial_log updated|$callid|$server_ip|$result|\n";}
$vddl_update = ($vddl_update + $affected_rows);
$preCtarget = ($beginUNIQUEID - 10); # 10 seconds before call start
$preCtarget = ($beginUNIQUEID - 120); # 120 seconds before call start
($preCsec,$preCmin,$preChour,$preCmday,$preCmon,$preCyear,$preCwday,$preCyday,$preCisdst) = localtime($preCtarget);
$preCyear = ($preCyear + 1900);
$preCmon++;
@@ -703,7 +703,7 @@ while($one_day_interval > 0)
if ($postCsec < 10) {$postCsec = "0$postCsec";}
$postCSQLdate = "$postCyear-$postCmon-$postCmday $postChour:$postCmin:$postCsec";
$stmtA = "UPDATE vicidial_carrier_log SET sip_hangup_cause='$result_details[0]',sip_hangup_reason='$result_details[1]' where server_ip='$server_ip' and lead_id='$lead_id' and call_date > \"$preCSQLdate\" and call_date < \"$postCSQLdate\" order by call_date desc limit 1;";
$stmtA = "UPDATE vicidial_carrier_log SET sip_hangup_cause='$result_details[0]',sip_hangup_reason='$result_details[1]' where server_ip='$server_ip' and caller_code='$callerid' and lead_id='$lead_id' and call_date > \"$preCSQLdate\" and call_date < \"$postCSQLdate\" order by call_date desc limit 1;";
print STDERR "|$stmtA|\n";
my $affected_rows = $dbhA->do($stmtA);
if($DB){print "|$affected_rows carrier_log updated|$callid|$server_ip|$uniqueid|$result_details[0]|$result_details[1]|\n";}
@@ -1075,7 +1075,7 @@ while($one_day_interval > 0)
$result = $command_line[5];
$result =~ s/Result: |\s*$//gi;
@result_details=split(/\|/, $result);
if ( (length($result)>0) && ($result_details[0] !~ /^407|^487/) )
if ( (length($result)>0) && ($result_details[0] !~ /^407/) )
{
$lead_id = substr($callid, 10, 10);
$lead_id = ($lead_id + 0);
@@ -1087,7 +1087,7 @@ while($one_day_interval > 0)
if($DB){print "|$affected_rows dial_log updated|$callid|$server_ip|$result|\n";}
$vddl_update = ($vddl_update + $affected_rows);
$preCtarget = ($beginUNIQUEID - 10); # 10 seconds before call start
$preCtarget = ($beginUNIQUEID - 120); # 120 seconds before call start
($preCsec,$preCmin,$preChour,$preCmday,$preCmon,$preCyear,$preCwday,$preCyday,$preCisdst) = localtime($preCtarget);
$preCyear = ($preCyear + 1900);
$preCmon++;
@@ -1109,7 +1109,7 @@ while($one_day_interval > 0)
if ($postCsec < 10) {$postCsec = "0$postCsec";}
$postCSQLdate = "$postCyear-$postCmon-$postCmday $postChour:$postCmin:$postCsec";
$stmtA = "UPDATE vicidial_carrier_log SET sip_hangup_cause='$result_details[0]',sip_hangup_reason='$result_details[1]' where server_ip='$server_ip' and lead_id='$lead_id' and call_date > \"$preCSQLdate\" and call_date < \"$postCSQLdate\" order by call_date desc limit 1;";
$stmtA = "UPDATE vicidial_carrier_log SET sip_hangup_cause='$result_details[0]',sip_hangup_reason='$result_details[1]' where server_ip='$server_ip' and caller_code='$callerid' and lead_id='$lead_id' and call_date > \"$preCSQLdate\" and call_date < \"$postCSQLdate\" order by call_date desc limit 1;";
print STDERR "|$stmtA|\n";
my $affected_rows = $dbhA->do($stmtA);
if($DB){print "|$affected_rows carrier_log updated|$callid|$server_ip|$uniqueid|$result_details[0]|$result_details[1]|\n";}
+4 -6
View File
@@ -609,9 +609,7 @@ sub process_request
$sip_hangup_cause=0;
$sip_hangup_reason='';
$preCtarget = ($beginUNIQUEID - 10); # 10 seconds before call start
$preCtarget = ($beginUNIQUEID - 120); # 120 seconds before call start
($preCsec,$preCmin,$preChour,$preCmday,$preCmon,$preCyear,$preCwday,$preCyday,$preCisdst) = localtime($preCtarget);
$preCyear = ($preCyear + 1900);
$preCmon++;
@@ -633,8 +631,7 @@ sub process_request
if ($postCsec < 10) {$postCsec = "0$postCsec";}
$postCSQLdate = "$postCyear-$postCmon-$postCmday $postChour:$postCmin:$postCsec";
$stmtA = "SELECT sip_hangup_cause,sip_hangup_reason FROM vicidial_dial_log where lead_id='$CIDlead_id' and server_ip='$VARserver_ip' and call_date > \"$preCSQLdate\" and call_date < \"$postCSQLdate\" order by call_date desc;";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$stmtA = "SELECT sip_hangup_cause,sip_hangup_reason FROM vicidial_dial_log where lead_id='$CIDlead_id' and server_ip='$VARserver_ip' and caller_code='$callerid' order by call_date desc limit 1;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
@@ -645,8 +642,9 @@ sub process_request
$sip_hangup_reason = $aryA[1];
}
$sthA->finish();
if ($AGILOG) {$agi_string = "$sthArows|$stmtA|$sip_hangup_cause|$sip_hangup_reason|"; &agi_output;}
$stmtA = "INSERT IGNORE INTO vicidial_carrier_log set uniqueid='$uniqueid',call_date='$now_date',server_ip='$VARserver_ip',lead_id='$CIDlead_id',hangup_cause='$hangup_cause',dialstatus='$dialstatus',channel='$channel',dial_time='$dial_time',answered_time='$answered_time',sip_hangup_cause='$sip_hangup_cause',sip_hangup_reason='$sip_hangup_reason';";
$stmtA = "INSERT IGNORE INTO vicidial_carrier_log set uniqueid='$uniqueid',call_date='$now_date',server_ip='$VARserver_ip',lead_id='$CIDlead_id',hangup_cause='$hangup_cause',dialstatus='$dialstatus',channel='$channel',dial_time='$dial_time',answered_time='$answered_time',sip_hangup_cause='$sip_hangup_cause',sip_hangup_reason='$sip_hangup_reason',caller_code='$callerid';";
if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;}
$VCARaffected_rows = $dbhA->do($stmtA);
if ($AGILOG) {$agi_string = "-- CARRIER LOG insert: |$VCARaffected_rows|$CIDlead_id|$hangup_cause|$sip_hangup_cause|$sip_hangup_reason|"; &agi_output;}
@@ -2000,6 +2000,7 @@ dial_time SMALLINT(3) UNSIGNED default '0',
answered_time SMALLINT(4) UNSIGNED default '0',
sip_hangup_cause SMALLINT(4) UNSIGNED default '0',
sip_hangup_reason VARCHAR(50) default '',
caller_code VARCHAR(30) default '',
index (call_date),
index (lead_id)
);
@@ -3104,4 +3105,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version';
UPDATE system_settings set vdc_agent_api_active='1';
UPDATE system_settings SET db_schema_version='1342',db_schema_update_date=NOW();
UPDATE system_settings SET db_schema_version='1343',db_schema_update_date=NOW();
+5
View File
@@ -330,3 +330,8 @@ CREATE INDEX vddllid on vicidial_dial_log (lead_id);
CREATE INDEX vdcllid on vicidial_carrier_log (lead_id);
UPDATE system_settings SET db_schema_version='1342',db_schema_update_date=NOW() where db_schema_version < 1342;
ALTER TABLE vicidial_carrier_log ADD caller_code VARCHAR(30) default '';
ALTER TABLE vicidial_carrier_log_archive ADD caller_code VARCHAR(30) default '';
UPDATE system_settings SET db_schema_version='1343',db_schema_update_date=NOW() where db_schema_version < 1343;