Exemplo n.º 1
0
        public async Task AddJobsAsync(IList <Job> argJobs)
        {
            grdQueue.SuspendLayout();
            foreach (Job job in argJobs.OrderBy(j => j.FtpFilename))
            {
                QueueItem q     = new gFtpGUI.QueueItem();
                var       queue = (grdQueue.DataSource as IList <QueueItem>);

                // Check if the job is already added to the queue
                if (queue.Any(i =>
                              i.Job.FtpFilename.ToLower().Equals(job.FtpFilename.ToLower()) &&
                              i.Job.FtpPath.ToLower().Equals(job.FtpPath.ToLower()) &&
                              i.Job.LocalFilename.ToLower().Equals(job.LocalFilename.ToLower()) &&
                              i.Job.LocalPath.ToLower().Equals(job.LocalPath.ToLower())
                              )
                    )
                {
                    MessageBox.Show($"The job {job} is already added to the queue!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    continue;
                }

                if (!queue.Any())
                {
                    q.Order = 1;
                }
                else
                {
                    q.Order = (grdQueue.DataSource as IList <QueueItem>).Max(t => t.Order) + 1;
                }
                q.Job   = job;
                q.Size  = job.Size;
                q.State = JobState.Pending;

                queue.Add(q);
            }
            grdQueue.ClearSelection();
            grdQueue.ResumeLayout();
            grdQueue.Refresh();

            await SaveQueueAsync();
        }
Exemplo n.º 2
0
        public async Task AddJobAsync(Job argJob)
        {
            QueueItem q     = new gFtpGUI.QueueItem();
            var       queue = (grdQueue.DataSource as IList <QueueItem>);

            // Check if the job is already added to the queue
            if (queue.Any(i =>
                          i.Job.FtpFilename.ToLower().Equals(argJob.FtpFilename.ToLower()) &&
                          i.Job.FtpPath.ToLower().Equals(argJob.FtpPath.ToLower()) &&
                          i.Job.LocalFilename.ToLower().Equals(argJob.LocalFilename.ToLower()) &&
                          i.Job.LocalPath.ToLower().Equals(argJob.LocalPath.ToLower())
                          )
                )
            {
                MessageBox.Show($"The job {argJob} is already added to the queue!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (!queue.Any())
            {
                q.Order = 1;
            }
            else
            {
                q.Order = (grdQueue.DataSource as IList <QueueItem>).Max(t => t.Order) + 1;
            }
            q.Job   = argJob;
            q.Size  = argJob.Size;
            q.State = JobState.Pending;

            queue.Add(q);
            grdQueue.ClearSelection();
            grdQueue.Refresh();

            await SaveQueueAsync();
        }