Exemple #1
0
        public void TestElementWithChildren()
        {
            var elem = new Enqueue();

            elem.Task("body", 1, 1);

            Assert.AreEqual(
                "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine +
                "<Enqueue>" + Environment.NewLine +
                "  <Task priority=\"1\" timeout=\"1\">body</Task>" + Environment.NewLine +
                "</Enqueue>",
                elem.ToString()
                );
        }
        public IActionResult ProcessDigits()

        {
            var response = new VoiceResponse();

            Dictionary <string, string> department = new Dictionary <string, string>();

            department.Add("1", "sales");
            department.Add("2", "support");
            department.Add("3", "billing");

            var enqueue = new Enqueue(workflowSid: _workflow_sid);

            enqueue.Task("{'selected_product': '" + department[HttpContext.Request.Query["Digits"]] + @"'}");


            response.Append(enqueue);
            return(Content(response.ToString(), contentType: "text/xml"));
        }
        public ActionResult ProcessDigits()

        {
            var response = new VoiceResponse();

            Dictionary <string, string> department = new Dictionary <string, string>();

            department.Add("1", "sales");
            department.Add("2", "support");
            department.Add("3", "billing");


            var enqueue = new Enqueue(workflowSid: _workflowSid);

            enqueue.Task("{\"selected_product\": \"" + department[Request.Params.Get("digits")] + "\"}");


            response.Append(enqueue);
            return(Content(response.ToString(), contentType: "text/xml"));
        }
    public static void SendResponse(HttpListenerContext ctx)
    {
        HttpListenerRequest  request  = ctx.Request;
        HttpListenerResponse response = ctx.Response;

        response.StatusCode  = (int)HttpStatusCode.OK;
        response.ContentType = "text/xml";

        // Generate TwiML
        var twiml   = new VoiceResponse();
        var enqueue = new Enqueue(workflowSid: "WW0123456789abcdef0123456789abcdef");

        enqueue.Task("{\"account_number\": \"12345abcdef\"}");
        twiml.Append(enqueue);

        // Write the output and close the stream
        byte[] buffer = Encoding.UTF8.GetBytes(twiml.ToString());
        response.ContentLength64 = buffer.Length;
        response.OutputStream.Write(buffer, 0, buffer.Length);
        response.OutputStream.Close();
    }