<%@ Page Language="C#" aspcompat=true %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Collections" %>
<%@ Import Namespace="System.Web" %>
<%@ Import Namespace="System.Web.SessionState" %>
<%@ Import Namespace="System.Web.UI" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>
<%@ Import Namespace="System.Web.UI.HtmlControls" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Text.RegularExpressions" %>
<%@ Import Namespace="System.Runtime.InteropServices" %>
<script language="C#" runat=server>
Boolean ParseXML(string XMLContent, ref string KeyPress)
{
try
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(XMLContent);
String MenuID, Duration, CallerID, CallID, DateAndTime, VoiceFileName, PromptID, Action;
XmlNode TempNode;
XmlElement root = doc.DocumentElement;
XmlAttributeCollection attrColl = root.Attributes;
//Determine if this a campaign start/stop event or prompt event
if (root.Name=="campaign")
{
//parse campaign attributes
MenuID = attrColl["menuid"].Value;
Action = attrColl["action"].Value;
if (Action=="4")
{
CallerID = attrColl["callerid"].Value;
}
else
{
Duration = attrColl["duration"].Value;
}
CallID = attrColl["callid"].Value;
}
else
{
//parse prompt attributes
MenuID = attrColl["menuid"].Value;
CallID = attrColl["callid"].Value;
PromptID = attrColl["promptid"].Value;
KeyPress = attrColl["keypress"].Value;
}
return true;
}
catch (Exception e)
{
Response.Write(e.Message);
return false;
}
}
string CheckKeyPress(string KeyPress)
{
string ReturnXML = "";
switch (KeyPress)
{
case "1235":
ReturnXML = "<prompt goto=\"2\" />";
break;
}
return ReturnXML;
}
void Page_Load(object sender, System.EventArgs e)
{
try
{
String XML, xmlcontent, PostResponse, campaign, KeyPress = "";
Byte[] Bindata = Request.BinaryRead(Request.TotalBytes);
XML = System.Text.Encoding.ASCII.GetString(Bindata);
//parse XML from VoiceShot
if (ParseXML(XML, ref KeyPress))
{
//return response to VoiceShot
XML = CheckKeyPress(KeyPress);
Response.Write(XML);
}
else
Response.Write("Failed");
}
catch (Exception error)
{
Response.Write(error.Message);
}
}
</script>
|