text stringlengths 0 152 |
|---|
dsn=asterisk |
mode=multirow |
readsql=SELECT extension FROM ast_hotdesk WHERE status = '${ARG1}' |
and a dialplan in extensions.conf that looks something like this: |
exten => *9997,1,Noop(multirow) |
same => n,Set(ODBC_ID=${HOTDESK_AVAILABLE_EXTENS()}) |
same => n,GotoIf($[${ODBCROWS} < 1]?no_rows) |
same => n,Answer() |
same => n,Set(COUNTER=1) |
same => n,While($[${COUNTER} <= ${ODBCROWS}]) |
same => n,Set(AVAIL_EXTEN_${COUNTER}=${ODBC_FETCH(${ODBC_ID})}) |
same => n,SayDigits(${AVAIL_EXTEN_${COUNTER}}) |
same => n,Wait(0.2) ; Pause between speaking |
same => n,Set(COUNTER=$[${COUNTER} + 1]) |
same => n,EndWhile() |
same => n(norows),ODBCFinish() |
same => n,Hangup() |
Note that unless you have multiple endpoints to log in, this will never return more |
than one extension in your lab because only one device will be logged in at any time. |
You can add some dummy data to the table just to see how this works: |
MySQL> UPDATE pbx.ast_hotdesk |
SET status='1',endpoint='HOTDESK_2' |
WHERE id='3' |
; |
MySQL> UPDATE pbx.ast_hotdesk |
SET status='1',endpoint='HOTDESK_3' |
WHERE id='5' |
; |
274 |
| |
Chapter 15: Relational Database Integration |
The ODBC_FETCH() function will essentially treat the information as a stack, and each |
call to it with the passed ODBC_ID will pop the next row of information off the stack. |
We also have the option of using the ODBC_FETCH_STATUS channel variable, which is |
set once the ODBC_FETCH() function (which returns SUCCESS if additional rows are |
available or FAILURE if no additional rows are available) is called. This permits us to |
write a dialplan like the following, which does not use a counter, but still loops |
through the data. This may be useful if we’re looking for something specific and don’t |
need to look at all the data. Once we’re done, the ODBCFinish() dialplan application |
should be called to clean up any remaining data. |
Here’s another extensions.conf example: |
[multirow_example_2] |
exten => start,1,Verbose(1,Looping example with break) |
same => n,Set(ODBC_ID=${GET_ALL_AVAIL_EXTENS(1)}) |
same => n(loop_start),NoOp() |
same => n,Set(ROW_RESULT=${ODBC_FETCH(${ODBC_ID})}) |
same => n,GotoIf($["${ODBC_FETCH_STATUS}" = "FAILURE"]?cleanup,1) |
same => n,GotoIf($["${ROW_RESULT}" = "1104"]?good_exten,1) |
same => n,Goto(loop_start) |
exten => cleanup,1,Verbose(1,Cleaning up after all iterations) |
same => n,Verbose(1,We did not find the extension we wanted) |
same => n,ODBCFinish(${ODBC_ID}) |
same => n,Hangup() |
exten => good_exten,1,Verbose(1,Extension we want is available) |
same => n,ODBCFinish(${ODBC_ID}) |
same => n,Verbose(1,Perform some action we wanted) |
same => n,Hangup() |
OK, we’ve digressed a bit. Let’s wrap up a few parts of the agent components that we |
haven’t handled yet. |
In the _*99110[1-5] extension, we need the following labels: |
same => n,GotoIf($[${${HotdeskExtension}_STATUS} = 1]?logout:login,1) |
same => n(invalid_user),Noop(Hot Desk extension ${HotdeskExtension} does not exist) |
same => n,Playback(silence/2&login-fail) |
same => n,Hangup() |
same => n(logout),Noop() |
same => n,Set(HOTDESK_STATUS(${HotdeskExtension})=0,) ; Note VAL2 is empty |
same => n,GotoIf($[${ODBCROWS} < 1]?error,1) |
same => n,Playback(silence/1&agent-loggedoff) |
same => n,Hangup() |
We also include the hotdesk_outbound context, which will handle our outgoing calls |
after we have logged the agent into the system: |
include => hotdesk_outbound ; this line can go anywhere in the [hotdesk] context |
Getting Funky with func_odbc: Hot-Desking |
| |
275 |
The [hotdesk_outbound] context utilizes many of the same principles already dis‐ |
cussed. This context uses a pattern match to catch any numbers dialed from the hot- |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.