private void btnInsertDeliveryStatus_Click(object sender, EventArgs e)
        {
            // Set error rate structure
            SimDeliveryErrorRate objDlrError = new SimDeliveryErrorRate((SimDeliveryErrorRate)cbxDeliveryStatus.SelectedValue);

            objDlrError.Occurance = int.Parse(txtDeliveryStatusOccurance.Text);

            // Calculate total error rate
            int nTotal = 0;

            foreach (ListViewItem objLvi in lvDeliveryStatus.Items)
            {
                SimDeliveryErrorRate objErrr = (SimDeliveryErrorRate)objLvi.Tag;
                nTotal += objErrr.Occurance;
            }

            // validate input
            if (objDlrError.Occurance < 1 || objDlrError.Occurance > 100)
            {
                MessageBox.Show("Error occurrence can not be < 1% or > 100%.",
                                this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (nTotal + objDlrError.Occurance > 100)
            {
                MessageBox.Show("Total error occurrence can not be < 1% or > 100%.",
                                this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            // First; try to see if we can update an existing item with the same status
            foreach (ListViewItem objLvi in lvDeliveryStatus.Items)
            {
                SimDeliveryErrorRate objErrr = (SimDeliveryErrorRate)objLvi.Tag;
                if (objErrr.Code == objDlrError.Code &&
                    objDlrError.Text == objDlrError.Text)
                {
                    objErrr.Occurance += objDlrError.Occurance;
                    objLvi.SubItems[DELIVERY_OCCURANCE].Text = objErrr.Occurance.ToString();
                    UpdateControls();
                    return;
                }
            }

            // If not; add a new status
            ListViewItem objNewLvi = new ListViewItem(
                new string[] { objDlrError.Text, objDlrError.Code.ToString(), objDlrError.Occurance.ToString() });

            objNewLvi.Tag = objDlrError;
            lvDeliveryStatus.Items.Add(objNewLvi);

            UpdateControls();
        }
        private void btnOk_Click(object sender, EventArgs e)
        {
            m_objSimErrorRates.DeliveryErrorRates.Clear();
            m_objSimErrorRates.MessageErrorRates.Clear();

            foreach (ListViewItem objLvi in lvMessageStatus.Items)
            {
                SimMessageErrorRate objErrr = (SimMessageErrorRate)objLvi.Tag;
                m_objSimErrorRates.MessageErrorRates.Add(objErrr);
            }

            foreach (ListViewItem objLvi in lvDeliveryStatus.Items)
            {
                SimDeliveryErrorRate objErrr = (SimDeliveryErrorRate)objLvi.Tag;
                m_objSimErrorRates.DeliveryErrorRates.Add(objErrr);
            }

            DialogResult = DialogResult.OK;
            Close();
        }
        private void UpdateControls()
        {
            cbxMsgStatusPreDefined.Enabled = rbMsgStatusPreDefined.Checked;
            txtMsgStatusCustom.Enabled     = !rbMsgStatusPreDefined.Checked;

            int nMessageStatusSuccess = 100;

            foreach (ListViewItem objLvi in lvMessageStatus.Items)
            {
                SimMessageErrorRate objErrr = (SimMessageErrorRate)objLvi.Tag;
                nMessageStatusSuccess -= objErrr.Occurance;
            }
            lblMessageStatusSuccess.Text = string.Format("{0}% ROK", nMessageStatusSuccess);

            int nDeliveryStatusSuccess = 100;

            foreach (ListViewItem objLvi in lvDeliveryStatus.Items)
            {
                SimDeliveryErrorRate objErrr = (SimDeliveryErrorRate)objLvi.Tag;
                nDeliveryStatusSuccess -= objErrr.Occurance;
            }
            lblDeliveryStatusSuccess.Text = string.Format("{0}% DELIVRD", nDeliveryStatusSuccess);
        }
示例#4
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            var objSettings = Settings.Default;

            // force save settings right away
            objSettings.LastReference = objSettings.LastReference;
            objSettings.Save();

            m_Logger = new Logger(objSettings.ViewLogFile);
            m_Logger.WriteLine("Startup SMPP Simulator");

            m_objSimWorker    = new SimWorker();
            m_objSimModel     = m_objSimWorker.SimModel;
            m_objSmsConstants = new AxSms.Constants();

            // IP Version combo box
            var dctIpVersion = new Dictionary <string, int>();

            dctIpVersion.Add("IPv6/IPv4", m_objSmsConstants.SMPP_IPVERSION_BOTH);
            dctIpVersion.Add("IPv6", m_objSmsConstants.SMPP_IPVERSION_6);
            dctIpVersion.Add("IPv4", m_objSmsConstants.SMPP_IPVERSION_4);

            cbxIpVersion.DisplayMember = "Key";
            cbxIpVersion.ValueMember   = "Value";
            cbxIpVersion.DataSource    = new BindingSource(dctIpVersion, null);

            // Make sure to update all the SESSION_ constants when changing stuff here !!!!
            lvSessions.Columns.Add("Client IP", (int)(lvSessions.Width * .25), HorizontalAlignment.Left);
            lvSessions.Columns.Add("Client Port", (int)(lvSessions.Width * .25), HorizontalAlignment.Left);
            lvSessions.Columns.Add("SystemID", (int)(lvSessions.Width * .24), HorizontalAlignment.Left);
            lvSessions.Columns.Add("Connection State", (int)(lvSessions.Width * .25), HorizontalAlignment.Left);
            lvSessions.AutoResizeColumn(3, ColumnHeaderAutoResizeStyle.HeaderSize);

            // Make sure to update all the MESSAGE_ constants when changing stuff here !!!!
            lvMessages.Columns.Add("Dir.", (int)(lvMessages.Width * .1), HorizontalAlignment.Left);
            lvMessages.Columns.Add("SystemID", (int)(lvMessages.Width * .20), HorizontalAlignment.Left);
            lvMessages.Columns.Add("ToAddress", (int)(lvMessages.Width * .15), HorizontalAlignment.Left);
            lvMessages.Columns.Add("Reference", (int)(lvMessages.Width * .15), HorizontalAlignment.Left);
            lvMessages.Columns.Add("State", (int)(lvMessages.Width * .15), HorizontalAlignment.Left);
            lvMessages.Columns.Add("Body", -2, HorizontalAlignment.Left);

            // Make sure to update all the AUTOMESSAGE_ constants when changing stuff here !!!!
            lvAutoMessage.Columns.Add("FromAddress", (int)(lvAutoMessage.Width * .20), HorizontalAlignment.Left);
            lvAutoMessage.Columns.Add("ToAddress", (int)(lvAutoMessage.Width * .20), HorizontalAlignment.Left);
            lvAutoMessage.Columns.Add("Body", (int)(lvAutoMessage.Width * .59), HorizontalAlignment.Left);

            // Set the hyperlinks in the GUI
            llblAxLink.Text = "Try other SMS software products by Auron Software.";
            llblAxLink.Links.Add(llblAxLink.Text.IndexOf("SMS software products"), "SMS software products".Length, "https://www.auronsoftware.com/products/");
            llblAxLink.LinkClicked += new LinkLabelLinkClickedEventHandler(llblAxLink_LinkClicked);

            llblFooterText.Text  = "Auron SMPP Simulator is freeware. It uses Auron SMS Component.\r\n";
            llblFooterText.Text += "For more information on Auron SMS products, click here.";
            llblFooterText.Links.Add(llblFooterText.Text.IndexOf("click here"), "click here".Length, "https://www.auronsoftware.com/products/");
            llblFooterText.LinkClicked += new LinkLabelLinkClickedEventHandler(llblAxLink_LinkClicked);

            // Initialize model
            m_objSimModel.LastReference       = objSettings.LastReference + SimConstants.ADDREFERENCES_ONAPPSTART;
            m_objSimModel.Port                = objSettings.Port;
            m_objSimModel.IpVersion           = objSettings.IpVersion;
            m_objSimModel.IsAuthRequired      = objSettings.AuthRequired;
            m_objSimModel.SystemId            = objSettings.SystemId;
            m_objSimModel.Password            = objSettings.Password;
            m_objSimModel.IsPduLogEnabled     = objSettings.PduLogEnabled;
            m_objSimModel.IsServerLogEnabled  = objSettings.ServerLogEnabled;
            m_objSimModel.IsSessionLogEnabled = objSettings.SessionLogEnabled;
            m_objSimModel.ServerLog           = objSettings.ServerLog;
            m_objSimModel.SessionLog          = objSettings.SessionLog;
            m_objSimModel.GeneratePerMinute   = objSettings.GeneratePerMinute;
            m_objSimModel.RandomOrder         = objSettings.RandomOrder;
            m_objSimModel.Echo                = objSettings.Echo;
            m_objSimModel.PduTimeout          = objSettings.PduTimeout;
            m_objSimModel.EnquireInterval     = objSettings.EnquireInterval;
            m_objSimModel.UseGsmEncoding      = objSettings.UseGsmEncoding;
            m_objSimModel.MultipartMode       = objSettings.MultipartMode;
            m_objSimModel.DeliverMode         = objSettings.DeliverMode;
            m_objSimModel.CertificateStore    = objSettings.CertificateStore;

            m_nKeepMaxMessages    = objSettings.KeepMessages;
            m_strAutoMessagesFile = objSettings.AutoMessageFile;

            // pre-load auto messages
            if (LoadAutoMessages(m_strAutoMessagesFile) != 0)
            {
                SimMessage objMessage = null;
                AddToAutoMessage(new SimMessage("+123123123", SimConstants.DEFAULT_FROMADDRESS, "Hello, World!"));
                AddToAutoMessage(objMessage = new SimMessage("+321321321", SimConstants.DEFAULT_FROMADDRESS, "مرحبا، العالم"));
                objMessage.DataCoding       = m_objSmsConstants.DATACODING_UNICODE;
                AddToAutoMessage(objMessage = new SimMessage("+231231231", SimConstants.DEFAULT_FROMADDRESS, "नमस्ते दुनिया"));
                objMessage.DataCoding       = m_objSmsConstants.DATACODING_DEFAULT;
                objMessage.LanguageShift    = m_objSmsConstants.LANGUAGE_SINGLESHIFT_HINDI;
                AddToAutoMessage(objMessage = new SimMessage("+123123123", SimConstants.DEFAULT_FROMADDRESS, "48656c6c6f2c20576f726c6421"));
                objMessage.BodyFormat       = m_objSmsConstants.BODYFORMAT_HEX;
            }
            PushAutoMessages();

            // Push error rates to model.
            SimErrorRates objErrorRates    = new SimErrorRates();
            string        strMessageRates  = objSettings.MessageErrorRates;
            string        strDeliveryRates = objSettings.DeliveryErrorRates;

            string[] aMessageRates = strMessageRates.Split(';');
            try
            {
                foreach (string strMessageRate in aMessageRates)
                {
                    SimMessageErrorRate objErrr      = new SimMessageErrorRate();
                    string[]            aMessageRate = strMessageRate.Split(',');
                    objErrr.StatusCode = int.Parse(aMessageRate[0]);
                    objErrr.Occurance  = int.Parse(aMessageRate[1]);
                    objErrorRates.MessageErrorRates.Add(objErrr);
                }
            }
            catch (Exception x)
            {
                m_Logger.WriteLine("Error while parsing message rates: {0}", x.ToString());
            }

            string[] aDeliveryRates = strDeliveryRates.Split(';');
            try
            {
                foreach (string strDeliveryRate in aDeliveryRates)
                {
                    SimDeliveryErrorRate objErrr       = new SimDeliveryErrorRate();
                    string[]             aDeliveryRate = strDeliveryRate.Split(',');
                    objErrr.Code      = int.Parse(aDeliveryRate[0]);
                    objErrr.Text      = aDeliveryRate[1];
                    objErrr.Occurance = int.Parse(aDeliveryRate[2]);
                    objErrorRates.DeliveryErrorRates.Add(objErrr);
                }
            }
            catch (Exception x)
            {
                m_Logger.WriteLine("Error while parsing delivery rates: {0}", x.ToString());
            }

            m_objSimModel.SetErrorRates(objErrorRates);

            // Set other control values
            txtServerLog.Text          = m_objSimModel.ServerLog;
            txtSessionLog.Text         = m_objSimModel.SessionLog;
            cbEnableServerLog.Checked  = m_objSimModel.IsServerLogEnabled;
            cbEnableSessionLog.Checked = m_objSimModel.IsSessionLogEnabled;
            cbEnablePduLog.Checked     = m_objSimModel.IsPduLogEnabled;
            cbAuthentication.Checked   = m_objSimModel.IsAuthRequired;
            txtSystemId.Text           = m_objSimModel.SystemId;
            txtPassword.Text           = m_objSimModel.Password;
            txtMaxSendPerMinute.Text   = m_objSimModel.GeneratePerMinute.ToString();
            cbRandom.Checked           = m_objSimModel.RandomOrder;
            cbEcho.Checked             = m_objSimModel.Echo;

            ReloadCertificates();

            objSettings.Save();
            UpdateControls();
        }
示例#5
0
 public SimDeliveryErrorRate(SimDeliveryErrorRate other)
 {
     m_strText    = other.m_strText;
     m_nCode      = other.m_nCode;
     m_nOccurance = other.m_nOccurance;
 }