public void ProcessRequest(HttpContext context)
        {
            string duration = context.Request.Form["RecordingDuration"];

            int lengthOfCall = 1;
            try
            {
                lengthOfCall = int.Parse(duration);
            }
            catch { }

            string patientID = context.Request.QueryString["userid"];
            string soundFileName = string.Empty;
            IPatientRecords patientRecords = new PatientRecords();
            string xmlFilePath = "C:\\inetpub\\wwwroot\\Reminders\\xml\\";
            Database.ReminderConnection = PatientCommunication.Response.Properties.Settings.Default.reminder;

            if (lengthOfCall > 5)
            {
                patientRecords.UpdatePatientCall(patientID, "Call Completed - VoiceMail");
            }
            else
            {
                patientRecords.UpdatePatientCall(patientID, "Call Completed - Person Picked Up");
            }
            soundFileName = patientRecords.GetPatientVoiceFileFromID(patientID);
            FileStream fs = System.IO.File.Create(xmlFilePath + patientID + "PlayVoice.xml");
            fs.Close();

            StreamWriter sw = System.IO.File.AppendText(xmlFilePath + patientID + "PlayVoice.xml");
            sw.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            sw.WriteLine("<Response>");

            sw.WriteLine("<Play>" + "http://reminders.grovehill.com/reminders/voice/" + soundFileName + "</Play>");
            sw.WriteLine("</Response>");
            sw.Flush();
            sw.Close();
            context.Response.ContentType = "text/xml";
            context.Response.WriteFile(xmlFilePath + patientID + "PlayVoice.xml");

            //foreach (string key in context.Request.Form.Keys)
            //{
            //    //Response.Write(Request.Form[key]);
            //    Log("C:\\temp2\\", "log2.log", "The key1 is :" + key);
            //    Log("C:\\temp2\\", "log2.log", context.Request.Form[key]);
            //}

            ////For a get request:
            //foreach (string key in context.Request.QueryString.Keys)
            //{
            //    //Response.Write(Request.QueryString[key]);
            //    Log("C:\\temp2\\", "log2.log", "The key2 is :" + key);
            //    Log("C:\\temp2\\", "log2.log", context.Request.QueryString[key]);
            //}

        }
        public void ProcessRequest(HttpContext context)
        {
            string digit = context.Request.QueryString["Digits"];
            //string patientID = context.Request.QueryString["CallerName"];
            string patientID = context.Request.QueryString["userid"];
            
            string soundFileName = string.Empty;
            IPatientRecords patientRecords = new PatientRecords();
            string xmlFilePath = "C:\\inetpub\\wwwroot\\Reminders\\testing\\xml\\";
            string logFilePath = System.Configuration
                .ConfigurationManager.AppSettings["logfile"];

            //Log("C:\\temp2\\", "log.log", "The digit is :" + digit);
            //Log("C:\\temp2\\", "log.log", "The patientid is :" + patientID);
            //Log("C:\\temp2\\", "log.log", " From value:  " + context.Request["from"]);
            //Log("C:\\temp2\\", "log.log", " TotalCost value:  " + context.Request["TotalCost"]);
            //Log("C:\\temp2\\", "log.log", " Direction value:  " + context.Request["Direction"]);
            //Log("C:\\temp2\\", "log.log", " BillDuration value:  " + context.Request["BillDuration"]);
            //Log("C:\\temp2\\", "log.log", " CallerName value:  " + context.Request["CallerName"]);
            //Log("C:\\temp2\\", "log.log", " HangupCause value:  " + context.Request["HangupCause"]);
            //Log("C:\\temp2\\", "log.log", " BillRate value:  " + context.Request["BillRate"]);
            //Log("C:\\temp2\\", "log.log", " AnswerTime value:  " + context.Request["AnswerTime"]);
            //Log("C:\\temp2\\", "log.log", " StartTime value:  " + context.Request["StartTime"]);
            //Log("C:\\temp2\\", "log.log", " Duration value:  " + context.Request["Duration"]);
            //Log("C:\\temp2\\", "log.log", " CallUUID value:  " + context.Request["CallUUID"]);
            //Log("C:\\temp2\\", "log.log", " EndTime value:  " + context.Request["EndTime"]);
            //Log("C:\\temp2\\", "log.log", " CallStatus value:  " + context.Request["CallStatus"]);
            //Log("C:\\temp2\\", "log.log", " Event value:  " + context.Request["Event"]);

            //Server=localhost;Database=reminders;Uid=root;Pwd=root;

            Database.ReminderConnection = "Server=localhost;Database=reminders;Uid=root;Pwd=root;";
            //if (digit == "1")
            //{
                soundFileName = patientRecords.GetPatientVoiceFileFromID(patientID);
                FileStream fs = System.IO.File.Create(xmlFilePath + patientID + "Play.xml");
                fs.Close();

                StreamWriter sw = System.IO.File.AppendText(xmlFilePath + patientID + "Play.xml");
                sw.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                sw.WriteLine("<Response>");

                sw.WriteLine("<Play>" + "http://reminders.grovehill.com/reminders/voice/" + soundFileName + "</Play>");
                sw.WriteLine("</Response>");
                sw.Flush();
                sw.Close();
                patientRecords.UpdateCall(patientID, "1");
                context.Response.ContentType = "text/xml";
                Log("C:\\temp2\\", "log.log", "http://reminders.grovehill.com/Reminders/testing/xml/" + patientID + "Play.xml");
                
                //context.Response.Write("http://reminders.grovehill.com/Reminders/testing/xml/" + patientID + "Play.xml");
                context.Response.WriteFile(xmlFilePath + patientID + "Play.xml");
            //}
            //else if  (digit == "9")
            //{
            //    patientRecords.UpdateCall(patientID, "9");
            //    soundFileName = patientRecords.GetPatientVoiceFileFromID(patientID);
            //    FileStream fs = System.IO.File.Create(xmlFilePath + patientID + "9Play.xml");
            //    fs.Close();

            //    StreamWriter sw = System.IO.File.AppendText(xmlFilePath + patientID + "9Play.xml");
            //    sw.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
            //    sw.WriteLine("<Response>");

            //    sw.WriteLine("<Play>" + "http://reminders.grovehill.com/reminders/voice/second.wav" + "</Play>");
            //    sw.WriteLine("</Response>");
            //    sw.Flush();
            //    sw.Close();
            //    context.Response.ContentType = "text/xml";
            //    Log("C:\\temp2\\", "log.log", "http://reminders.grovehill.com/Reminders/testing/xml/" + patientID + "9Play.xml");

            //    //context.Response.Write("http://reminders.grovehill.com/Reminders/testing/xml/" + patientID + "Play.xml");
            //    context.Response.WriteFile(xmlFilePath + patientID + "9Play.xml");
            //}
            //else
            //{
            //    patientRecords.UpdateCall(patientID, "0");
            //}

            //foreach (string key in context.Request.Form.Keys)
            //{
            //    //Response.Write(Request.Form[key]);
            //    Log("C:\\temp2\\", "log.log", "The key1 is :" + key);
            //    Log("C:\\temp2\\", "log.log", context.Request.Form[key]);
            //}

            ////For a get request:
            //foreach (string key in context.Request.QueryString.Keys)
            //{
            //    //Response.Write(Request.QueryString[key]);
            //    Log("C:\\temp2\\", "log.log", "The key2 is :" + key);
            //    Log("C:\\temp2\\", "log.log", context.Request.QueryString[key]);
            //}

            //Log("C:\\temp2\\", "log.log", " From value:  " + context.Request["from"]);
            //Log("C:\\temp2\\", "log.log", " TotalCost value:  " + context.Request["TotalCost"]);
            //Log("C:\\temp2\\", "log.log", " Direction value:  " + context.Request["Direction"]);
            //Log("C:\\temp2\\", "log.log", " BillDuration value:  " + context.Request["BillDuration"]);
            //Log("C:\\temp2\\", "log.log", " CallerName value:  " + context.Request["CallerName"]);
            //Log("C:\\temp2\\", "log.log", " HangupCause value:  " + context.Request["HangupCause"]);
            //Log("C:\\temp2\\", "log.log", " BillRate value:  " + context.Request["BillRate"]);
            //Log("C:\\temp2\\", "log.log", " AnswerTime value:  " + context.Request["AnswerTime"]);
            //Log("C:\\temp2\\", "log.log", " StartTime value:  " + context.Request["StartTime"]);
            //Log("C:\\temp2\\", "log.log", " Duration value:  " + context.Request["Duration"]);
            //Log("C:\\temp2\\", "log.log", " CallUUID value:  " + context.Request["CallUUID"]);
            //Log("C:\\temp2\\", "log.log", " EndTime value:  " + context.Request["EndTime"]);
            //Log("C:\\temp2\\", "log.log", " CallStatus value:  " + context.Request["CallStatus"]);
            //Log("C:\\temp2\\", "log.log", " Event value:  " + context.Request["Event"]);
        }