private void ReplySendSMS()
        {
            string URL;
            DataTable MtIncomingSMS = new DataTable();
            WebClient oWeb = new WebClient();
            Byte[] bytHeaders;
            SMSView smsview = new SMSView();
            DataTable dtinsms = new DataTable();
            DataTable dtqstatus = new DataTable();
            DataTable flagupdate = new DataTable();
            SMSController smscontroller = new SMSController();
            dtinsms = smscontroller.GetIncomingSMS(smsview);
            if (dtinsms.Rows.Count > 0)
            {

                foreach (DataRow dr in dtinsms.Rows)
                {
                    string PhoneNumber = (Convert.ToString(dr["sms_phoneno"].ToString()));
                    smsview.MySms = (Convert.ToString(dr["sms_content"].ToString()));
                    string SmsStatusMsg = string.Empty;
                    string SmsDeliveryStatus = string.Empty;
                    dtqstatus = smscontroller.GetQueueStatus(smsview);
                    DataTable dtWcount = new DataTable();
                    smsview.QueueStatusID = Convert.ToInt32(dtqstatus.Rows[0][0]);
                    if (dtqstatus.Rows.Count > 0)
                    {
                        if (smsview.QueueStatusID == 1)
                        {

                            try
                            {
                                // SMSWaitingQueueCount
                                DataTable dttnx = new DataTable();
                                dttnx = smscontroller.Getvisittnxidbyusingrepliedsms(smsview);
                                foreach (DataRow drtnx in dttnx.Rows)
                                {
                                    smsview.QueueTransaction = (Convert.ToInt32(drtnx["visit_tnx_id"].ToString()));

                                    // SMSWaitingQueueCount
                                    DataTable dttab = new DataTable();
                                    dttab = smscontroller.GetDeptid(smsview);
                                    foreach (DataRow dttb in dttab.Rows)
                                    {
                                        smsview.DepartmentID = (Convert.ToInt32(dttb["queue_department_id"].ToString()));
                                        DataTable dtcount = new DataTable();
                                        dtcount = smscontroller.GetStatusCount(smsview);
                                        foreach (DataRow c in dtcount.Rows)
                                        {
                                            QueueToken = (c["visit_queue_no_show"].ToString());
                                            for (int i = 0; i < dtcount.Rows.Count; i++)
                                            {
                                                int pos = 0;
                                                if (dtcount != null && dtcount.Rows.Count > 0 && Convert.ToString(dtcount.Rows[i]["visit_queue_no_show"]).Equals(QueueToken))
                                                // if (dt.Rows[i]["visit_queue_no_show"] == QueueToken)
                                                {
                                                    pos = i;

                                                    if (pos > 0)
                                                    {
                                                        int t = pos * 5;
                                                        TimeSpan span = TimeSpan.FromMinutes(t);
                                                        string aptime = span.ToString(@"hh\:mm");
                                                        DataTable dtcid = new DataTable();
                                                        dtcid = smscontroller.GetCustIDByUsingQueueno(smsview);
                                                        foreach (DataRow drcid in dtcid.Rows)
                                                        {
                                                            smsview.CustId = (Convert.ToInt32(drcid["visit_customer_id"].ToString()));

                                                            string str1 = "Your Queue NO:" + QueueToken + " is in waiting state.\r\nYou have " + pos + " person yet to be served.Approximate waiting time " + aptime + " Hours.\r\nYour will be called Shortly.\r\nplease proceed to the waiting area.";
                                                            //URL = "http://sms.proactivesms.in/sendsms.jsp?user=attsystm&password=attsystm&mobiles=" + PhoneNumber + "&sms=" + strmsg1 + "&senderid=ATTIPL";
                                                            //URL = "https://api.aussiesms.com.au/?sendsms&mobileID=61422889101&password=att0424&to=" + PhoneNumber + "&text=" + strmsg1 + "&from=QSoft&msg_type=SMS_TEXT";
                                                            // URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&from=Qsoft&to=" + PhoneNumber + "&text=" + strmsg1 + "";
                                                            //bytHeaders = System.Text.ASCIIEncoding.UTF8.GetBytes("*****@*****.**" + ":" + "EqMs2015");
                                                            //oWeb.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(bytHeaders));
                                                            //oWeb.Headers.Add("Content-Type", "text/plain;charset=utf-8");
                                                            ////string URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&api=1&to=" + MissedPhoneNo + "&text=" + strmsg1 + "";
                                                            //URL = "https://tim.telstra.com/cgphttp/servlet/[email protected]&Password=Qsoft123&destination=" + PhoneNumber + "&text=" + strmsg1 + "";


                                                            // SmsStatusMsg = client.DownloadString(URL);
                                                            //SmsStatusMsg = SmsStatusMsg.Replace("\r\n", "");
                                                            //SmsStatusMsg = SmsStatusMsg.Replace("\t", "");
                                                            //SmsStatusMsg = SmsStatusMsg.Replace("\n", "");
                                                            //XmlDocument xml = new XmlDocument();
                                                            //xml.LoadXml(SmsStatusMsg); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                                            //XmlNodeList xnList = xml.SelectNodes("smslist");
                                                            //foreach (XmlNode xn in xnList)
                                                            //{
                                                            //    XmlNode example = xn.SelectSingleNode("sms");
                                                            //    if (example != null)
                                                            //    {
                                                            //        string na = example["messageid"].InnerText;
                                                            //        string no = example["smsclientid"].InnerText;
                                                            //        string mobileno = example["mobile-no"].InnerText;
                                                            //        string URL1 = "http://sms.proactivesms.in/getDLR.jsp?userid=attsystm&password=attsystm&messageid=" + na + "redownload=yes&responce type=xml";

                                                            //        SmsDeliveryStatus = client.DownloadString(URL1);
                                                            //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\r\n", "");
                                                            //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\t", "");
                                                            //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\n", "");
                                                            //        XmlDocument xml1 = new XmlDocument();
                                                            //        xml.LoadXml(SmsDeliveryStatus); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                                            //        //XmlNodeList xnList1 = xml.SelectNodes("response");

                                                            //        //foreach (XmlNode xn1 in xnList1)
                                                            //        //{
                                                            //        XmlNode example1 = xml.SelectSingleNode("response");
                                                            //        if (example1 != null)
                                                            //        {
                                                            //            //string rscode = example1["responsecode"].InnerText;
                                                            //            smsview.DeliveryReport = example1["resposedescription"].InnerText;
                                                            //            //string dlrcount = example1["dlristcount"].InnerText;
                                                            //            //string pendingcount = example1["pendingdrcount"].InnerText;

                                                            //        }
                                                            //    }

                                                            //}

                                                            #region Samsung SMS gateway
                                                            //SMS for Samsung gateway
                                                            // Set the username of the account holder.
                                                            Messaging.MessageController.UserAccount.User = "******";
                                                            // Set the password of the account holder.
                                                            Messaging.MessageController.UserAccount.Password = "******";
                                                            // Set the first name of the account holder (optional).
                                                            Messaging.MessageController.UserAccount.ContactFirstName = "David";
                                                            // Set the last name of the account holder (optional).
                                                            Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                                                            // Set the mobile phone number of the account holder (optional).
                                                            Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                                                            // Set the landline phone number of the account holder (optional).
                                                            Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                                                            // Set the contact email of the account holder (optional).
                                                            Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                                                            // Set the country of origin of the account holder (optional).
                                                            Messaging.MessageController.UserAccount.Country = Countries.Australia;
                                                            bool testOK = false;
                                                            try
                                                            {
                                                                // Test the user account settings.
                                                                Account testAccount = Messaging.MessageController.UserAccount;
                                                                testOK = Messaging.MessageController.TestAccount(testAccount);
                                                            }
                                                            catch (Exception ex)
                                                            {
                                                                // An exception was thrown. Display the details of the exception and return.
                                                                string message = "There was an error testing the connection details:\n" +
                                                                ex.Message;
                                                                // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                                                                return;
                                                            }
                                                            if (testOK)
                                                            {
                                                                // The user account settings were valid. Display a success message
                                                                // box with the number of credits.
                                                                int balance = Messaging.MessageController.UserAccount.Balance;
                                                                string message = string.Format("You have {0} message credits available.",
                                                                balance);
                                                                // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                                                            }
                                                            else
                                                            {
                                                                // The username or password were incorrect. Display a failed message box.
                                                                //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                                                                // "Connection Failed", MessageBoxButtons.OK);
                                                            }

                                                            Messaging.MessageController.Settings.TimeOut = 60;
                                                            // Set the batch size (number of messages to be sent at once) to 200.
                                                            Messaging.MessageController.Settings.BatchSize = 200;
                                                            //string strmsg = "To confirm an appointment with the Samsung Experience Store,\r\nyou will need 4 characters password. The password is  " + strrandom + "";
                                                            //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                                            //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                                            //string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";

                                                            //"Hi Kara, your ticket number is 040, Approximate waiting time is 00:40 minutes/hours”

                                                            Messaging.MessageController.Settings.DeliveryReport = true;
                                                            // SMSMessage smsobj = new SMSMessage(smsview.QueueStatusID, str1);
                                                            // Messaging.MessageController.AddToQueue(smsobj);
                                                            Messaging.MessageController.SendMessages();
                                                            //end of Samsung SMS
                                                            #endregion Samsung SMS gateway



                                                            if (SmsStatusMsg.Contains("<br>"))
                                                            {
                                                                SmsStatusMsg = SmsStatusMsg.Replace("<br>", ", ");
                                                            }
                                                            smsview.QueueNo = QueueToken;
                                                            DateTime dattime = System.DateTime.Now;
                                                            smsview.SMSDateTime = dattime;
                                                            smsview.SMSStatusFlag = "R";
                                                            smsview.Message = str1;
                                                            smsview.PhoneNo = PhoneNumber;
                                                            smscontroller.GetInsertReplySMS(smsview);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        int t = 5;
                                                        TimeSpan span = TimeSpan.FromMinutes(t);
                                                        string aptime = span.ToString(@"hh\:mm");
                                                        DataTable dtcid = new DataTable();
                                                        dtcid = smscontroller.GetCustIDByUsingQueueno(smsview);
                                                        foreach (DataRow drcid in dtcid.Rows)
                                                        {
                                                            smsview.CustId = (Convert.ToInt32(drcid["visit_customer_id"].ToString()));

                                                            string strmsg1 = "Your Queue NO:" + QueueToken + " is in waiting state.\r\nYou are the next person to be served.Approximate waiting time " + aptime + " Hours\r\nplease proceed to the waiting area.";
                                                            //URL = "http://sms.proactivesms.in/sendsms.jsp?user=attsystm&password=attsystm&mobiles=" + PhoneNumber + "&sms=" + strmsg1 + "&senderid=ATTIPL";
                                                            //URL = "https://api.aussiesms.com.au/?sendsms&mobileID=61422889101&password=att0424&to=" + PhoneNumber + "&text=" + strmsg1 + "&from=QSoft&msg_type=SMS_TEXT";
                                                            // URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&from=Qsoft&to=" + PhoneNumber + "&text=" + strmsg1 + "";
                                                            //bytHeaders = System.Text.ASCIIEncoding.UTF8.GetBytes("*****@*****.**" + ":" + "EqMs2015");
                                                            //oWeb.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(bytHeaders));
                                                            //oWeb.Headers.Add("Content-Type", "text/plain;charset=utf-8");
                                                            ////string URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&api=1&to=" + MissedPhoneNo + "&text=" + strmsg1 + "";
                                                            //URL = "https://tim.telstra.com/cgphttp/servlet/[email protected]&Password=Qsoft123&destination=" + PhoneNumber + "&text=" + strmsg1 + "";


                                                            //SmsStatusMsg = client.DownloadString(URL);
                                                            //SmsStatusMsg = SmsStatusMsg.Replace("\r\n", "");
                                                            //SmsStatusMsg = SmsStatusMsg.Replace("\t", "");
                                                            //SmsStatusMsg = SmsStatusMsg.Replace("\n", "");
                                                            //XmlDocument xml = new XmlDocument();
                                                            //xml.LoadXml(SmsStatusMsg); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                                            //XmlNodeList xnList = xml.SelectNodes("smslist");
                                                            //foreach (XmlNode xn in xnList)
                                                            //{
                                                            //    XmlNode example = xn.SelectSingleNode("sms");
                                                            //    if (example != null)
                                                            //    {
                                                            //        string na = example["messageid"].InnerText;
                                                            //        string no = example["smsclientid"].InnerText;
                                                            //        string mobileno = example["mobile-no"].InnerText;
                                                            //        string URL1 = "http://sms.proactivesms.in/getDLR.jsp?userid=attsystm&password=attsystm&messageid=" + na + "redownload=yes&responce type=xml";

                                                            //        SmsDeliveryStatus = client.DownloadString(URL1);
                                                            //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\r\n", "");
                                                            //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\t", "");
                                                            //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\n", "");
                                                            //        XmlDocument xml1 = new XmlDocument();
                                                            //        xml.LoadXml(SmsDeliveryStatus); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                                            //        //XmlNodeList xnList1 = xml.SelectNodes("response");

                                                            //        //foreach (XmlNode xn1 in xnList1)
                                                            //        //{
                                                            //        XmlNode example1 = xml.SelectSingleNode("response");
                                                            //        if (example1 != null)
                                                            //        {
                                                            //            //string rscode = example1["responsecode"].InnerText;
                                                            //            smsview.DeliveryReport = example1["resposedescription"].InnerText;
                                                            //            //string dlrcount = example1["dlristcount"].InnerText;
                                                            //            //string pendingcount = example1["pendingdrcount"].InnerText;

                                                            //        }
                                                            //    }

                                                            //}
                                                            #region Samsung SMS gateway
                                                            //SMS for Samsung gateway
                                                            // Set the username of the account holder.
                                                            Messaging.MessageController.UserAccount.User = "******";
                                                            // Set the password of the account holder.
                                                            Messaging.MessageController.UserAccount.Password = "******";
                                                            // Set the first name of the account holder (optional).
                                                            Messaging.MessageController.UserAccount.ContactFirstName = "David";
                                                            // Set the last name of the account holder (optional).
                                                            Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                                                            // Set the mobile phone number of the account holder (optional).
                                                            Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                                                            // Set the landline phone number of the account holder (optional).
                                                            Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                                                            // Set the contact email of the account holder (optional).
                                                            Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                                                            // Set the country of origin of the account holder (optional).
                                                            Messaging.MessageController.UserAccount.Country = Countries.Australia;
                                                            bool testOK = false;
                                                            try
                                                            {
                                                                // Test the user account settings.
                                                                Account testAccount = Messaging.MessageController.UserAccount;
                                                                testOK = Messaging.MessageController.TestAccount(testAccount);
                                                            }
                                                            catch (Exception ex)
                                                            {
                                                                // An exception was thrown. Display the details of the exception and return.
                                                                string message = "There was an error testing the connection details:\n" +
                                                                ex.Message;
                                                                // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                                                                return;
                                                            }
                                                            if (testOK)
                                                            {
                                                                // The user account settings were valid. Display a success message
                                                                // box with the number of credits.
                                                                int balance = Messaging.MessageController.UserAccount.Balance;
                                                                string message = string.Format("You have {0} message credits available.",
                                                                balance);
                                                                // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                                                            }
                                                            else
                                                            {
                                                                // The username or password were incorrect. Display a failed message box.
                                                                //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                                                                // "Connection Failed", MessageBoxButtons.OK);
                                                            }

                                                            Messaging.MessageController.Settings.TimeOut = 60;
                                                            // Set the batch size (number of messages to be sent at once) to 200.
                                                            Messaging.MessageController.Settings.BatchSize = 200;
                                                            //string strmsg = "To confirm an appointment with the Samsung Experience Store,\r\nyou will need 4 characters password. The password is  " + strrandom + "";
                                                            //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                                            //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                                            //string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";

                                                            //"Hi Kara, your ticket number is 040, Approximate waiting time is 00:40 minutes/hours”

                                                            Messaging.MessageController.Settings.DeliveryReport = true;
                                                            //SMSMessage smsobj = new SMSMessage(MissedPhoneNo, strmsg);
                                                            //Messaging.MessageController.AddToQueue(smsobj);
                                                            Messaging.MessageController.SendMessages();
                                                            //end of Samsung SMS
                                                            #endregion Samsung SMS gateway


                                                            if (SmsStatusMsg.Contains("<br>"))
                                                            {
                                                                SmsStatusMsg = SmsStatusMsg.Replace("<br>", ", ");
                                                            }
                                                            smsview.QueueNo = QueueToken;
                                                            DateTime dattime = System.DateTime.Now;
                                                            smsview.SMSDateTime = dattime;
                                                            smsview.SMSStatusFlag = "R";
                                                            smsview.Message = strmsg1;
                                                            smsview.PhoneNo = PhoneNumber;
                                                            smscontroller.GetInsertReplySMS(smsview);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            catch (WebException e1)
                            {
                                SmsStatusMsg = e1.Message;
                            }
                            catch (Exception e2)
                            {
                                SmsStatusMsg = e2.Message;
                            }
                            //smsview.InsmsStatus = "S";
                            //dtinsms = smscontroller.GetIncomingSMS(smsview);
                            //smsview.MySms = (Convert.ToString(dr["incomingsms"].ToString()));
                            //flagupdate = smscontroller.GetsmsStatusFlag(smsview);
                        }
                        else if (smsview.QueueStatusID == 2)
                        {
                            try
                            {
                                DataTable dtcid = new DataTable();
                                dtcid = smscontroller.GetCustIDByUsingQueueno(smsview);
                                foreach (DataRow drcid in dtcid.Rows)
                                {
                                    smsview.CustId = (Convert.ToInt32(drcid["visit_customer_id"].ToString()));
                                    string strmsg1 = "Thank you for asking your Q status...\r\nYour Queue NO:" + QueueToken + " is Serving";
                                    //URL = "http://sms.proactivesms.in/sendsms.jsp?user=attsystm&password=attsystm&mobiles=" + PhoneNumber + "&sms=" + strmsg1 + "&senderid=ATTIPL";
                                    //URL = "https://api.aussiesms.com.au/?sendsms&mobileID=61422889101&password=att0424&to=" + PhoneNumber + "&text=" + strmsg1 + "&from=QSoft&msg_type=SMS_TEXT";
                                    // URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&from=Qsoft&to=" + PhoneNumber + "&text=" + strmsg1 + "";
                                    //bytHeaders = System.Text.ASCIIEncoding.UTF8.GetBytes("*****@*****.**" + ":" + "EqMs2015");
                                    //oWeb.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(bytHeaders));
                                    //oWeb.Headers.Add("Content-Type", "text/plain;charset=utf-8");
                                    ////string URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&api=1&to=" + MissedPhoneNo + "&text=" + strmsg1 + "";
                                    //URL = "https://tim.telstra.com/cgphttp/servlet/[email protected]&Password=Qsoft123&destination=" + PhoneNumber + "&text=" + strmsg1 + "";


                                    // SmsStatusMsg = client.DownloadString(URL);
                                    //SmsStatusMsg = SmsStatusMsg.Replace("\r\n", "");
                                    //SmsStatusMsg = SmsStatusMsg.Replace("\t", "");
                                    //SmsStatusMsg = SmsStatusMsg.Replace("\n", "");
                                    //XmlDocument xml = new XmlDocument();
                                    //xml.LoadXml(SmsStatusMsg); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                    //XmlNodeList xnList = xml.SelectNodes("smslist");
                                    //foreach (XmlNode xn in xnList)
                                    //{
                                    //    XmlNode example = xn.SelectSingleNode("sms");
                                    //    if (example != null)
                                    //    {
                                    //        string na = example["messageid"].InnerText;
                                    //        string no = example["smsclientid"].InnerText;
                                    //        string mobileno = example["mobile-no"].InnerText;
                                    //        string URL1 = "http://sms.proactivesms.in/getDLR.jsp?userid=attsystm&password=attsystm&messageid=" + na + "redownload=yes&responce type=xml";

                                    //        SmsDeliveryStatus = client.DownloadString(URL1);
                                    //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\r\n", "");
                                    //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\t", "");
                                    //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\n", "");
                                    //        XmlDocument xml1 = new XmlDocument();
                                    //        xml.LoadXml(SmsDeliveryStatus); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                    //        //XmlNodeList xnList1 = xml.SelectNodes("response");

                                    //        //foreach (XmlNode xn1 in xnList1)
                                    //        //{
                                    //        XmlNode example1 = xml.SelectSingleNode("response");
                                    //        if (example1 != null)
                                    //        {
                                    //            //string rscode = example1["responsecode"].InnerText;
                                    //            smsview.DeliveryReport = example1["resposedescription"].InnerText;
                                    //            //string dlrcount = example1["dlristcount"].InnerText;
                                    //            //string pendingcount = example1["pendingdrcount"].InnerText;

                                    //        }
                                    //    }

                                    // }
                                    #region Samsung SMS gateway
                                    //SMS for Samsung gateway
                                    // Set the username of the account holder.
                                    Messaging.MessageController.UserAccount.User = "******";
                                    // Set the password of the account holder.
                                    Messaging.MessageController.UserAccount.Password = "******";
                                    // Set the first name of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactFirstName = "David";
                                    // Set the last name of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                                    // Set the mobile phone number of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                                    // Set the landline phone number of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                                    // Set the contact email of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                                    // Set the country of origin of the account holder (optional).
                                    Messaging.MessageController.UserAccount.Country = Countries.Australia;
                                    bool testOK = false;
                                    try
                                    {
                                        // Test the user account settings.
                                        Account testAccount = Messaging.MessageController.UserAccount;
                                        testOK = Messaging.MessageController.TestAccount(testAccount);
                                    }
                                    catch (Exception ex)
                                    {
                                        // An exception was thrown. Display the details of the exception and return.
                                        string message = "There was an error testing the connection details:\n" +
                                        ex.Message;
                                        // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                                        return;
                                    }
                                    if (testOK)
                                    {
                                        // The user account settings were valid. Display a success message
                                        // box with the number of credits.
                                        int balance = Messaging.MessageController.UserAccount.Balance;
                                        string message = string.Format("You have {0} message credits available.",
                                        balance);
                                        // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                                    }
                                    else
                                    {
                                        // The username or password were incorrect. Display a failed message box.
                                        //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                                        // "Connection Failed", MessageBoxButtons.OK);
                                    }

                                    Messaging.MessageController.Settings.TimeOut = 60;
                                    // Set the batch size (number of messages to be sent at once) to 200.
                                    Messaging.MessageController.Settings.BatchSize = 200;
                                    //string strmsg = "To confirm an appointment with the Samsung Experience Store,\r\nyou will need 4 characters password. The password is  " + strrandom + "";
                                    //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                    //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                    //string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";

                                    //"Hi Kara, your ticket number is 040, Approximate waiting time is 00:40 minutes/hours”

                                    Messaging.MessageController.Settings.DeliveryReport = true;
                                    //SMSMessage smsobj = new SMSMessage(MissedPhoneNo, strmsg);
                                    //Messaging.MessageController.AddToQueue(smsobj);
                                    Messaging.MessageController.SendMessages();
                                    //end of Samsung SMS
                                    #endregion Samsung SMS gateway



                                    if (SmsStatusMsg.Contains("<br>"))
                                    {
                                        SmsStatusMsg = SmsStatusMsg.Replace("<br>", ", ");
                                    }
                                    smsview.QueueNo = QueueToken;
                                    DateTime dattime = System.DateTime.Now;
                                    smsview.SMSDateTime = dattime;
                                    smsview.SMSStatusFlag = "R";
                                    smsview.Message = strmsg1;
                                    smsview.PhoneNo = PhoneNumber;
                                    smscontroller.GetInsertReplySMS(smsview);
                                }
                            }
                            catch (WebException e1)
                            {
                                SmsStatusMsg = e1.Message;
                            }
                            catch (Exception e2)
                            {
                                SmsStatusMsg = e2.Message;
                            }
                            //smsview.InsmsStatus = "S";
                            //dtinsms = smscontroller.GetIncomingSMS(smsview);
                            //smsview.MySms = (Convert.ToString(dr["incomingsms"].ToString()));
                            //flagupdate = smscontroller.GetsmsStatusFlag(smsview);
                        }
                        else if (smsview.QueueStatusID == 3)
                        {
                            try
                            {
                                DataTable dtcid = new DataTable();
                                dtcid = smscontroller.GetCustIDByUsingQueueno(smsview);
                                foreach (DataRow drcid in dtcid.Rows)
                                {
                                    string strmsg1 = "Thank you for asking your Q status...\r\nYour Queue NO:" + QueueToken + " is Ended\r\nThank you, Please visit again";
                                    //URL = "http://sms.proactivesms.in/sendsms.jsp?user=attsystm&password=attsystm&mobiles=" + PhoneNumber + "&sms=" + strmsg1 + "&senderid=ATTIPL";
                                    //URL = "https://api.aussiesms.com.au/?sendsms&mobileID=61422889101&password=att0424&to=" + PhoneNumber + "&text=" + strmsg1 + "&from=QSoft&msg_type=SMS_TEXT";
                                    // URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&from=Qsoft&to=" + PhoneNumber + "&text=" + strmsg1 + "";
                                    //bytHeaders = System.Text.ASCIIEncoding.UTF8.GetBytes("*****@*****.**" + ":" + "EqMs2015");
                                    //oWeb.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(bytHeaders));
                                    //oWeb.Headers.Add("Content-Type", "text/plain;charset=utf-8");
                                    ////string URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&api=1&to=" + MissedPhoneNo + "&text=" + strmsg1 + "";
                                    //URL = "https://tim.telstra.com/cgphttp/servlet/[email protected]&Password=Qsoft123&destination=" + PhoneNumber + "&text=" + strmsg1 + "";


                                    // SmsStatusMsg = client.DownloadString(URL);
                                    //SmsStatusMsg = SmsStatusMsg.Replace("\r\n", "");
                                    //SmsStatusMsg = SmsStatusMsg.Replace("\t", "");
                                    //SmsStatusMsg = SmsStatusMsg.Replace("\n", "");
                                    //XmlDocument xml = new XmlDocument();
                                    //xml.LoadXml(SmsStatusMsg); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                    //XmlNodeList xnList = xml.SelectNodes("smslist");
                                    //foreach (XmlNode xn in xnList)
                                    //{
                                    //    XmlNode example = xn.SelectSingleNode("sms");
                                    //    if (example != null)
                                    //    {
                                    //        string na = example["messageid"].InnerText;
                                    //        string no = example["smsclientid"].InnerText;
                                    //        string mobileno = example["mobile-no"].InnerText;
                                    //        string URL1 = "http://sms.proactivesms.in/getDLR.jsp?userid=attsystm&password=attsystm&messageid=" + na + "redownload=yes&responce type=xml";

                                    //        SmsDeliveryStatus = client.DownloadString(URL1);
                                    //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\r\n", "");
                                    //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\t", "");
                                    //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\n", "");
                                    //        XmlDocument xml1 = new XmlDocument();
                                    //        xml.LoadXml(SmsDeliveryStatus); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                    //        //XmlNodeList xnList1 = xml.SelectNodes("response");

                                    //        //foreach (XmlNode xn1 in xnList1)
                                    //        //{
                                    //        XmlNode example1 = xml.SelectSingleNode("response");
                                    //        if (example1 != null)
                                    //        {
                                    //            //string rscode = example1["responsecode"].InnerText;
                                    //            smsview.DeliveryReport = example1["resposedescription"].InnerText;
                                    //            //string dlrcount = example1["dlristcount"].InnerText;
                                    //            //string pendingcount = example1["pendingdrcount"].InnerText;

                                    //        }
                                    //    }

                                    //}

                                    #region Samsung SMS gateway
                                    //SMS for Samsung gateway
                                    // Set the username of the account holder.
                                    Messaging.MessageController.UserAccount.User = "******";
                                    // Set the password of the account holder.
                                    Messaging.MessageController.UserAccount.Password = "******";
                                    // Set the first name of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactFirstName = "David";
                                    // Set the last name of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                                    // Set the mobile phone number of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                                    // Set the landline phone number of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                                    // Set the contact email of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                                    // Set the country of origin of the account holder (optional).
                                    Messaging.MessageController.UserAccount.Country = Countries.Australia;
                                    bool testOK = false;
                                    try
                                    {
                                        // Test the user account settings.
                                        Account testAccount = Messaging.MessageController.UserAccount;
                                        testOK = Messaging.MessageController.TestAccount(testAccount);
                                    }
                                    catch (Exception ex)
                                    {
                                        // An exception was thrown. Display the details of the exception and return.
                                        string message = "There was an error testing the connection details:\n" +
                                        ex.Message;
                                        // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                                        return;
                                    }
                                    if (testOK)
                                    {
                                        // The user account settings were valid. Display a success message
                                        // box with the number of credits.
                                        int balance = Messaging.MessageController.UserAccount.Balance;
                                        string message = string.Format("You have {0} message credits available.",
                                        balance);
                                        // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                                    }
                                    else
                                    {
                                        // The username or password were incorrect. Display a failed message box.
                                        //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                                        // "Connection Failed", MessageBoxButtons.OK);
                                    }

                                    Messaging.MessageController.Settings.TimeOut = 60;
                                    // Set the batch size (number of messages to be sent at once) to 200.
                                    Messaging.MessageController.Settings.BatchSize = 200;
                                    //string strmsg = "To confirm an appointment with the Samsung Experience Store,\r\nyou will need 4 characters password. The password is  " + strrandom + "";
                                    //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                    //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                    //string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";

                                    //"Hi Kara, your ticket number is 040, Approximate waiting time is 00:40 minutes/hours”

                                    Messaging.MessageController.Settings.DeliveryReport = true;
                                    //SMSMessage smsobj = new SMSMessage(MissedPhoneNo, strmsg);
                                    //Messaging.MessageController.AddToQueue(smsobj);
                                    Messaging.MessageController.SendMessages();
                                    //end of Samsung SMS
                                    #endregion Samsung SMS gateway


                                    if (SmsStatusMsg.Contains("<br>"))
                                    {
                                        SmsStatusMsg = SmsStatusMsg.Replace("<br>", ", ");
                                    }
                                    smsview.QueueNo = QueueToken;
                                    DateTime dattime = System.DateTime.Now;
                                    smsview.SMSDateTime = dattime;
                                    smsview.SMSStatusFlag = "R";
                                    smsview.Message = strmsg1;
                                    smsview.PhoneNo = PhoneNumber;
                                    smscontroller.GetInsertReplySMS(smsview);
                                }
                            }
                            catch (WebException e1)
                            {
                                SmsStatusMsg = e1.Message;
                            }
                            catch (Exception e2)
                            {
                                SmsStatusMsg = e2.Message;
                            }
                            //smsview.InsmsStatus = "S";
                            //dtinsms = smscontroller.GetIncomingSMS(smsview);
                            //smsview.MySms = (Convert.ToString(dr["incomingsms"].ToString()));
                            //flagupdate = smscontroller.GetsmsStatusFlag(smsview);
                        }
                        else if (smsview.QueueStatusID == 4)
                        {
                            try
                            {
                                DataTable dtcid = new DataTable();
                                dtcid = smscontroller.GetCustIDByUsingQueueno(smsview);
                                foreach (DataRow drcid in dtcid.Rows)
                                {
                                    string strmsg1 = "Thank you for asking your Q status...\r\nYour Queue is missed. Please contact reception for assistance.";
                                    //URL = "http://sms.proactivesms.in/sendsms.jsp?user=attsystm&password=attsystm&mobiles=" + PhoneNumber + "&sms=" + strmsg1 + "&senderid=ATTIPL";
                                    //URL = "https://api.aussiesms.com.au/?sendsms&mobileID=61422889101&password=att0424&to=" + PhoneNumber + "&text=" + strmsg1 + "&from=QSoft&msg_type=SMS_TEXT";
                                    //URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&from=Qsoft&to=" + PhoneNumber + "&text=" + strmsg1 + "";
                                    //bytHeaders = System.Text.ASCIIEncoding.UTF8.GetBytes("*****@*****.**" + ":" + "EqMs2015");
                                    //oWeb.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(bytHeaders));
                                    //oWeb.Headers.Add("Content-Type", "text/plain;charset=utf-8");
                                    ////string URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&api=1&to=" + MissedPhoneNo + "&text=" + strmsg1 + "";
                                    //URL = "https://tim.telstra.com/cgphttp/servlet/[email protected]&Password=Qsoft123&destination=" + PhoneNumber + "&text=" + strmsg1 + "";


                                    // SmsStatusMsg = client.DownloadString(URL);
                                    //SmsStatusMsg = SmsStatusMsg.Replace("\r\n", "");
                                    //SmsStatusMsg = SmsStatusMsg.Replace("\t", "");
                                    //SmsStatusMsg = SmsStatusMsg.Replace("\n", "");
                                    //XmlDocument xml = new XmlDocument();
                                    //xml.LoadXml(SmsStatusMsg); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                    //XmlNodeList xnList = xml.SelectNodes("smslist");
                                    //foreach (XmlNode xn in xnList)
                                    //{
                                    //    XmlNode example = xn.SelectSingleNode("sms");
                                    //    if (example != null)
                                    //    {
                                    //        string na = example["messageid"].InnerText;
                                    //        string no = example["smsclientid"].InnerText;
                                    //        string mobileno = example["mobile-no"].InnerText;
                                    //        string URL1 = "http://sms.proactivesms.in/getDLR.jsp?userid=attsystm&password=attsystm&messageid=" + na + "redownload=yes&responce type=xml";

                                    //        SmsDeliveryStatus = client.DownloadString(URL1);
                                    //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\r\n", "");
                                    //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\t", "");
                                    //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\n", "");
                                    //        XmlDocument xml1 = new XmlDocument();
                                    //        xml.LoadXml(SmsDeliveryStatus); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                    //        //XmlNodeList xnList1 = xml.SelectNodes("response");

                                    //        //foreach (XmlNode xn1 in xnList1)
                                    //        //{
                                    //        XmlNode example1 = xml.SelectSingleNode("response");
                                    //        if (example1 != null)
                                    //        {
                                    //            //string rscode = example1["responsecode"].InnerText;
                                    //            smsview.DeliveryReport = example1["resposedescription"].InnerText;
                                    //            //string dlrcount = example1["dlristcount"].InnerText;
                                    //            //string pendingcount = example1["pendingdrcount"].InnerText;

                                    //        }
                                    //    }

                                    //}
                                    #region Samsung SMS gateway
                                    //SMS for Samsung gateway
                                    // Set the username of the account holder.
                                    Messaging.MessageController.UserAccount.User = "******";
                                    // Set the password of the account holder.
                                    Messaging.MessageController.UserAccount.Password = "******";
                                    // Set the first name of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactFirstName = "David";
                                    // Set the last name of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                                    // Set the mobile phone number of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                                    // Set the landline phone number of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                                    // Set the contact email of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                                    // Set the country of origin of the account holder (optional).
                                    Messaging.MessageController.UserAccount.Country = Countries.Australia;
                                    bool testOK = false;
                                    try
                                    {
                                        // Test the user account settings.
                                        Account testAccount = Messaging.MessageController.UserAccount;
                                        testOK = Messaging.MessageController.TestAccount(testAccount);
                                    }
                                    catch (Exception ex)
                                    {
                                        // An exception was thrown. Display the details of the exception and return.
                                        string message = "There was an error testing the connection details:\n" +
                                        ex.Message;
                                        // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                                        return;
                                    }
                                    if (testOK)
                                    {
                                        // The user account settings were valid. Display a success message
                                        // box with the number of credits.
                                        int balance = Messaging.MessageController.UserAccount.Balance;
                                        string message = string.Format("You have {0} message credits available.",
                                        balance);
                                        // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                                    }
                                    else
                                    {
                                        // The username or password were incorrect. Display a failed message box.
                                        //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                                        // "Connection Failed", MessageBoxButtons.OK);
                                    }

                                    Messaging.MessageController.Settings.TimeOut = 60;
                                    // Set the batch size (number of messages to be sent at once) to 200.
                                    Messaging.MessageController.Settings.BatchSize = 200;
                                    //string strmsg = "To confirm an appointment with the Samsung Experience Store,\r\nyou will need 4 characters password. The password is  " + strrandom + "";
                                    //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                    //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                    //string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";

                                    //"Hi Kara, your ticket number is 040, Approximate waiting time is 00:40 minutes/hours”

                                    Messaging.MessageController.Settings.DeliveryReport = true;
                                    //SMSMessage smsobj = new SMSMessage(MissedPhoneNo, strmsg);
                                    //Messaging.MessageController.AddToQueue(smsobj);
                                    Messaging.MessageController.SendMessages();
                                    //end of Samsung SMS
                                    #endregion Samsung SMS gateway



                                    if (SmsStatusMsg.Contains("<br>"))
                                    {
                                        SmsStatusMsg = SmsStatusMsg.Replace("<br>", ", ");
                                    }
                                    smsview.QueueNo = QueueToken;
                                    DateTime dattime = System.DateTime.Now;
                                    smsview.SMSDateTime = dattime;
                                    smsview.SMSStatusFlag = "R";
                                    smsview.Message = strmsg1;
                                    smsview.PhoneNo = PhoneNumber;
                                    smscontroller.GetInsertReplySMS(smsview);
                                }
                            }
                            catch (WebException e1)
                            {
                                SmsStatusMsg = e1.Message;
                            }
                            catch (Exception e2)
                            {
                                SmsStatusMsg = e2.Message;
                            }
                            //smsview.InsmsStatus = "S";
                            //dtinsms = smscontroller.GetIncomingSMS(smsview);
                            //smsview.MySms = (Convert.ToString(dr["incomingsms"].ToString()));
                            //flagupdate = smscontroller.GetsmsStatusFlag(smsview);
                        }
                        else if (smsview.QueueStatusID == 5)
                        {
                            try
                            {
                                DataTable dtcid = new DataTable();
                                dtcid = smscontroller.GetCustIDByUsingQueueno(smsview);
                                foreach (DataRow drcid in dtcid.Rows)
                                {
                                    string strmsg1 = "Thank you for asking your Q status...\r\nYour Queue is On hold";
                                    //URL = "http://sms.proactivesms.in/sendsms.jsp?user=attsystm&password=attsystm&mobiles=" + PhoneNumber + "&sms=" + strmsg1 + "&senderid=ATTIPL";
                                    //URL = "https://api.aussiesms.com.au/?sendsms&mobileID=61422889101&password=att0424&to=" + PhoneNumber + "&text=" + strmsg1 + "&from=QSoft&msg_type=SMS_TEXT";
                                    // URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&from=Qsoft&to=" + PhoneNumber + "&text=" + strmsg1 + "";
                                    //bytHeaders = System.Text.ASCIIEncoding.UTF8.GetBytes("*****@*****.**" + ":" + "EqMs2015");
                                    //oWeb.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(bytHeaders));
                                    //oWeb.Headers.Add("Content-Type", "text/plain;charset=utf-8");
                                    ////string URL = "http://www.smsglobal.com/http-api.php?action=sendsms&user=yahtz6o2&password=46yAfp0i&api=1&to=" + MissedPhoneNo + "&text=" + strmsg1 + "";
                                    //URL = "https://tim.telstra.com/cgphttp/servlet/[email protected]&Password=Qsoft123&destination=" + PhoneNumber + "&text=" + strmsg1 + "";

                                    // SmsStatusMsg = client.DownloadString(URL);
                                    //SmsStatusMsg = SmsStatusMsg.Replace("\r\n", "");
                                    //SmsStatusMsg = SmsStatusMsg.Replace("\t", "");
                                    //SmsStatusMsg = SmsStatusMsg.Replace("\n", "");
                                    //XmlDocument xml = new XmlDocument();
                                    //xml.LoadXml(SmsStatusMsg); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                    //XmlNodeList xnList = xml.SelectNodes("smslist");
                                    //foreach (XmlNode xn in xnList)
                                    //{
                                    //    XmlNode example = xn.SelectSingleNode("sms");
                                    //    if (example != null)
                                    //    {
                                    //        string na = example["messageid"].InnerText;
                                    //        string no = example["smsclientid"].InnerText;
                                    //        string mobileno = example["mobile-no"].InnerText;
                                    //        string URL1 = "http://sms.proactivesms.in/getDLR.jsp?userid=attsystm&password=attsystm&messageid=" + na + "redownload=yes&responce type=xml";

                                    //        SmsDeliveryStatus = client.DownloadString(URL1);
                                    //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\r\n", "");
                                    //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\t", "");
                                    //        SmsDeliveryStatus = SmsDeliveryStatus.Replace("\n", "");
                                    //        XmlDocument xml1 = new XmlDocument();
                                    //        xml.LoadXml(SmsDeliveryStatus); //myXmlString is the xml file in string //copying xml to string: string myXmlString = xmldoc.OuterXml.ToString();
                                    //        //XmlNodeList xnList1 = xml.SelectNodes("response");

                                    //        //foreach (XmlNode xn1 in xnList1)
                                    //        //{
                                    //        XmlNode example1 = xml.SelectSingleNode("response");
                                    //        if (example1 != null)
                                    //        {
                                    //            //string rscode = example1["responsecode"].InnerText;
                                    //            smsview.DeliveryReport = example1["resposedescription"].InnerText;
                                    //            //string dlrcount = example1["dlristcount"].InnerText;
                                    //            //string pendingcount = example1["pendingdrcount"].InnerText;

                                    //        }
                                    //    }

                                    //}

                                    #region Samsung SMS gateway
                                    //SMS for Samsung gateway
                                    // Set the username of the account holder.
                                    Messaging.MessageController.UserAccount.User = "******";
                                    // Set the password of the account holder.
                                    Messaging.MessageController.UserAccount.Password = "******";
                                    // Set the first name of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactFirstName = "David";
                                    // Set the last name of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactLastName = "Smith";
                                    // Set the mobile phone number of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactPhone = "0423612367";
                                    // Set the landline phone number of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactLandLine = "0338901234";
                                    // Set the contact email of the account holder (optional).
                                    Messaging.MessageController.UserAccount.ContactEmail = "*****@*****.**";
                                    // Set the country of origin of the account holder (optional).
                                    Messaging.MessageController.UserAccount.Country = Countries.Australia;
                                    bool testOK = false;
                                    try
                                    {
                                        // Test the user account settings.
                                        Account testAccount = Messaging.MessageController.UserAccount;
                                        testOK = Messaging.MessageController.TestAccount(testAccount);
                                    }
                                    catch (Exception ex)
                                    {
                                        // An exception was thrown. Display the details of the exception and return.
                                        string message = "There was an error testing the connection details:\n" +
                                        ex.Message;
                                        // MessageBox.Show(this, message, "Connection Failed", MessageBoxButtons.OK);
                                        return;
                                    }
                                    if (testOK)
                                    {
                                        // The user account settings were valid. Display a success message
                                        // box with the number of credits.
                                        int balance = Messaging.MessageController.UserAccount.Balance;
                                        string message = string.Format("You have {0} message credits available.",
                                        balance);
                                        // MessageBox.Show(this, message, "Connection Succeeded", MessageBoxButtons.OK);
                                    }
                                    else
                                    {
                                        // The username or password were incorrect. Display a failed message box.
                                        //  MessageBox.Show(this, "The username or password you entered were incorrect.",
                                        // "Connection Failed", MessageBoxButtons.OK);
                                    }

                                    Messaging.MessageController.Settings.TimeOut = 60;
                                    // Set the batch size (number of messages to be sent at once) to 200.
                                    Messaging.MessageController.Settings.BatchSize = 200;
                                    //string strmsg = "To confirm an appointment with the Samsung Experience Store,\r\nyou will need 4 characters password. The password is  " + strrandom + "";
                                    //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                    //string strmsg = "Hi " + " " + Cname + ", To finalize your appointment with the Samsung Experience Store  at Sydney Central Plaza,\r\nplease enter these 4 characters" + strrandom + "password on the Confirmation screen. Thank you";
                                    //string strmsg = "Hi" + " " + Cname + ",Your ticket number is:" + QueueTokenGenerationSMS + " . Thanks";

                                    //"Hi Kara, your ticket number is 040, Approximate waiting time is 00:40 minutes/hours”

                                    Messaging.MessageController.Settings.DeliveryReport = true;
                                    //SMSMessage smsobj = new SMSMessage(MissedPhoneNo, strmsg);
                                    //Messaging.MessageController.AddToQueue(smsobj);
                                    Messaging.MessageController.SendMessages();
                                    //end of Samsung SMS
                                    #endregion Samsung SMS gateway


                                    if (SmsStatusMsg.Contains("<br>"))
                                    {
                                        SmsStatusMsg = SmsStatusMsg.Replace("<br>", ", ");
                                    }
                                    smsview.QueueNo = QueueToken;
                                    DateTime dattime = System.DateTime.Now;
                                    smsview.SMSDateTime = dattime;
                                    smsview.SMSStatusFlag = "R";
                                    smsview.Message = strmsg1;
                                    smsview.PhoneNo = PhoneNumber;
                                    smscontroller.GetInsertReplySMS(smsview);
                                }
                            }
                            catch (WebException e1)
                            {
                                SmsStatusMsg = e1.Message;
                            }
                            catch (Exception e2)
                            {
                                SmsStatusMsg = e2.Message;
                            }
                            //smsview.InsmsStatus = "S";
                            //dtinsms = smscontroller.GetIncomingSMS(smsview);
                            //smsview.MySms = (Convert.ToString(dr["incomingsms"].ToString()));
                            //flagupdate = smscontroller.GetsmsStatusFlag(smsview);
                        }
                    }



                }
            }
        }