コード例 #1
0
        public void ExpiredAppointmentNotification()
        {
            SMSView smsview = new SMSView();
            try
            {
                DataTable appointment = new DataTable();
                SMSController sms = new SMSController();
                appointment = sms.appointmentexpired(smsview);

                foreach (DataRow dr in appointment.Rows)
                {
                    SMSView smsview1 = new SMSView();
                    string cname = dr["customer_firstname"].ToString();
                    int appid = Convert.ToInt32(dr["appointment_id"].ToString());
                    string app = dr["appointment_time"].ToString();
                    DateTime adt = Convert.ToDateTime(app);
                    string mobileno = "61" + dr["appointment_mobileno"].ToString();
                    long custid = Convert.ToInt64(dr["appointment_customer_id"].ToString());
                    DateTime syst = DateTime.Now;
                    string apptime = adt.ToString("HH:mm");
                    DateTime timeapp1 = Convert.ToDateTime(app);
                    TimeSpan t1 = new TimeSpan(01, 00, 00);
                    timeapp1 = timeapp1 + t1;
                    string timeapp = timeapp1.ToString("HH:mm");
                    string systemtime = syst.ToString("HH:mm");
                    //string systemtime = "22:19";
                    //DateTime re = Convert.ToDateTime("10:31");
                    //String ret = re.ToString("HH:mm");
                    DataTable dtsmsview = new DataTable();
                    dtsmsview = smscontroller.appointmenTranstexpired(smsview1);
                    if (dtsmsview.Rows.Count == 0)
                    {
                        if (timeapp == systemtime)
                        {
                            string strmsg = "Dear " + cname + ",\r\n  your appointment for " + apptime + " has been Expired, please contact 18xxxxxx to reschedule";
                            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 = 5;
                            // Set the batch size (number of messages to be sent at once) to 200.
                            Messaging.MessageController.Settings.BatchSize = 200;
                            Messaging.MessageController.Settings.DeliveryReport = true;
                            SMSMessage smsobj = new SMSMessage(mobileno, strmsg);
                            Messaging.MessageController.AddToQueue(smsobj);
                            Messaging.MessageController.SendMessages();
                            #endregion Samsung SMS gateway

      
                            #region inserting to tbl_sms_tnx
                            smsview.CustId = custid;
                            smsview.SmsDesc = strmsg;
                            smsview.PhoneNo = mobileno;
                            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 Update SMS_Alert statsus flag

                            smsview.AppointmentID = appid;
                            smsview.SMSalert = 'E';
                            sms.updatesmsalert(smsview);

                            #endregion Update SMS_Alert statsus flag

                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }