if you are already going through all the trouble to pull these from the database wouldn't it be easier to actually do the date comparison in the lua too, instead of creating condition tags?

On Sep 10, 2015, at 11:43 AM, Jonathan Hunter <hunterj91@hotmail.com> wrote:

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 seperate times.

Can someone let me know what Im doing wrong?

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
_________________________________________________________________________
Professional FreeSWITCH Consulting Services: 
consulting@freeswitch.org
http://www.freeswitchsolutions.com

Official FreeSWITCH Sites
http://www.freeswitch.org
http://confluence.freeswitch.org
http://www.cluecon.com

FreeSWITCH-users mailing list
FreeSWITCH-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org