using System; using System.Collections.Generic; using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading; using System.Threading.Tasks; namespace Swarmops.Logic.Support.BackendServices { [Serializable] public class RasterizeDocumentHiresOrder: BackendServiceOrderBase, IBackendServiceOrderBase { [Obsolete("Do not call the parameterless public ctor directly. It is needed for serialization.", true)] public RasterizeDocumentHiresOrder() { } public RasterizeDocumentHiresOrder(Document document) { this.DocumentId = document.Identity; } public override void Run() { Document document = Document.FromIdentity(this.DocumentId); HasWorkerThread = true; WorkerThread = new Thread(LongRun); WorkerThread.Start(this); } private static void LongRun(object orderObject) { RasterizeDocumentHiresOrder order = (RasterizeDocumentHiresOrder) orderObject; Document document = Document.FromIdentity(order.DocumentId); try { PdfProcessor.Rerasterize((Document)document, PdfProcessor.PdfProcessorOptions.HighQuality | PdfProcessor.PdfProcessorOptions.ForceOrphans); } catch (Exception exception) { order.ThrewException(exception); } order.Close(); order.HasTerminated = true; } public override void Terminate() { } public int DocumentId { get; set; } } }