コード例 #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();
            }
        }
コード例 #2
0
        private void ButtonAddCatalogClick(object sender, RoutedEventArgs e)
        {
            Task newTask = new Task();

            newTask.TaskName = "Move";

            newTask.TimeStart = datePicker.SelectedDate;

            newTask.MovePath = textBoxMoveCatalogPath.Text;
            newTask.Catalog  = textBoxMoveCatalogName.Text;

            tasks.Add(newTask);

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

                context.SaveChanges();
            }

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