Ejemplo n.º 1
0
        private void btnDisconnect_Click(object sender, EventArgs e)
        {
            if (this.multiSim == 4)
            {
                objclsSMS.ClosePort(this.port1);
                objclsSMS.ClosePort(this.port2);
                objclsSMS.ClosePort(this.port3);
                objclsSMS.ClosePort(this.port4);
            }



            try
            {
                this.gboPortSettings.Enabled = true;
                objclsSMS.ClosePort(this.port1);

                //Remove tab pages
                this.tabSMSapplication.TabPages.Remove(tbSendSMS);
                this.tabSMSapplication.TabPages.Remove(tbReadSMS);
                this.tabSMSapplication.TabPages.Remove(tbDeleteSMS);
                this.tabSMSapplication.TabPages.Remove(tbRequestSMS);

                this.lblConnectionStatus.Text = "Not Connected";
                this.btnDisconnect.Enabled    = false;
            }
            catch (Exception ex)
            {
                ErrorLog(ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void btnDisconnect_Click(object sender, EventArgs e)
        {
            try
            {
                this.gboPortSettings.Enabled = true;
                objclsSMS.ClosePort(this.port);

                //Remove tab pages
                this.tabSMSapplication.TabPages.Remove(tbListNumber);
            }
            catch (Exception ex)
            {
                ErrorLog(ex.Message);
            }
        }
Ejemplo n.º 3
0
        private void bgwSendSMS_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                SetText("Connection Status");

                //.............................................. Send SMS ....................................................
                try
                {
                    SetText("Sending sms to cc #: " + strMobileNo);

                    if (strMessage == "rbstest")
                    {
                        ListViewItem item = new ListViewItem(new string[] { iCtr.ToString(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), strMobileNo, "OK" });
                        SetSentMessage(item);
                        SetText("[" + iCtr.ToString() + "/" + iCount.ToString() + "]: msg sent to " + strMobileNo);
                    }
                    else
                    {
                        try
                        {
                            try
                            { objclsSMS.ClosePort(this.port); }
                            catch { }
                            Thread.Sleep(60);
                            try
                            {
                                ErrorLog(this.cboPortName.Text + " : opening port");
                                this.port = objclsSMS.OpenPort(this.cboPortName.Text, Convert.ToInt32(this.cboBaudRate.Text), Convert.ToInt32(this.cboDataBits.Text), Convert.ToInt32(this.txtReadTimeOut.Text), Convert.ToInt32(this.txtWriteTimeOut.Text));
                                ErrorLog(this.cboPortName.Text + " : port is open");
                            }
                            catch {}
                            try
                            {
                                if (objclsSMS.sendMsg(this.port, strMobileNo, strMessage))
                                {
                                    ErrorLog("Message has sent successfully");
                                    ErrorLog("[0/0]: msg sent to " + strMobileNo);

                                    ListViewItem item = new ListViewItem(new string[] { iCtr.ToString(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), strMobileNo, "sent: Read" });
                                    SetSentMessage(item);
                                    SetText("[" + iCtr.ToString() + "/" + iCount.ToString() + "]: msg sent to " + strMobileNo);
                                    iCtrRead++;
                                }
                                else
                                {
                                    //MessageBox.Show("Failed to send message");
                                    SetText("Failed to send message");
                                    SetText("[0/0]: msg failed sent to " + strMobileNo);

                                    ErrorLog("Failed to send message");
                                    ErrorLog("[0/0]: msg failed sent to " + strMobileNo);

                                    ListViewItem item = new ListViewItem(new string[] { iCtr.ToString(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), strMobileNo, "sent: NotRead" });
                                    SetSentMessage(item);
                                    SetText("[" + iCtr.ToString() + "/" + iCount.ToString() + "]: msg sent no reply from SMSC to " + strMobileNo);
                                    iCtrNotRead++;
                                }
                            }
                            catch (Exception ex)
                            {
                                ListViewItem item = new ListViewItem(new string[] { iCtr.ToString(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), strMobileNo, "sent: PhoneNoResp" });
                                SetSentMessage(item);
                                SetText("[" + iCtr.ToString() + "/" + iCount.ToString() + "]: msg sent no reply from SMSC to " + strMobileNo);

                                ErrorLog("[" + iCtr.ToString() + "/" + iCount.ToString() + "]:error msg..." + ex.Message);
                                iCtrClosedPhone++;
                            }
                        }
                        catch (Exception ex)
                        {
                            ErrorLog("error opening..." + ex.Message);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ErrorLog(ex.Message);
                    return;
                }
            }
            catch (Exception ex)
            {
                ErrorLog(ex.Message);
            }
        }