/// <summary> /// starts the job provided as parameters /// </summary> /// <param name="job">the Job object containing all the parameters</param> /// <returns>success / failure indicator</returns> private bool StartEncoding(TaggedJob job) { try { log = mainForm.Log.Info(string.Format("Log for {0} ({1}, {2} -> {3})", job.Name, job.Job.EncodingMode, job.InputFileName, job.OutputFileName)); log.LogEvent("Started handling job"); log.Expand(); //Check to see if output file already exists before encoding. if (File.Exists(job.Job.Output) && (!Path.GetExtension(job.Job.Output).Equals(".lwi") && !Path.GetExtension(job.Job.Output).Equals(".ffindex") && !Path.GetExtension(job.Job.Output).Equals(".d2v") && !Path.GetExtension(job.Job.Output).Equals(".dgi")) && !mainForm.DialogManager.overwriteJobOutput(job.Job.Output)) { throw new JobStartException("File exists and the user doesn't want to overwrite", ExceptionType.UserSkip); } // Get IJobProcessor currentProcessor = GetProcessor(job.Job); if (currentProcessor == null) { throw new JobStartException("No processor could be found", ExceptionType.Error); } // Preprocess PreprocessJob(job.Job); // Setup try { currentProcessor.setup(job.Job, new StatusUpdate(job.Name), log); } catch (JobRunException e) { throw new JobStartException("Calling setup of processor failed with error '" + e.Message + "'", ExceptionType.Error); } if (currentProcessor == null) { throw new JobStartException("starting job failed", ExceptionType.Error); } // Do JobControl setup currentProcessor.StatusUpdate += new JobProcessingStatusUpdateCallback(UpdateGUIStatus); // Progress window WorkerPriority.GetJobPriority(job.Job, out WorkerPriorityType oPriority, out bool lowIOPriority); pw.setPriority(oPriority); if (mainForm.Settings.OpenProgressWindow && mainForm.Visible) { this.ShowProcessWindow(); } job.Start = DateTime.Now; currentJob = job; // Start try { currentProcessor.start(); } catch (JobRunException e) { throw new JobStartException("starting job failed with error '" + e.Message + "'", ExceptionType.Error); } RefreshAll(); MeGUI.core.util.WindowUtil.PreventSystemPowerdown(); return(true); } catch (JobStartException e) { this.HideProcessWindow(); log.LogValue("Error starting job", e); if (e.type == ExceptionType.Error) { job.Status = JobStatus.ERROR; } else // ExceptionType.UserSkip { job.Status = JobStatus.SKIP; } currentProcessor = null; currentJob = null; RefreshAll(); return(false); } }