Beispiel #1
0
        public MainWindow()
        {
            InitializeComponent();
            typeSelect.Items.Add("Почта");
            typeSelect.Items.Add("Скачать файл");
            typeSelect.Items.Add("Перенести каталог");

            System.Windows.Forms.NotifyIcon ni = new System.Windows.Forms.NotifyIcon();
            ni.Icon    = new System.Drawing.Icon("Icon.ico");
            ni.Visible = true;
            ni.Click  += ClickNi;

            this.Closing += ThisClosing;

            using (TaskContext context = new TaskContext())
            {
                tasks = context.TaskDb.ToList();
            }

            foreach (var i in tasks)
            {
                if (i.TaskName == "Email")
                {
                    threads.Add(new Thread(() => TaskAction.SendMessages(i)));
                }
                else if (i.TaskName == "Move")
                {
                    threads.Add(new Thread(() => TaskAction.MoveCaralog(i)));
                }
                else if (i.TaskName == "Download")
                {
                    threads.Add(new Thread(() => TaskAction.DownloadFile(i)));
                }
            }

            foreach (var i in threads)
            {
                i.Start();
            }
        }
Beispiel #2
0
        private void ButtonAddEmailClick(object sender, RoutedEventArgs e)
        {
            Task newTask = new Task();

            newTask.TaskName = "Email";

            newTask.TimeStart = datePicker.SelectedDate;

            newTask.HeadMessage = textBoxHeadEmail.Text;
            newTask.BodyMessage = textBoxBodyEmail.Text;
            newTask.PostName    = textBoxPostName.Text;

            tasks.Add(newTask);

            using (TaskContext context = new TaskContext())
            {
                context.TaskDb.Add(newTask);

                context.SaveChanges();
            }
            threads.Add(new Thread(() => TaskAction.SendMessages(newTask)));
            threads[threads.Count - 1].Start();
        }