Example #1
0
        public void Send(string message, string nr)
        {
            SmsSubmitPdu pdu = new SmsSubmitPdu(message, nr, "");

            try
            {
                if (!comm.IsOpen())
                {
                    comm.Open();
                }

                if (!comm.IsConnected())
                {
                    Singleton.Show_MessageBox("błąd portu");
                    return;
                }

                /*if (comm.GetPinStatus() != PinStatus.Ready) {
                 *  comm.EnterPin(PIN);
                 *  Thread.Sleep(1000);
                 * }*/

                comm.SendMessage(pdu);
                Thread.Sleep(1000);
            }
            catch (Exception ex)
            {
                Singleton.Show_MessageBox(ex.Message);
                return;
            }
            //Singleton.Show_MessageBox("wysyłam " + message + "na numer: " + nr);
        }
        public bool Sendsms(String msg, String contact)
        {
            bool bol = false;

            try
            {
                //var phoneNumber = contact;
                var phoneNumber = "+923138251224";
                var pdu         = new SmsSubmitPdu(msg, contact, string.Empty);
                //SmsSubmitPdu pdu;
                //byte msg = (byte)DataCodingScheme.DataCoding.Alpha7BitDefault;
                //pdu = new SmsSubmitPdu(txtAddress.Text, txtContact.Text, msg);
                int time = 3;
                for (int i = 0; i < time; i++)
                {
                    gsmcom.SendMessage(pdu);
                }

                return(true);
            }
            catch (Exception)
            {
                MessageBox.Show("modem is not available");
                return(false);
            }
            return(true);
        }
Example #3
0
        public bool sendSMS(string CELL_Number, string SMS_Message)
        {
            bool status = false;

            try
            {
                if (comm != null)
                {
                    Cursor.Current = Cursors.WaitCursor;

                    pdu1 = new SmsSubmitPdu(SMS_Message, CELL_Number, "");

                    comm.SendMessage(pdu1);

                    Cursor.Current = Cursors.Default;

                    //MessageBox.Show("M E S S A G E - S E N T", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    status = true;
                }
            }
            catch (Exception E5)
            {
                //MessageBox.Show("Error Sending SMS To Destination Address\r\n\n Connection Has Been Terminated !!!\r\n\n", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                //comm.Close();
                status = false;
            }
            return(status);
        }
Example #4
0
        public Boolean send_message(string number, string message)
        {
            Boolean ok = false;

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                try
                {
                    SmsSubmitPdu pdu;
                    byte         dcs = (byte)DataCodingScheme.GeneralCoding.Alpha7BitDefault;
                    pdu = new SmsSubmitPdu(message, Convert.ToString(number), dcs);

                    Thread.Sleep(3000);
                    comm.SendMessage(pdu);
                    ok = true;
                }
                catch (Exception ex)
                {
                    lbl_status.Invoke(new Action(() =>
                    {
                        lbl_status.Text = "Func :send_message [2nd level]" + ex.Message;
                    }));
                }
            }
            catch (Exception ex)
            {
                lbl_status.Invoke(new Action(() =>
                {
                    lbl_status.Text = "Func :send_message [1st level]" + ex.Message;
                }));
            }
            return(ok);
        }
        private void btnSend_Click(object sender, EventArgs e)
        {
            Operation code = new Operation();

            try
            {
                txtDonorId.Text   = "0343";
                txtDonorName.Text = "Hello there";
                txtNumber.Text    = "09226663075";
                Cursor.Current    = Cursors.WaitCursor;
                txtMessage.Text   = "Respected " + txtDonorName.Text + ", Welcome to Clapp Trust. Your donor ID is " + txtDonorId.Text + ". Our online system will send you SMS whenever your donation is received.";
                try
                {
                    SmsSubmitPdu pdu;
                    byte         dcs = (byte)DataCodingScheme.GeneralCoding.Alpha7BitDefault;
                    pdu = new SmsSubmitPdu(txtMessage.Text, Convert.ToString(txtNumber.Text), dcs);
                    int times = 1;
                    for (int i = 0; i < times; i++)
                    {
                        comm.SendMessage(pdu);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Modem is not available");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception ex :" + ex.Message);
            }
        }
Example #6
0
        public static string sendATSMSCommand(string PortName, string cellNo, string messages, object _sendFailer)
        {
            int         baudRate = 9600;
            int         timeout  = 300;
            GsmCommMain comm;

            comm = new GsmCommMain(PortName, baudRate, timeout);

            try
            {
                comm.Open();
            }
            catch (Exception)
            {
                //return false;
            }

            try
            {
                SmsSubmitPdu[] pdus;

                bool unicode = Library.IsUnicode(messages);
                try
                {
                    if (!unicode)
                    {
                        pdus = GsmComm.PduConverter.SmartMessaging.SmartMessageFactory.CreateConcatTextMessage(messages, cellNo);
                    }
                    else
                    {
                        pdus = GsmComm.PduConverter.SmartMessaging.SmartMessageFactory.CreateConcatTextMessage(messages, true, cellNo);
                    }
                }
                catch (Exception ex)
                {
                    return(null);
                }

                foreach (SmsSubmitPdu pdu in pdus)
                {
                    comm.SendMessage(pdu);
                }


                return("1");
            }
            catch (Exception ex)
            {
                return(ex.ToString());
                //return false;
            }
            finally
            {
                if (comm != null)
                {
                    comm.Close();
                }
            }
        }
        private void Send()
        {
            if (commMain != null && commMain.IsConnected())
            {
                try
                {
                    if (dataGridView_ClientList.SelectedRows.Count > 0)
                    {
                        string       cpNumber = dataGridView_ClientList.SelectedRows[0].Cells[4].Value.ToString();
                        SmsSubmitPdu pdu;
                        int          count    = 0;
                        int          countPos = 0;

                        foreach (char c in tb_message.Text)
                        {
                            count++;
                            if (count >= 150)
                            {
                                string firstFivChar = new string(tb_message.Text.Substring(countPos, count).ToArray());
                                pdu = new SmsSubmitPdu(firstFivChar, cpNumber, string.Empty);
                                commMain.SendMessage(pdu);
                                countPos = countPos + 150;
                                count    = count - count;
                            }
                        }

                        if (count <= 150)
                        {
                            string lastText = new string(tb_message.Text.Substring(countPos, count).ToArray());
                            pdu = new SmsSubmitPdu(lastText, cpNumber, "");
                            commMain.SendMessage(pdu);
                            countPos = countPos + 150;
                            count    = count - count;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please selecet Client number");
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Please check if simcard properly loaded. Please check if simcard have load.");
                }
            }
        }
Example #8
0
 public static void Send(string message, string number)
 {
     try
     {
         SmsSubmitPdu pdu;
         byte         dcs = (byte)DataCodingScheme.GeneralCoding.Alpha7BitDefault;
         pdu = new SmsSubmitPdu(message, Convert.ToString(number), dcs);
         int times = 1;
         for (int i = 0; i < times; i++)
         {
             comm.SendMessage(pdu);
         }
     }
     catch
     {
     }
 }
Example #9
0
        private void SendMultiple(OutgoingSmsPdu[] pdus)
        {
            var num = pdus.Length;

            try
            {
                // Send the created messages
                comm.EnableTemporarySmsBatchMode();

                foreach (OutgoingSmsPdu pdu in pdus)
                {
                    comm.SendMessage(pdu);
                }
            }
            catch
            {
            }
        }
Example #10
0
 public bool Alert(string msg, string number)
 {
     try
     {
         if (comm.IsOpen())
         {
             byte         dcs = DataCodingScheme.Class0_7Bit;
             SmsSubmitPdu pdu = new SmsSubmitPdu(msg, number, "", dcs);
             comm.SendMessage(pdu);
             return(true);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Alert unable to send error: " + ex.Message);
         // EventLog.WriteEntry("AeiGenAlert: No SMS Alert");
     }
     return(false);
 }  //Alert
Example #11
0
 void SendMsg(string phone, string text)
 {
     try
     {
         comm.SendMessage(new SmsSubmitPdu(text, phone));
         this.Invoke(new Action(() => Output("SMS OUT", phone, text)));
     }
     catch (Exception ex)
     {
         this.Invoke(new Action(() => ShowException(ex)));
     }
 }
Example #12
0
        public void SendSMS(string CELL_Number, string SMS_Message)
        {
            SmsSubmitPdu pdu1;

            if (comm.IsConnected() == true)
            {
                pdu1 = new SmsSubmitPdu(SMS_Message, CELL_Number, "");

                comm.SendMessage(pdu1);
                comm.Close();
            }
        }
Example #13
0
 private void btnKirim_Click(object sender, EventArgs e)
 {
     try
     {
         SmsSubmitPdu pdu;
         pdu = new SmsSubmitPdu(rchPesan.Text, txtHP.Text, "");
         comm.SendMessage(pdu);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Example #14
0
 public static void SendMessage(GsmCommMain comm, string phonenumber, string text)
 {
     try
     {
         _logger.Info($"Sending SMS to {phonenumber}");
         byte         dcs = (byte)DataCodingScheme.GeneralCoding.Alpha16Bit;
         SmsSubmitPdu pdu = new SmsSubmitPdu(text, phonenumber, dcs);
         comm.SendMessage(pdu);
     }
     catch (Exception ex)
     {
         _logger.Fatal($"Error while sending SMS to {phonenumber}: {ex.Message} ({ex.GetType()})");
     }
 }
 public void SendMessages(string cpnumber)
 {
     try
     {
         if (cpnumber != "")
         {
             SmsSubmitPdu pdu;
             pdu = new SmsSubmitPdu(txtMessage.Text, cpnumber);
             comm.SendMessage(pdu);
             ShowMessage(pdu);
             UpdateLog("Sent", "Dashboard Message", cpnumber, txtMessage.Text);
             Output("[{0}] 1 Message sent to: " + cpnumber, Start);
             Output("");
         }
     }
     catch (Exception ex)
     {
         UpdateLog("Unsent", "Dashboard Message", cpnumber, txtMessage.Text);
         Output(ex.Message);
         Output("[{0}] 1 Message not sent to: " + cpnumber, Start);
         Output("");
     }
 }
Example #16
0
        private static bool send_gsm(string phoneNumber, string message)
        {
            bool unicode = true;
            bool alert   = false;

            if (((_GsmComm == null || !_GsmComm.IsOpen()) && !_connect2gsm()) || string.IsNullOrEmpty(message))
            {
                return(false);
            }

            try
            {
                SmsSubmitPdu pdu;

                if (!alert && !unicode)
                {
                    pdu = new SmsSubmitPdu(message, phoneNumber, "");
                }
                else
                {
                    byte dcs;

                    if (!alert && unicode)
                    {
                        dcs = DataCodingScheme.NoClass_16Bit;
                    }
                    else if (alert && !unicode)
                    {
                        dcs = DataCodingScheme.Class0_7Bit;
                    }
                    else if (alert && unicode)
                    {
                        dcs = DataCodingScheme.Class0_16Bit;
                    }
                    else
                    {
                        dcs = DataCodingScheme.NoClass_7Bit;
                    }

                    pdu = new SmsSubmitPdu(message, phoneNumber, "", dcs);

                    _GsmComm.SendMessage(pdu);
                }
            }
            catch (Exception ex) { return(false); }

            return(true);
        }
Example #17
0
        public bool sendMessage(string num, string msg)
        {
            SmsSubmitPdu pdu = null;

            try
            {
                pdu = new SmsSubmitPdu(msg, num, "");
                comm.SendMessage(pdu);
            }
            catch (Exception ex)
            {
                ex.ToString();
                return(false);
            }
            return(true);
        }
Example #18
0
 public void SendMessage(string message, string cellphonenumber)
 {
     try
     {
         // Send an SMS message
         SmsSubmitPdu pdu;
         // Send message in the default format
         pdu = new SmsSubmitPdu(message, cellphonenumber);
         comm.SendMessage(pdu);
         UpdateLog("Sent", "Dashboard Messages", cellphonenumberTxtbx.Text, message);
     }
     catch (Exception)
     {
         UpdateLog("Failed", "Sending Failed", cellphonenumberTxtbx.Text, message);
     }
 }
Example #19
0
 public void SendSMS(string port, string nomer, string message)
 {
     try
     {
         GsmCommMain  comm;
         SmsSubmitPdu pdu;
         comm = new GsmCommMain(Convert.ToInt32(port), 115200);
         comm.Open();
         pdu = new SmsSubmitPdu(message, nomer, "");
         comm.SendMessage(pdu);
         comm.Close();
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message.ToString());
     }
 }
Example #20
0
        //
        // Summary:
        //     Send message directly from connected modem
        //
        // Parameters:
        //   noHP:
        //     Destination Phone Number
        //
        //   pesan:
        //     Message content.
        public Boolean SendSMS(string noHP, string pesan)
        {
            bool result = false;

            try
            {
                SmsSubmitPdu pdu = new SmsSubmitPdu(pesan, noHP);

                comm.SendMessage(pdu);

                return(true);
            } catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            return(result);
        }
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         SmsSubmitPdu pdu;
         byte         dcs = (byte)DataCodingScheme.GeneralCoding.Alpha7BitDefault;
         pdu = new SmsSubmitPdu(smstexts.Text, textBox6.Text, dcs);
         int time = 1;
         for (int i = 0; i < time; i++)
         {
             comm.SendMessage(pdu);
         }
     }
     catch (Exception)
     {
         MessageBox.Show("modem is not available");
     }
 }
Example #22
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        dbcon obj = new dbcon();

        obj.GetInvoice(Session["OrderID"].ToString());
        try
        {
            //  if (obj.GetInvoice())
            // {

            string MsgBody = dbcon.mymsg;      //myclass.body;
            //"using Gmail in ASP.NET";

            int         port = 8;
            int         baud = 9600;
            int         time = 300;
            GsmCommMain Rate = new GsmCommMain(port, baud, time);
            Rate.Open();

            while (!Rate.IsConnected())
            {
                lblexp.Text = "Not Connected";
            }
            //MessageBox.Show("Connected");
            // Rate.Close();
            SmsSubmitPdu Msg;



            Msg = new SmsSubmitPdu(MsgBody, dbcon.phoneno);
            Rate.SendMessage(Msg);
            //lblmobile.Text = "Message sent to  " + txtmobile.Text + "";
            Rate.Close();



            lblexp.Text = "Dear User Your Ordered Information is Sent";
            // }
        }
        catch (Exception ex)
        {
            lblexp.Text = "some Problem" + ex;
        }
    }
Example #23
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            Operation code = new Operation();

            try
            {
                SqlConnection  con                   = Main.GetDBConnection();
                DataTable      consultanttable       = new DataTable();
                string         sqlConsultant         = @"SELECT  Don_Donor_ID,Don_Donor_Name,Don_Mobile_Phone
                FROM  SGAP.dbo.Donor_Profile";
                SqlDataAdapter Consultantdataadapter = new SqlDataAdapter(sqlConsultant, con);
                Consultantdataadapter.Fill(consultanttable);
                foreach (DataRow myrow in consultanttable.Rows)
                {
                    txtDonorId.Text   = Convert.ToString(myrow[0]);
                    txtDonorName.Text = Convert.ToString(myrow[1]);
                    txtNumber.Text    = Convert.ToString(myrow[2]);
                    Cursor.Current    = Cursors.WaitCursor;
                    txtMessage.Text   = "Respected " + txtDonorName.Text + ", Welcome to KioTech. Your KioTech ID is: " + txtDonorId.Text + ". This is just a test, thank you :).";
                    try
                    {
                        SmsSubmitPdu pdu;
                        byte         dcs = (byte)DataCodingScheme.GeneralCoding.Alpha7BitDefault;
                        pdu = new SmsSubmitPdu(txtMessage.Text, Convert.ToString(txtNumber.Text), dcs);
                        int times = 1;
                        for (int i = 0; i < times; i++)
                        {
                            comm.SendMessage(pdu);
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Modem is not available");
                        code.Execute("update sgap.dbo.donor_profile set don_sms2='notsend' where don_donor_id ='" + txtDonorId.Text + "'");
                    }
                }
            }
            catch
            {
                MessageBox.Show("SMS not send");
            }
        }
Example #24
0
 //Méthode pour envoyer un message
 public void Send(string message, string number, string nothing)
 {
     Cursor.Current = Cursors.WaitCursor;
     try
     {
         SmsSubmitPdu pdu;
         pdu = new SmsSubmitPdu(message, number, nothing);  // "" indicate SMSC No
         if (!comm.IsOpen())
         {
             comm.Open();
         }
         comm.SendMessage(pdu);
         MessageBox.Show("message envoyé", "ENVOIE SIMPLE", MessageBoxButtons.OK, MessageBoxIcon.Information);
         comm.Close();
     }
     catch (Exception)
     {
         MessageBox.Show("L'envoie a échoué", "ENVOIE SIMPLE", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     Cursor.Current = Cursors.Default;
 }
Example #25
0
        public static bool SendUpdate(DBObject parent, string id, string message, string number, string network, string cb)
        {
            _network = new Network(null);
            comm     = new GsmCommMain(cb, 9600, 150);
            try
            {
                SmsSubmitPdu pdu;
                byte         dcs = (byte)DataCodingScheme.GeneralCoding.Alpha7BitDefault;
                pdu = new SmsSubmitPdu(message, Convert.ToString(number), dcs);
                int times = 1;
                for (int i = 0; i < times; i++)
                {
                    if (comm.IsConnected())
                    {
                        Console.WriteLine("comm is already open");
                        Console.WriteLine("modem  connected:" + network + "to:" + comm);
                        _network.UpdateStatus(network, "connected");
                    }
                    else
                    {
                        comm.Open();
                        _network.UpdateStatus(network, "connected");
                    }

                    comm.SendMessage(pdu);
                    _message = new Message(parent);
                    _message.Update(id, "T");

                    sent = true;
                }
                sent = true;
            }
            catch (Exception r)
            {
                sent = false;
                _network.UpdateStatus(network, "disconnected");
                Console.WriteLine("comm is already open");
            }
            return(sent);
        }
Example #26
0
        private bool SendMessage(string CELL_Number, string SMS_Message)
        {
            SmsSubmitPdu pdu1;

            if (comm.IsConnected() == true)
            {
                try
                {
                    pdu1 = new SmsSubmitPdu(SMS_Message, CELL_Number, "");
                    comm.SendMessage(pdu1);

                    return(true);
                }
                catch (Exception E5)
                {
                    MessageBox.Show("Error Sending SMS To Destination Address\r\n\n Connection Has Been Terminated !!!\r\n\n");
                    comm.Close();
                    return(false);
                }
            }
            return(false);
        }
Example #27
0
        private void SendMultiple(OutgoingSmsPdu[] pdus)
        {
            int num = pdus.Length;

            try
            {
                // Send the created messages
                int i = 0;
                foreach (OutgoingSmsPdu pdu in pdus)
                {
                    i++;
                    logger("Sending message " + i.ToString() + " of " + num.ToString() + "...");
                    comm.SendMessage(pdu);
                }
                logger("Done.");
            }
            catch (Exception ex)
            {
                ShowException(ex);
                logger("Message sending aborted because of an error.");
            }
        }
Example #28
0
        //Send message to the number and message
        public bool GSMSend(string RecieverNumber, string txtMessage)
        {
            bool sendSuccess = false;

            try
            {
                Cursor.Current = Cursors.WaitCursor;
                try
                {
                    SmsSubmitPdu pdu;
                    byte         dcs = (byte)DataCodingScheme.GeneralCoding.Alpha7BitDefault;
                    pdu = new SmsSubmitPdu(txtMessage, Convert.ToString(RecieverNumber), dcs);
                    int times = 1;
                    for (int i = 0; i < times; i++)
                    {
                        comm.SendMessage(pdu);
                    }
                    //MessageBox.Show("SMS sent");
                    //Console.WriteLine("SMS SENT SUCCESSFUL");
                    sendSuccess = true;
                }
                catch (Exception ex)
                {
                    //MessageBox.Show("Modem is not available" + ex.ToString());
                    Console.WriteLine("Modem is not available: " + ex.ToString());
                    sendSuccess = false;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("SMS SENDING FAILED: " + ex.ToString());
                // MessageBox.Show("SMS not send");
                // Console.WriteLine("SMS SENDING FAILED");
                sendSuccess = false;
            }

            return(sendSuccess);
        }
Example #29
0
        public void SendSms(string phoneNo, string msg)
        {
            try
            {
                if ((Gsm == null) || (!Gsm.IsOpen()))
                {
                    return;
                }

                SmsSubmitPdu pdu = new SmsSubmitPdu(msg, phoneNo, String.Empty);
                Gsm.SendMessage(pdu);
                //after sms set status notify here
            }
            catch (Exception ex)
            {
                LogError(ex.Message);

                if (Gsm.IsConnected() && Gsm.IsOpen())
                {
                    Gsm.Close();
                }
            }
        }
Example #30
0
        public static string Send(string message, string number)
        {
            string state;

            try
            {
                SmsSubmitPdu pdu;
                byte         dcs = (byte)DataCodingScheme.GeneralCoding.Alpha7BitDefault;
                pdu = new SmsSubmitPdu(message, Convert.ToString(number), dcs);
                int times = 1;
                for (int i = 0; i < times; i++)
                {
                    comm.SendMessage(pdu);
                    _message = new Message();
                }
                state = "sent";
            }
            catch (Exception r)
            {
                state = "not sent " + r;
                MainForm._Form1.FeedBack("Exception " + r.Message.ToString());
            }
            return(state);
        }