Procházet zdrojové kódy

PDF EDITOR CONTROL - fixed bug causing crash when reloading document

Nick-PRSDigital@bitbucket.org před 2 roky
rodič
revize
187eed3c61

+ 10 - 7
inabox.wpf/DynamicGrid/PDF/PDFEditorControl.xaml.cs

@@ -259,7 +259,10 @@ namespace InABox.DynamicGrid
                 return true;
             if (!String.Equals(entry.Get<Document, string>(x => x.CRC),index[id]))
             {
-                MessageBox.Show("This PDF has been revised, and will now refresh.\n\nPlease check the drawing for any applicable changes.");
+                Dispatcher.BeginInvoke(() => 
+                { 
+                    MessageBox.Show("This PDF has been revised, and will now refresh.\n\nPlease check the drawing for any applicable changes."); 
+                });                
                 return true;
             }
 
@@ -279,12 +282,13 @@ namespace InABox.DynamicGrid
             {
                 if (DownloadNeeded(_document.DocumentLink.ID))
                 {
-                    var dbdoc = new Client<Document>().Load(new Filter<Document>(x => x.ID).IsEqualTo(_document.DocumentLink.ID)).FirstOrDefault();
-                    if (dbdoc == null)
+                    CoreTable table = new Client<Document>().Query(new Filter<Document>(x => x.ID).IsEqualTo(_document.DocumentLink.ID));
+                    if (!table.Rows.Any())
                     {
                         MessageBox.Show("Unable to Load File!");
                         return;
                     }
+                    var dbdoc = table.Rows.FirstOrDefault().ToObject<Document>();
 
                     var indexfile = Path.Combine(CoreUtils.GetPath(), "pdfindex.json");
                     var index = new Dictionary<Guid, string>();
@@ -306,7 +310,7 @@ namespace InABox.DynamicGrid
                     }
                     catch (Exception eGhostscript)
                     {
-                        Logger.Send(LogType.Error, "", "Ghostscript Error: "+eGhostscript.Message + "\n" + eGhostscript.StackTrace);
+                        Logger.Send(LogType.Information, "", "Ghostscript: " + eGhostscript.Message + "\n" + eGhostscript.StackTrace);
                     }
 
                     try
@@ -315,7 +319,7 @@ namespace InABox.DynamicGrid
                     }
                     catch (Exception eFlatten)
                     {
-                        Logger.Send(LogType.Error, "", "Flatten Error: "+eFlatten.Message + "\n" + eFlatten.StackTrace);
+                        Logger.Send(LogType.Error, "", "Flatten Error: " + eFlatten.Message + "\n" + eFlatten.StackTrace);
                     }
 
                     try
@@ -325,7 +329,7 @@ namespace InABox.DynamicGrid
                     }
                     catch (Exception eRasterize)
                     {
-                        Logger.Send(LogType.Error, "", "Rasterize Error: "+eRasterize.Message + "\n" + eRasterize.StackTrace);
+                        Logger.Send(LogType.Error, "", "Rasterize Error: " + eRasterize.Message + "\n" + eRasterize.StackTrace);
 
                     }
 
@@ -336,7 +340,6 @@ namespace InABox.DynamicGrid
                     pdfdocument = File.ReadAllBytes(cachefile);
                 }
 
-
                 var doc = new PdfLoadedDocument(pdfdocument);
 
                 currentAnnotations.Clear();