예제 #1
0
        private void ButtonAddDownloadClick(object sender, RoutedEventArgs e)
        {
            Task newTask = new Task();

            newTask.TaskName = "Download";

            newTask.FromDownloadPath = textBoxDownloadPath.Text;
            newTask.NameFile         = textBoxDownloadName.Text;

            newTask.TimeStart = datePicker.SelectedDate;

            //newTask.TimeStart = DateTime.Now.AddMinutes(newTask.Minute).AddDays(newTask.Day).AddHours(newTask.Hour);

            tasks.Add(newTask);

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

                context.SaveChanges();
            }

            threads.Add(new Thread(() => TaskAction.DownloadFile(newTask)));
            threads[threads.Count - 1].Start();
        }
예제 #2
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();
            }
        }