分享

Dialplan 手写的简单学员成绩电话查询系统

 MikeDoc 2011-09-13

下面为简单的一个电话查询系统,功能很小,练练手,功能基本OK,但不够尽善尽美,只能满足基本的功能。

..................................................................................................................................................................................................

 

IVR:欢迎致电学员成绩电话查询系统,学员成绩查询请按1,人工查询请按2,学员管理请按3(管理员使用)。。。按其它键提示错误或重新回到什么什么按1或2

 

按键1:请输入学员编号,如果输入没有该编号,提示不存在或再提示回到请输入学员拨号,输入正确后提示“您的成绩为多少多少分”然后挂机.(当然这里还很多什么什么重新查询啊。什么的。。原理一样.我就没继续做了)

 

按键2: 转某个分机,或者队列。。。

 

按键3:(先提示输入管理员密码)修改学员成绩请按1,删除错误学员成绩请按2(添加学员编号就没做了。)

 

按1:请输入要修改学员的编号(与数据库查询,同样输入不存在的编号,提示错误,或重新提示),然后提示请输入要修改次学员的成绩,输入后提示修改成功,并重新读取数据,提示修改后的成绩为多少多少

 

按2: 请输入要删除学员成绩的编号,(与数据库查询,同样输入不存在的编号,提示错误,或重新提示),输入正确后,提示删除成功。。什么什么

 

..................................................................................................................................................................................................

数据库结构:
s_uid s_name s_relts
(学员编号) (学员姓名) (学员成绩)
1000 浩子 888
1001 voip 666
........ ........ .......

..................................................................................................................................................................................................

下面为整个实现功能的Dialplan 代码,有点乱,程序当然还可以优化,先这么整吧。。
  1. [code]
  2. [globals] ;定义全局变量
  3. ;................................................mysql
  4. DBCurrentHost=localhost
  5. DBuser=root
  6. DBpass=888888
  7. DBname=asterisk_test
  8. ;........................................
  9. [from-internal] ;欢迎提示,xxxxxx按1或按2
  10. exten => _x.,1,Answer(${EXTEN})
  11. exten => _x.,n,NoOP(${EXTEN})
  12. exten => _x.,n(read1),Read(a,stu/welcome,1,,2,5)
  13. exten => _x.,n(lan1),Gotoif($["${a}"="1"]?menu1,${EXTEN},1:lan2)
  14. exten => _x.,n(lan2),Gotoif($["${a}"="2"]?menu2,${EXTEN},1:lan0)
  15. exten => _x.,n(lan0),Gotoif($["${a}"="0"]?menu0,${EXTEN},1:exen0,${EXTEN},1)
  16. [exen0] ;欢迎提示按其它键的报错提示,然后重新回到welcome
  17. exten => _x.,1,Answer(${EXTEN})
  18. exten => _x.,n,NoOP(${EXTEN})
  19. exten => _x.,n,wait(1)
  20. exten => _x.,n,Playback(stu/exen0)
  21. exten => _x.,n,Gotoif($["1"="1"]?from-internal,${EXTEN},read1)
  22. [menu1] ;按1键后的操作,输入学员拨号,进行查询
  23. exten => _x.,1,Answer(${EXTEN})
  24. exten => _x.,n,NoOP(${EXTEN})
  25. exten => _x.,n,wait(1)
  26. exten => _x.,n(read1),Read(bhao,stu/stubhao,20,,2,5)
  27. exten => _x.,n,Set(ID=${bhao})
  28. exten => _x.,n,MySql(connect connid ${DBCurrentHost} ${DBuser} ${DBpass} ${DBname})
  29. exten => _x.,n,MySql(query resultidr ${connid} select s_uid/,s_relts from stu where s_uid=${ID})
  30. exten => _x.,n,MySql(Fetch foundrow ${resultidr} s_uid s_relts)
  31. exten => _x.,n,MySql(clear ${resultidr})
  32. exten => _x.,n,MySql(disconnect ${connid})
  33. exten => _x.,n,Gotoif($["${ID}"="${s_uid}"]?jieg:read1)
  34. exten => _x.,n(jieg),playback(stu/jieg)
  35. ;exten => _x.,n,Dial(SIP/${s_relts})
  36. exten => _x.,n,SayNumber(${s_relts})
  37. exten => _x.,n,Playback(stu/fen)
  38. exten => _x.,n,Hangup()
  39. [menu2] ;人工查询后的操作
  40. exten => _x.,1,Answer(${EXTEN})
  41. exten => _x.,n,NoOP(${EXTEN})
  42. exten => _x.,n,Dial(SIP/8111,10)
  43. exten => _x.,n,playback(stu/mang)
  44. exten => _x.,n,Hangup()
  45. [menu0] ;按0键后的操作,管理员使用
  46. exten => _x.,1,Answer(${EXTEN})
  47. exten => _x.,n,NoOP(${EXTEN})
  48. exten => _x.,n,MySql(connect connid ${DBCurrentHost} ${DBuser} ${DBpass} ${DBname})
  49. exten => _x.,n,MySql(query result ${connid} select s_pass from ampuser)
  50. exten => _x.,n,MySql(Fetch foundrow ${result} s_pass)
  51. exten => _x.,n,MySql(clear ${result})
  52. exten => _x.,n,MySql(disconnect ${connid})
  53. exten => _x.,n,Authenticate(${s_pass})
  54. exten => _x.,n(read1),Read(stubhao,stu/stucjivr,1,,2,5)
  55. exten => _x.,n(lan1),Gotoif($["${stubhao}"="1"]?update,${EXTEN},1:lan2)
  56. exten => _x.,n(lan2),Gotoif($["${stubhao}"="2"]?delete,${EXTEN},1:read1)
  57. [update] ;修改学员成绩拨号
  58. exten => _x.,1,Answer(${EXTEN})
  59. exten => _x.,n,NoOP(${EXTEN})
  60. exten => _x.,n(read1),Read(update,stu/update_stu,10,,2,5)
  61. exten => _x.,n,MySql(connect connid ${DBCurrentHost} ${DBuser} ${DBpass} ${DBname})
  62. exten => _x.,n,MySql(query resultidr ${connid} select s_uid/,s_relts from stu where s_uid=${update})
  63. exten => _x.,n,MySql(Fetch foundrow ${resultidr} s_uid s_relts)
  64. exten => _x.,n,MySql(clear ${resultidr})
  65. exten => _x.,n,MySql(disconnect ${connid})
  66. exten => _x.,n,Gotoif($["${update}"="${s_uid}"]?lanup:read1)
  67. exten => _x.,n(lanup),Read(cj,stu/xhao1,10,,2,5)
  68. exten => _x.,n,MySql(connect connid ${DBCurrentHost} ${DBuser} ${DBpass} ${DBname})
  69. exten => _x.,n,MySql(query resultidr ${connid} update stu set s_relts ='${cj}' where s_uid=${s_uid})
  70. exten => _x.,n,MySql(disconnect ${connid})
  71. exten => _x.,n,MySql(connect connid ${DBCurrentHost} ${DBuser} ${DBpass} ${DBname})
  72. exten => _x.,n,MySql(query resultidr ${connid} select s_uid/,s_relts from stu where s_uid=${update})
  73. exten => _x.,n,MySql(Fetch foundrow ${resultidr} s_uid s_relts)
  74. exten => _x.,n,MySql(clear ${resultidr})
  75. exten => _x.,n,MySql(disconnect ${connid})
  76. exten => _x.,n,playback(stu/update_cj)
  77. exten => _x.,n,SayNumber(${s_relts})
  78. exten => _x.,n,Playback(stu/fen)
  79. exten => _x.,n,Hangup()
  80. [delete] ;删除错误的学员信息操作
  81. exten => _x.,1,Answer(${EXTEN})
  82. exten => _x.,n,NoOP(${EXTEN})
  83. exten => _x.,n(delete1),Read(deletebhao,stu/delete_bhao,10,,2,5)
  84. exten => _x.,n,MySql(connect connid ${DBCurrentHost} ${DBuser} ${DBpass} ${DBname})
  85. exten => _x.,n,MySql(query resultidr ${connid} select s_uid/,s_relts from stu where s_uid=${deletebhao})
  86. exten => _x.,n,MySql(Fetch foundrow ${resultidr} s_uid s_relts)
  87. exten => _x.,n,MySql(clear ${resultidr})
  88. exten => _x.,n,MySql(disconnect ${connid})
  89. exten => _x.,n,Gotoif($["${deletebhao}"="${s_uid}"]?delete:delete1)
  90. exten => _x.,n(delete),MySql(connect connid ${DBCurrentHost} ${DBuser} ${DBpass} ${DBname})
  91. exten => _x.,n,MySql(query resultidr ${connid} delete from stu where s_uid=${deletebhao})
  92. exten => _x.,n,MySql(disconnect ${connid})
  93. exten => _x.,n,Playback(stu/delbhao)
  94. exten => _x.,n,SayAlpha(${deletebhao})
  95. exten => _x.,n,Playback(stu/deletejg)
  96. exten => _x.,n,Hangup()
  97. ; 添加就木做了

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多