/// <summary> /// Starts a new asynchronous thread /// </summary> private void CreateThread(string filename) { Logger.Trace("COM: Removing jobinfo from queue."); _jobInfoQueue.Remove(Job.JobInfo); Logger.Trace("COM: Creating new asynchronous thread."); var thread = new SynchronizedThread(() => DoConversion(Job, filename)); thread.Name = "ConversionThread"; Logger.Trace("COM: Adding the new thread to the thread pool."); _threadPool.AddThread(thread); }
private void ExecuteDeleteJob(object o) { var jobInfo = o as JobInfo; var position = JobInfos.CurrentPosition; _jobInfos.Remove(jobInfo); _jobInfoQueue.Remove(jobInfo, true); if (_jobInfos.Count > 0) { JobInfos.MoveCurrentToPosition(Math.Max(0, position - 1)); } RaiseRefreshView(); }
/// <summary> /// Converts the job to the specified location /// </summary> /// <param name="fullFileName">Specifies the location</param> public void ConvertTo(string fullFileName) { LocationSetUp(fullFileName); Logger.Trace("COM: Starting the conversion process."); DoConversion(); if (OnJobFinished != null) { OnJobFinished(this, new EventArgs()); } if (JobFinished != null) { JobFinished(); } Logger.Trace("COM: Removing jobinfo from the queue."); _comJobInfoQueue.Remove(JobInfo); }
private void ExecuteDeleteJob(object o) { var jobs = o as IEnumerable <object>; if (jobs == null) { return; } foreach (var job in jobs.ToArray()) { var jobInfo = (IJobInfo)job; var position = JobInfos.CurrentPosition; _jobInfos.Remove(jobInfo); _jobInfoQueue.Remove(jobInfo, true); if (_jobInfos.Count > 0) { JobInfos.MoveCurrentToPosition(Math.Max(0, position - 1)); } } RaiseRefreshView(); }
private bool MergeAllExecute() { var jobInfosCopy = _jobInfoQueue.JobInfos.ToList(); var first = jobInfosCopy.First(); foreach (var jobObject in jobInfosCopy.Skip(1)) { var job = (JobInfo)jobObject; if (job.JobType != first.JobType) { continue; } _jobInfoManager.Merge(first, job); _jobInfoQueue.Remove(job, false); } _jobInfoManager.SaveToInfFile(first); return(true); }
private void ProcessJobs() { try { while (!_jobInfoQueue.IsEmpty || _managePrintJobs) { try { if (_managePrintJobs) { throw new ManagePrintJobsException(); } var jobInfo = _jobInfoQueue.NextJob; if (jobInfo.SourceFiles.Count == 0) { _logger.Info("JobInfo has no source files and will be skipped"); _jobInfoQueue.Remove(jobInfo, true); continue; } _logger.Debug("New PrintJob {0} from Printer {1}", jobInfo.InfFile, jobInfo.SourceFiles[0].PrinterName); var repeatJob = true; try { ProcessJob(jobInfo); // If Job was processed without ManagePrintJobsException, it can be removed repeatJob = false; } finally { if (!repeatJob) { // ensure that the current job is removed even if an exception is thrown _logger.Trace("Removing job from Queue"); _jobInfoQueue.Remove(jobInfo, true); } } } catch (ManagePrintJobsException) { _managePrintJobs = false; _logger.Trace("Managing print jobs"); _managePrintJobExceptionHandler.HandleException(); } } } catch (Exception ex) { _logger.Error("There was an error while processing the print jobs: " + ex); throw; } finally { if (!_jobInfoQueue.IsEmpty) { _logger.Warn("Processing finishes while there are print jobs left."); } _processingThread = null; } }