Пример #1
0
        private void BtnSendPlan_OnClick(object sender, RoutedEventArgs e)
        {
            SchedulerClass sc = new SchedulerClass();

            DateTime dtSendDateTime = (ldSchedulDateTimes.SelectedDate ?? DateTime.Today);

            if (tpSchedulTimes.Value.HasValue)
            {
                int hours   = tpSchedulTimes.Value.Value.Hour;
                int minutes = tpSchedulTimes.Value.Value.Minute;
                dtSendDateTime = dtSendDateTime.AddHours(hours).AddMinutes(minutes);
            }
            if (dtSendDateTime < DateTime.Now)
            {
                SendEndWindow sew =
                    new SendEndWindow("Дата и время отправки писем не могут быть раньше, чем настоящее время");
                sew.ShowDialog();
                return;
            }

            EmailSendServiceClass emailSender = CreateEmailSendService();

            if (emailSender != null)
            {
                sc.SendEmails(dtSendDateTime, emailSender, (IQueryable <Email>)dgEmails.ItemsSource, this);
            }
        }
Пример #2
0
        private void btnSend_Click(object sender, RoutedEventArgs e)
        {
            SchedulerClass sc         = new SchedulerClass();
            TimeSpan       tsSendTime = sc.GetSendTime(tbTimePicker.Text);

            if (tsSendTime == new TimeSpan())
            {
                MessageBox.Show("Некорректный формат даты");
                return;
            }
            DateTime dtSendDateTime = (cldSchedulDateTimes.SelectedDate ?? DateTime.Today).Add(tsSendTime);

            if (dtSendDateTime < DateTime.Now)
            {
                MessageBox.Show("Дата и время отправки писем не могут быть раньше, чем настоящее время");
                return;
            }
            EmailSendService emailSender = new EmailSendService(cbServerSelect.Text, Int32.Parse(cbServerSelect.SelectedValue.ToString()), cbSenderSelect.Text, cbSenderSelect.Text, pbPassword.Password);
            var locator = (ViewModelLocator)FindResource("Locator");

            sc.SendEmails(dtSendDateTime, emailSender, locator.Main.Emails, Subject.Text, MessageBody.Text);
        }