客製~動態的 agi-conf

    內容表格
    1. 1. 說明
    2. 2. Dialplan 設計

     

    說明

    假設有兩種計費模式:每秒計費以及月租費,若用戶為月租費模式,當用戶撥號後,系統不會提示餘額,若為每秒計費者,系統必須提示餘額。

    原理:系統應該要自動辨識該用戶的 Call Plan 自動選擇並選擇正確的 agi-conf 檔。

    此方案的限制:

    • 僅適用用戶為 SIP Client 連線時,而透過 DID 撥入的用戶必須修改 a2billing core。

    Dialplan 設計

    [a2billing-callplan]
    exten => _X.,1,NoOp("--------- Connect to MySQL -----------")
    exten => _X.,n,Set(CARDNO=${CDR(accountcode)})
    exten => _X.,n,NoOp("-- Account code is ${CARDNO} --")
    ;----------- DB connection variables ----------
    exten => _X.,n,Set(DBHOST="localhost")
    exten => _X.,n,Set(DBUSER="a2billinguser")
    exten => _X.,n,Set(DBPASS="a2billing")
    exten => _X.,n,Set(DBNAME="mya2billing")
    exten => _X.,n,MYSQL(Connect connid ${DBHOST} ${DBUSER} ${DBPASS} ${DBNAME})
    exten => _X.,n,GotoIf($["${connid}" = ""]?error,1)
    exten => _X.,n,NoOp("------ Connected MySQL -------")
    ;----------- Get tariff ID -----------
    exten => _X.,n,Set(SQL="SELECT tariff FROM cc_card WHERE username=${CARDNO}")
    exten => _X.,n,MYSQL(Query resultid ${connid} ${SQL})
    exten => _X.,n,MYSQL(Fetch fetchid ${resultid} TARIFF)
    exten => _X.,n,NoOp(-- TARIFF => ${TARIFF} --)
    ;----------- Get Call Plan(CP) -------------
    exten => _X.,n,Set(SQL="SELECT tariffgroupname FROM cc_tariffgroup WHERE id=${TARIFF}")
    exten => _X.,n,MYSQL(Query resultid ${connid} ${SQL})
    exten => _X.,n,MYSQL(Fetch fetchid ${resultid} CP)
    exten => _X.,n,MYSQL(Disconnect ${connid})
    exten => _X.,n,NoOp(-- Call Plan => ${CP} --)
    ;----------- Add the rule for Call Plan -----------
    exten => _X.,n,GotoIf($["${CP}" = "CP1"]?conf1,1)
    exten => _X.,n,GotoIf($["${CP}" = "CP2"]?conf2,1)
    exten => _X.,n,Hangup
    exten => h,1,Hangup
    exten => error,1,NoOp(MySQL connection error!! Please check the dialplan...)
    exten => error,n,Hangup
    exten => conf1,1,NoOp("----- Starting A2Billing with agi-conf-1 ------")
    exten => conf1,n,DeadAgi(a2billing.php,1)
    exten => conf1,n,Hangup
    exten => conf2,1,NoOp("----- Starting A2Billing with agi-conf-2 ------")
    exten => conf2,n,DeadAgi(a2billing.php,2)
    exten => conf2,n,Hangup
    
    標籤 (Edit tags)
    • No tags
    您必須 登入 才能發佈評論。
    Powered by MindTouch Core