예제 #1
0
        private void SmsController_OnMessageSent(object sender, SMSController.SMS sms)
        {
            int count = int.Parse(lblSent.Text);

            count++;

            lblSent.Invoke(new Action(() => {
                lblSent.Text = count.ToString();
            }));

            WriteToConsole("SMS sent successfully to:  " + sms.address);
        }
예제 #2
0
        private void SmsController_OnMessageReceived(object sender, SMSController.SMS sms)
        {
            int count = int.Parse(lblReceived.Text);

            count++;
            lblReceived.Invoke(new Action(() => {
                lblReceived.Text = count.ToString();
            }));
            try
            {
                WriteToConsole("New SMS recevied From : " + sms.address + "\n" + sms.body);
            }
            catch (Exception ex)
            {
            }
        }
예제 #3
0
        private void btnSendSMS_Click(object sender, EventArgs e)
        {
            SMSController.SMS sms = new SMSController.SMS();
            sms.body    = txtMessage.Text;
            sms.address = txtTo.Text;

            var device = GetSelectedDevice();

            if (device != null)
            {
                //Send SMS
                //device.SendSMS(sms);
                //sms.Send(device);

                sms.Send(device);


                //Clear Inputs
                txtMessage.Text = "";
                txtTo.Text      = "";
            }
        }
예제 #4
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (smsController.AllVerifiedDevices().Count > 0)
            {
                var dt = DB.Select("SELECT TOP " + smsController.AllVerifiedDevices().Count + " *  FROM messages where status = 0  ORDER BY ID DESC");
                if (dt.Rows.Count == 0)
                {
                    MessageBox.Show("Database Table is empty.");
                    timer1.Enabled = false;
                    btnDBSms.Text  = "Send DB SMS";
                }
                else
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        var device            = smsController.AllVerifiedDevices()[(dt.Rows.IndexOf(row))];
                        SMSController.SMS sms = new SMSController.SMS();
                        sms.id      = row["id"].ToString();
                        sms.address = row["mobile"].ToString();
                        sms.body    = row["message"].ToString();

                        //Message can be send by two methods

                        //Method 1
                        //sms.Send(device);

                        //Method 2
                        if (device != null)
                        {
                            DB.Query("UPDATE messages SET status = 1  WHERE ID =" + sms.id);
                            device.SendSMS(sms);
                        }
                    }
                }
            }
        }