public void appointmentalert() { try { DataTable Qtokendt = new DataTable(); SMSController smscont = new SMSController(); Qtokendt = smscont.appointmentalert(); foreach (DataRow dr in Qtokendt.Rows) { SMSView smsview = new SMSView(); // int appid = Convert.ToInt32(dr["appointment_id"].ToString()); // string adt = dr["appointment_time"].ToString(); // TimeSpan t1 = new TimeSpan(1, 0, 0); // DateTime dtime1 = Convert.ToDateTime(adt); // DateTime dtime2 = dtime1 - t1; //appointment time adjustment for before one hour // string apptime = dtime2.ToString("HH:mm:ss"); // string cmobn = dr["appointment_mobileno"].ToString(); // string cname = dr["customer_firstname"].ToString(); //// string cdt = DateTime.Now.ToString("HH:mm:ss"); //current system time // string cdt = "::00"; // Manual system time for testing // if (apptime == cdt) // { int appid = Convert.ToInt32(dr["appointment_id"].ToString()); string appt = dr["appointment_time"].ToString(); DateTime apt = Convert.ToDateTime(appt); string custaptime = apt.ToShortTimeString(); //string cmobn = dr["appointment_customer_id"].ToString(); string cname = dr["customer_firstname"].ToString(); string mobnum = dr["customer_mobile"].ToString(); //DateTime crrsysdate = DateTime.Now; DateTime fdt = DateTime.Now;//Convert.ToDateTime("06:01"); string fd = fdt.ToString("HH:mm"); //DateTime onehour = Convert.ToDateTime("01:00"); string sfd = fdt.ToString("HH:mm"); //string sonehour = onehour.ToString("HH:MM"); string cappt = apt.ToString("HH:mm"); DateTime Result = apt.AddMinutes(-59); //DateTime r=Convert.ToDateTime(Result); string Resultdt = Result.ToString(); DateTime re = Convert.ToDateTime(Resultdt); string r = re.ToString("HH:mm"); string cdt = fdt.ToString();//DateTime.Now.ToString(); if (r == fd) { string strmsg = "Dear " + cname + ",\r\n Your appointment with Samsung is an hour to go, If you are away, please return back to the waiting room."; smsview.SmsDesc = strmsg; #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(mobnum, strmsg); Messaging.MessageController.AddToQueue(smsobj); Messaging.MessageController.SendMessages(); //end of Samsung SMS //smsview.SmsUpdatedDateTime = System.DateTime.Now; //smsview.SmsActive = 'Y'; //smsview.SMSContentTypeId = 1; //smsview.SmsAlert = 1; //smsview.SmsUpdatedBy="Admin"; //string i; //i = smscontroller.getInsertAppointmentAlertSms(smsview); #endregion Samsung SMS gateway #region Update SMS_Alert statsus flag smsview.AppointmentID = appid; smsview.SMSalert = 'B'; smscont.updatesmsalert(smsview); #endregion Update SMS_Alert statsus flag } } } catch (Exception ex) { throw ex; } }