[Freeswitch-users] Using Lua to extract TOD conditions from Database -How to do it with multiple entries.
Jonathan Hunter
jhunter at voxboxcoms.co.uk
Fri Sep 11 09:19:07 MSD 2015
Hi Guys,
Wonder if anyone can help.
I am testing with time of day routing, and I want to be able to check
yearly/monthly conditions before weekly conditions are picked up.
I can do this successfully by just inputting XML into the dialplan, and
works as expected, my issue is now when extracting the detail required from
a database using lua.
I for example have 3 entries below for different times of the year;
+------------+-------+------+----------------+
| dayofmonth | month | year | dayofmonthtime |
+------------+-------+------+----------------+
| 25 | 12 | 0 | 0 |
| 1 | 1 | 2016 | 540-1050 |
| 10-18 | 9 | 2015 | 600-840 |
So when creating directly using xml I get;
table.insert(xml, [[<condition mon="12" mday="25" break="on-true">]]);
table.insert(xml, [[<action application="set" data="TOD=sales"
inline="true"/>]]);
table.insert(xml, [[<action application="set" data="Status=closed
inline="true"/>]]);
table.insert(xml, [[</condition>]]);
table.insert(xml, [[<condition year="2016" mon="1" mday="1"
break="on-true">]]);
table.insert(xml, [[<action application="set" data="TOD=sales"
inline="true"/>]]);
table.insert(xml, [[<action application="set" data="Status=closed
inline="true"/>]]);
table.insert(xml, [[</condition>]]);
table.insert(xml, [[<condition year="2015" mon="9" mday="10-18"
break="on-true">]]);
table.insert(xml, [[<action application="set" data="TOD=sales"
inline="true"/>]]);
table.insert(xml, [[<action application="set" data="Status=closed
inline="true"/>]]);
table.insert(xml, [[</condition>]]);
However my issue is when my lua script extracts them, it loops through the
3 entries (each row) , so that only the 3rd entry is available for on-wards
routing as it is populating the dialplan 3 separate times.
Can someone let me know what Im doing wrong? The data return is fine and
I can implement lua and freeswitch for all other scenarios, its just this
one which I am having issue with.
Im just doing a query as;
local todnew_query = string.format("select * from timeofday_new where
todname='sales' and context_name='xx.xx.xx' order by priority")
assert
(dbh:query(todnew_query,function(todresult)
And using the result with some if statements, I wondered if anyone had any
advice on this?
Thanks
Jon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20150911/b260f819/attachment-0001.html
Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users
mailing list