private void MissedQueueSendingSMS() { SMSView smsview = new SMSView(); SMSController smscontroller = new SMSController(); DataTable MissedQueue = new DataTable(); DataTable MissedQueueSentSMS = new DataTable(); MissedQueue = null; //WebClient oWeb = new WebClient(); //Byte[] bytHeaders; MissedQueueSentSMS = null; smsview = new SMSView(); MissedQueue = smscontroller.GetMissedQueueSendingSMS(); foreach (DataRow dr in MissedQueue.Rows) { smsview.QueueTransaction = (Convert.ToInt32(dr["queue_visit_tnxid"].ToString())); int qti = (Convert.ToInt32(dr["queue_visit_tnxid"].ToString())); string MissedQueueNo = (dr["visit_queue_no_show"].ToString()); string MissedPhoneNo = (Convert.ToString(dr["customer_mobile"].ToString())); long CustId = (Convert.ToInt64(dr["customer_id"].ToString())); // string mobileno = (Custname["members_mobile"].ToString()); // string MissedPhoneNo = 61 + MissedPhoneNo1; string SmsStatusMsg = string.Empty; string SmsDeliveryStatus = string.Empty; // SMSView smsview = new SMSView(); string cname = dr["visit_customer_name"].ToString(); string appt = dr["customer_appointment_time"].ToString(); DateTime apt = Convert.ToDateTime(appt); string cappt = apt.ToString("HH:mm"); string custaptime = apt.ToShortTimeString(); string mobnum = "61"+ dr["customer_mobile"].ToString(); try { DataTable CheckMessage = new DataTable(); // CheckMessage = smscontroller.GetMessedQMessageExistance(smsview); // if (CheckMessage.Rows.Count <= 0) // { if (MissedPhoneNo != "") { if (MissedPhoneNo.Length == 11) { //string strmsg = "Hi " + " " + Cname + ", It seems you missed your appointment at the Samsung Experience Stor. \r\nShould you require a new appointment, please contact 1300 362 603 or visit www.samsung.com.au"; // string strmsg = "Hi " + " " + MissedQueueNo +",It seems you missed your appointment at the Samsung Experience Stor. \r\nShould you require a new appointment, please contact 1300 362 603 or visit www.samsung.com.au"; string strmsg = "Hi " + cname + ", It seems you missed your appointment at the Samsung Experience Store at " + cappt + "\r\nShould you require a new appointment, please contact 1300 362 603 or visit www.samsung.com.au."; //Hi Kara, It seems you missed your appointment at the Samsung Experience Store at XX:XX, Should you require a new appointment, please contact 1300 362 603 or visit www.samsung.com.au //"Hi " + cname + "It seems you missed your appointment at the Samsung Experience Store at " + cappt + "\r\nShould you require a new appointment, please contact 1300 362 603 or visit www.samsung.com.au."; smsview.SmsDesc = strmsg; //string strmsg = "Hi: " + MissedQueueNo + " has been called but due to no show your number has been moved to missed queue. \r\nPlease contact reception for assistance"; //string URL = "http://sms.proactivesms.in/sendsms.jsp?user=attsystm&password=attsystm&mobiles=" + MissedPhoneNo + "&sms=" + strmsg1 + "&senderid=ATTIPL"; //string URL = "https://api.aussiesms.com.au/?sendsms&mobileID=61422889101&password=att0424&to=" + MissedPhoneNo + "&text=" + strmsg1 + "&from=QSoft&msg_type=SMS_TEXT"; //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 + ""; //string URL = "https://tim.telstra.com/cgphttp/servlet/[email protected]&Password=Qsoft123&destination=" + MissedPhoneNo + "&text=" + strmsg1 + ""; #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); //SMSMessage smsobj = new SMSMessage(mobileno, strmsg); Messaging.MessageController.AddToQueue(smsobj); Messaging.MessageController.SendMessages(); //end of Samsung SMS #endregion Samsung SMS gateway #region inserting to tbl_sms_tnx smsview.CustId = CustId; smsview.SmsDesc = strmsg; smsview.PhoneNo = mobnum; smsview.DeliveryReport = "y"; smsview.SmsDesc = strmsg; smsview.IncomingsmsFlag = "M"; smsview.SmsVisittnxId = 2; smsview.SMSDateTime = System.DateTime.Now; smsview.SMSStatusFlag = "M"; smsview.QueueNo = Convert.ToString("1"); smsview.CentreId = ""; smsview.SMSDateTime = System.DateTime.Now; string i; i = smscontroller.getInsertAppointmentAlertSms(smsview); #endregion into tbl_sms_tnx #region Updating sms_status_flag='D' for MissQ smsview.Qvisittnxid = qti; //smsview.SMSalert = 'E'; smscontroller.updatesmsstatusflag(smsview); #endregion End Updating sms_status_flag } //} else { if (MissedPhoneNo.Length == 9) { MissedPhoneNo = 61 + MissedPhoneNo; //string strmsg1 = "Your ticket number: " + MissedQueueNo + " has been called but due to no show your number has been moved to missed queue. \r\nPlease contact reception for assistance"; //string strmsg = "Hi " + " " + MissedQueueNo + ",It seems you missed your appointment at the Samsung Experience Stor. \r\nShould you require a new appointment, please contact 1300 362 603 or visit www.samsung.com.au"; string strmsg = "Hi " + cname + " It seems you missed your appointment at the Samsung Experience Store at " + cappt + "\r\n Should you require a new appointment, please contact 1300 362 603 or visit www.samsung.com.au."; smsview.SmsDesc = strmsg; // string URL = "http://sms.proactivesms.in/sendsms.jsp?user=attsystm&password=attsystm&mobiles=" + MissedPhoneNo + "&sms=" + strmsg1 + "&senderid=ATTIPL"; //string URL = "https://api.aussiesms.com.au/?sendsms&mobileID=61422889101&password=att0424&to=" + MissedPhoneNo + "&text=" + strmsg1 + "&from=QSoft&msg_type=SMS_TEXT"; //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 + ""; //string URL = "https://tim.telstra.com/cgphttp/servlet/[email protected]&Password=Qsoft123&destination=" + MissedPhoneNo + "&text=" + strmsg1 + ""; #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 //SmsStatusMsg = oWeb.DownloadString(URL); //if (SmsStatusMsg.Contains("<br>")) //{ // SmsStatusMsg = SmsStatusMsg.Replace("<br>", ", "); //} //smsview.SMSStatusFlag = "S"; //smscontroller.GetQueueTokenGenerationSentSMS(smsview); ////Thread.Sleep(100); //DataTable dt1 = new DataTable(); //dt1 = smscontroller.GetRetrieveSMSstatusFlag(smsview); //foreach (DataRow dr123 in dt1.Rows) //{ // string Sflag = (dr123["message_status_flag"].ToString()); // string uflag = Convert.ToString("M"); // if (Sflag == uflag) // { // smsview.SMSStatusFlag = "S"; // smscontroller.GetQueueTokenGenerationSentSMS(smsview); // } // else // { // #region delivery Report // //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; // // } // // } // #endregion delivery Report // smsview.QueueTransaction = Qtnxid; // smsview.CustId = CustId; // smsview.SmsDesc = strmsg; // smsview.QueueNo = MissedQueueNo; // smsview.PhoneNo = MissedPhoneNo; //// smsview.IncomingsmsFlag = "M"; // smsview.SMSDateTime = System.DateTime.Now; // // string d; // // d = smscontroller.GetInsertMissedQSMS(smsview); // // DataTable QueueTokenGenerationSentSMS = new DataTable(); // // } // //smsview.SmsUpdatedDateTime = System.DateTime.Now; // smsview.SmsActive ='Y'; // smsview.SMSContentTypeId = 2; // smsview.SmsAlert = 2; // smsview.SmsUpdatedBy = "Admin"; // string i; // i = smscontroller.getInsertAppointmentAlertSms(smsview); // } // } // } // } #region inserting to tbl_sms_tnx smsview.CustId = CustId; smsview.SmsDesc = strmsg; smsview.PhoneNo = mobnum; smsview.DeliveryReport = "y"; smsview.SmsDesc = strmsg; smsview.IncomingsmsFlag = "M"; smsview.SmsVisittnxId = 2; smsview.SMSDateTime = System.DateTime.Now; smsview.SMSStatusFlag = "M"; smsview.QueueNo = Convert.ToString("1"); smsview.CentreId = ""; smsview.SMSDateTime = System.DateTime.Now; string i; i = smscontroller.getInsertAppointmentAlertSms(smsview); #endregion into tbl_sms_tnx #region Updating sms_status_flag='D' for MissQ smsview.Qvisittnxid = qti; //smsview.SMSalert = 'E'; smscontroller.updatesmsstatusflag(smsview); #endregion End Updating sms_status_flag } } } } catch (WebException e1) { // SmsStatusMsg = e1.Message; } catch (Exception e2) { // SmsStatusMsg = e2.Message; } //smsview.SMSStatusFlag = "S"; //MissedQueueSentSMS = smscontroller.GetMissedQueueSentSMS(smsview); } }