From ab200e9f774c33ce8b73905c6a3a5c45f5e29f1d Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 10 Feb 2018 10:47:23 +0100 Subject: [PATCH] Debugging Hires PDF conversion failure --- Logic/Logic.csproj | 9 ++ .../Logic.Support.Document.Designer.cs | 81 +++++++++++ Logic/Resources/Logic.Support.Document.resx | 128 ++++++++++++++++++ Logic/Support/BackendServiceOrders.cs | 1 + .../BackendServiceOrderBase.cs | 8 +- .../RasterizeDocumentHiresOrder.cs | 16 ++- Logic/Support/PdfProcessor.cs | 2 +- 7 files changed, 239 insertions(+), 6 deletions(-) create mode 100644 Logic/Resources/Logic.Support.Document.Designer.cs create mode 100644 Logic/Resources/Logic.Support.Document.resx diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj index cdb56250..bb965b75 100644 --- a/Logic/Logic.csproj +++ b/Logic/Logic.csproj @@ -179,6 +179,11 @@ True Logic.Structure.Geography.resx + + True + True + Logic.Support.Document.resx + True True @@ -668,6 +673,10 @@ + + ResXFileCodeGenerator + Logic.Support.Document.Designer.cs + ResXFileCodeGenerator Logic.Support.ErrorMessages.Designer.cs diff --git a/Logic/Resources/Logic.Support.Document.Designer.cs b/Logic/Resources/Logic.Support.Document.Designer.cs new file mode 100644 index 00000000..364c5448 --- /dev/null +++ b/Logic/Resources/Logic.Support.Document.Designer.cs @@ -0,0 +1,81 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Swarmops.Logic.Resources { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Logic_Support_Document { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Logic_Support_Document() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Swarmops.Logic.Resources.Logic.Support.Document", typeof(Logic_Support_Document).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to (Single page). + /// + internal static string PageSingle { + get { + return ResourceManager.GetString("PageSingle", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to (Page {0} of {1}). + /// + internal static string PageXofY { + get { + return ResourceManager.GetString("PageXofY", resourceCulture); + } + } + } +} diff --git a/Logic/Resources/Logic.Support.Document.resx b/Logic/Resources/Logic.Support.Document.resx new file mode 100644 index 00000000..9a575404 --- /dev/null +++ b/Logic/Resources/Logic.Support.Document.resx @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + (Single page) + If it is possible to say "this is the only page" or "you're looking at the only page" in the translated language, it's preferable to the English wording. "Only page" doesn't sound like correct English, but your language might have a construct for it. + + + (Page {0} of {1}) + This should convey a meaning that there's more than is being looked at. + + \ No newline at end of file diff --git a/Logic/Support/BackendServiceOrders.cs b/Logic/Support/BackendServiceOrders.cs index 04c76afa..1323e2fc 100644 --- a/Logic/Support/BackendServiceOrders.cs +++ b/Logic/Support/BackendServiceOrders.cs @@ -21,6 +21,7 @@ namespace Swarmops.Logic.Support { foreach (BackendServiceOrder order in this) { + Console.WriteLine("Excecuting backend order #" + order.Identity); // debug purposes order.Execute(); } } diff --git a/Logic/Support/BackendServices/BackendServiceOrderBase.cs b/Logic/Support/BackendServices/BackendServiceOrderBase.cs index 2617976f..7f7c4a33 100644 --- a/Logic/Support/BackendServices/BackendServiceOrderBase.cs +++ b/Logic/Support/BackendServices/BackendServiceOrderBase.cs @@ -101,7 +101,8 @@ namespace Swarmops.Logic.Support.BackendServices { string executingAssemblyName = Assembly.GetExecutingAssembly().GetName().Name; string className = this.GetType().FullName; - string serviceClassName = executingAssemblyName + "," + className; + string serviceClassName = BackendServiceClass = executingAssemblyName + "," + className; + this.CreatedDateTime = DateTime.UtcNow; // Create the service order through reflection and XML serialization @@ -112,7 +113,11 @@ namespace Swarmops.Logic.Support.BackendServices public DateTime CreatedDateTime { get; set; } public string BackendServiceClass { get; set; } + + [XmlIgnore] public int ServiceOrderIdentity { get; set; } + + [XmlIgnore] public bool HasTerminated { get; set; } [XmlIgnore] @@ -122,6 +127,7 @@ namespace Swarmops.Logic.Support.BackendServices [XmlIgnore] public bool HasWorkerThread { get; set; } + [XmlIgnore] public Thread WorkerThread { get; set; } diff --git a/Logic/Support/BackendServices/RasterizeDocumentHiresOrder.cs b/Logic/Support/BackendServices/RasterizeDocumentHiresOrder.cs index aaa717f2..d34f29c2 100644 --- a/Logic/Support/BackendServices/RasterizeDocumentHiresOrder.cs +++ b/Logic/Support/BackendServices/RasterizeDocumentHiresOrder.cs @@ -25,22 +25,30 @@ namespace Swarmops.Logic.Support.BackendServices HasWorkerThread = true; WorkerThread = new Thread(LongRun); WorkerThread.Start(this); + Console.WriteLine(" - Worker thread for #" + this.ServiceOrderIdentity + " started"); // debugging } private static void LongRun(object orderObject) { - RasterizeDocumentHiresOrder order = (RasterizeDocumentHiresOrder) orderObject; - Document document = Document.FromIdentity(order.DocumentId); + RasterizeDocumentHiresOrder order = null; try { + order = (RasterizeDocumentHiresOrder)orderObject; + Console.WriteLine(" - Worker thread for #" + order.ServiceOrderIdentity + " running"); // debugging + Document document = Document.FromIdentity(order.DocumentId); PdfProcessor.Rerasterize((Document)document, PdfProcessor.PdfProcessorOptions.HighQuality | PdfProcessor.PdfProcessorOptions.ForceOrphans); + order.Close(); } catch (Exception exception) { + Console.WriteLine(" - Exception thrown: " + exception.ToString()); // debugging order.ThrewException(exception); } - order.Close(); - order.HasTerminated = true; + + if (order != null) + { + order.HasTerminated = true; + } } public override void Terminate() diff --git a/Logic/Support/PdfProcessor.cs b/Logic/Support/PdfProcessor.cs index 76f6a926..abcbfadb 100644 --- a/Logic/Support/PdfProcessor.cs +++ b/Logic/Support/PdfProcessor.cs @@ -209,7 +209,7 @@ namespace Swarmops.Logic.Support long fileLength = new FileInfo(Document.StorageRoot + lastPageFileName).Length; documents.Add( Document.Create(lastPageFileName, - clientFileName + " " + (pageCounter + 1).ToString(CultureInfo.InvariantCulture) + "/" + pdfPageCount.ToString(CultureInfo.InvariantCulture), + clientFileName + " {{LOCPAGE-" + (pageCounter).ToString(CultureInfo.InvariantCulture) + "-" + pdfPageCount.ToString(CultureInfo.InvariantCulture) + "}}", fileLength, guid, null, uploader)); // Set to readonly, lock out changes, permit all read