示例#1
0
        /// <summary>
        /// loads all the jobs from the harddisk
        /// upon loading, the jobs are ordered according to their position field
        /// so that the order in which the jobs were previously shown in the GUI is preserved
        /// </summary>
        public void LoadJobs()
        {
            string        jobsPath = Path.Combine(mainForm.MeGUIPath, "jobs");
            DirectoryInfo di       = FileUtil.ensureDirectoryExists(jobsPath);

            FileInfo[] files = di.GetFiles("*.xml");
            foreach (FileInfo fi in files)
            {
                string    fileName = fi.FullName;
                TaggedJob job      = LoadJob(fileName);
                if (job != null && job.Name != null)
                {
                    if (allJobs.ContainsKey(job.Name))
                    {
                        MessageBox.Show("A job named " + job.Name + " is already in the queue.\nThe job defined in " + fileName + "\nwill be discarded", "Duplicate job name detected",
                                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        allJobs.Add(job.Name, job);
                    }
                }
            }

            foreach (TaggedJob job in allJobs.Values)
            {
                if (job.Status == JobStatus.PROCESSING || job.Status == JobStatus.PAUSED || job.Status == JobStatus.ABORTING)
                {
                    job.Status = JobStatus.ABORTED;
                }

                job.RequiredJobs = ToJobList(job.RequiredJobNames);
                job.EnabledJobs  = ToJobList(job.EnabledJobNames);
            }

            string            path = Path.Combine(mainForm.MeGUIPath, "joblists.xml");
            JobListSerializer s    = Util.XmlDeserializeOrDefault <JobListSerializer>(path);

            globalJobQueue.JobList = ToJobList(s.mainJobList);

            foreach (TaggedJob job in allJobs.Values)
            {
                if (globalJobQueue.HasJob(job))
                {
                    continue;
                }
                globalJobQueue.QueueJob(job);
            }

            AdjustWorkerCount(false);
        }
示例#2
0
        private void loadJobLists()
        {
            string path = Path.Combine(mainForm.MeGUIPath, "joblists.xml");

            JobListSerializer s = Util.XmlDeserializeOrDefault <JobListSerializer>(path);

            jobQueue.JobList = toJobList(s.mainJobList);

            foreach (Pair <string, List <string> > p in s.workersAndTheirJobLists)
            {
                JobWorkerMode mode = JobWorkerMode.RequestNewJobs;
                bool          bIsTemporaryWorker = false;
                if (p.fst.StartsWith("Temporary worker "))
                {
                    if (p.snd.Count == 0)
                    {
                        continue;
                    }
                    mode = JobWorkerMode.CloseOnLocalListCompleted;
                    bIsTemporaryWorker = true;
                }
                JobWorker w = NewWorker(p.fst, false);
                w.Mode = mode;
                w.IsTemporaryWorker = bIsTemporaryWorker;

                // check if there are any unassigned jobs which belongs to this worker
                foreach (TaggedJob oJob in allJobs.Values)
                {
                    if (w.Name.Equals(oJob.OwningWorker) && !p.snd.Contains(oJob.Name))
                    {
                        p.snd.Add(oJob.Name);
                    }
                }

                IEnumerable <TaggedJob> list = toJobList(p.snd);
                foreach (TaggedJob j in list)
                {
                    w.AddJob(j);
                }
            }

            // check if there are any assigned jobs which have no existing worker
            foreach (TaggedJob oJob in allJobs.Values)
            {
                if (oJob.OwningWorker != null && !workers.ContainsKey(oJob.OwningWorker))
                {
                    oJob.OwningWorker = null;
                }
            }
        }
示例#3
0
        private void saveJobLists()
        {
            JobListSerializer s = new JobListSerializer();

            s.mainJobList = toStringList(jobQueue.JobList);

            foreach (JobWorker w in workers.Values)
            {
                s.workersAndTheirJobLists.Add(new Pair <string, List <string> >(
                                                  w.Name,
                                                  toStringList(w.Jobs)));
            }
            string path = Path.Combine(mainForm.MeGUIPath, "joblists.xml");

            Util.XmlSerialize(s, path);
        }
示例#4
0
        /// <summary>
        /// saves all the jobs in the queue
        /// </summary>
        public void SaveJobs()
        {
            lock (mainForm.Jobs.ResourceLock)
            {
                foreach (TaggedJob job in allJobs.Values)
                {
                    job.EnabledJobNames  = ToStringList(job.EnabledJobs);
                    job.RequiredJobNames = ToStringList(job.RequiredJobs);
                    SaveJob(job, mainForm.MeGUIPath);
                }

                JobListSerializer s = new JobListSerializer();
                s.mainJobList = ToStringList(globalJobQueue.JobList);
                string path = Path.Combine(mainForm.MeGUIPath, "joblists.xml");
                Util.XmlSerialize(s, path);
            }
        }
示例#5
0
        private void loadJobLists()
        {
            string path = Path.Combine(mainForm.MeGUIPath, "joblists.xml");

            JobListSerializer s = Util.XmlDeserializeOrDefault <JobListSerializer>(path);

            jobQueue.JobList = toJobList(s.mainJobList);

            foreach (Pair <string, List <string> > p in s.workersAndTheirJobLists)
            {
                JobWorker w = NewWorker(p.fst, false);
                IEnumerable <TaggedJob> list = toJobList(p.snd);
                w.Jobs = list;
                foreach (TaggedJob j in list)
                {
                    j.OwningWorker = w.Name;
                }
            }
        }