private void на_проводе()
        {
            string pattern        = @"\b\d{10}\b";
            string строка_телефон = textBox1.Text.Trim();

            var mc = Regex.Matches(строка_телефон, pattern);

            if (mc.Count != 1)
            {
                MessageBox.Show("Введите номер телефона 10 знаков");
                return;
            }


            //StringBuilder sb = new StringBuilder();
            //for (int i = 1; i <= 10; i++)
            //{
            //    sb.Append("абвгдесы ");
            //}
            клСообщение.текст = textBox2.Text.Trim();
            if (клСообщение.текст == String.Empty)
            {
                MessageBox.Show("Введите тест сообщения");
                return;
            }
            //   string телефон_клиента = "7" + клСообщение.телефон;

            string телефон_клиента = "7" + textBox1.Text.Trim();
            string текст           = "";

            if (клСообщение.программисту)
            {
                текст = sms.Send("79068015888", "79068015888", клСообщение.текст);
            }
            else
            {
                текст = sms.Send("79068015888", телефон_клиента, клСообщение.текст);
            }
            //  string текст = sms.Send("79068015888", "79068015888", DateTime.Now.ToLongTimeString());
            клСообщение.дата = DateTime.Now;
            textBox8.Text    = клСообщение.дата.Value.ToLongTimeString();
            MessageBox.Show(текст);
            char сепаратор = '\n';

            string[] строки = текст.Split(сепаратор);
            if (строки.Length > 1)
            {
                // лимит = int.Parse(строки[1]);
                клСообщение.код = строки[1];
                textBox7.Text   = клСообщение.код;
            }
            initСтоимость();
            if (клСообщение.стоимость > 0)
            {
                клСообщение.отправлен = true;
            }
            init_limit();
        }
Exemplo n.º 2
0
        private void Execute(Operation operation)
        {
            IList <MobilePhoneEntryObject> recipients = GetRecipients(operation);

            if (recipients.Count == 0)
            {
                Logger.Instance.LogFormat(LogType.Info, this, Properties.Resources.NoRecipientsErrorMessage);
                return;
            }

            string format = _settings.GetSetting(SettingKeys.MessageFormat).GetValue <string>();
            string text   = operation.ToString(format);

            text = ReplaceUmlauts(text);

            text = text.Truncate(SmsMessageMaxLength, true, true);

            string userName = _settings.GetSetting(SettingKeys.UserName).GetValue <string>();
            string password = _settings.GetSetting(SettingKeys.Password).GetValue <string>();

            try
            {
                _provider.Send(userName, password, recipients.Select(r => r.PhoneNumber), text);
            }
            catch (Exception ex)
            {
                Logger.Instance.LogException(this, ex);
                Logger.Instance.LogFormat(LogType.Error, this, Properties.Resources.SendSmsErrorMessage);
            }
        }
Exemplo n.º 3
0
        void IJob.Execute(IJobContext context, Operation operation)
        {
            if (context.Phase != JobPhase.AfterOperationStored)
            {
                return;
            }

            IList <MobilePhoneEntryObject> recipients = GetRecipients(operation);

            if (recipients.Count == 0)
            {
                Logger.Instance.LogFormat(LogType.Info, this, Properties.Resources.NoRecipientsErrorMessage);
                return;
            }

            string format = _settings.GetSetting("SMSJob", "MessageFormat").GetValue <string>();
            string text   = operation.ToString(format);

            text = text.Replace("Ö", "Oe").Replace("Ä", "Ae").Replace("Ü", "Ue").Replace("ö", "oe").Replace("ä", "ae").Replace("ü", "ue").Replace("ß", "ss");
            // Truncate the string if it is too long
            text = text.Truncate(160, true, true);

            // Invoke the provider-send asynchronous because it is a web request and may take a while
            _provider.Send(_userName, _password, recipients.Select(r => r.PhoneNumber), text);
        }