Sfoglia il codice sorgente

Fixed EntityDocumentAnnotation Popup Handling
removed unnecessary try/catch when loading external files into database queries

frogsoftware 1 settimana fa
parent
commit
a900430395

+ 2 - 8
inabox.database.sqlite/SQLiteProvider.cs

@@ -3930,15 +3930,9 @@ public class SQLiteProvider : IProvider
     {
         var idString = id.ToString();
         var filename = Path.Combine(ExternalDataFolder(T, columnName, idString), idString);
-        try
-        {
+        if (File.Exists(filename))
             return File.ReadAllBytes(filename);
-        }
-        catch
-        {
-            //Logger.Send(LogType.Error, "", $"Could not load external {T.Name}.{columnName}: {e.Message}");
-            return null;
-        }
+        return null;
     }
     private void SaveExternalData(Type T, string columnName, Guid id, byte[] data)
     {

+ 13 - 4
inabox.wpf/DynamicGrid/PDF/PDFEditorControl.xaml.cs

@@ -135,6 +135,11 @@ namespace InABox.DynamicGrid
                             var page = doc.Pages[i] as PdfLoadedPage;
                             foreach (PdfLoadedAnnotation a in page.Annotations)
                             {
+                                
+                                var atype = GetAnnotationType(a);
+                                if (atype == EntityDocumentAnnotationType.Popup)
+                                    continue;
+                                
                                 var a_id = Guid.Empty;
                                 if (!string.IsNullOrWhiteSpace(a.Author))
                                     Guid.TryParse(a.Author, out a_id);
@@ -143,6 +148,8 @@ namespace InABox.DynamicGrid
                                     currentAnnotations.Remove(a_id);
 
                                 var annotation = a_id.Equals(Guid.Empty) ? null : annotations.FirstOrDefault(x => x.ID.Equals(a_id));
+                                
+                                
                                 if (annotation == null)
                                 {
                                     annotation = new EntityDocumentAnnotation { EntityDocument = _document.ID };
@@ -150,15 +157,17 @@ namespace InABox.DynamicGrid
                                 }
 
                                 annotation.Page = i;
-                                annotation.Type = GetAnnotationType(a);
+                                annotation.Type = atype;
                                 annotation.Data = SaveAnnotation(doc, a);
                             }
                         }
 
                         new Client<EntityDocumentAnnotation>().Save(annotations.Where(x => x.IsChanged()), "");
-
-                        foreach (var annotation in annotations.Where(x => currentAnnotations.Contains(x.ID)))
-                            new Client<EntityDocumentAnnotation>().Delete(annotation, "");
+                        var _deletes = annotations.Where(x =>
+                                currentAnnotations.Contains(x.ID) || x.Type == EntityDocumentAnnotationType.Popup)
+                            .ToArray();
+                        if (_deletes.Any())
+                            new Client<EntityDocumentAnnotation>().Delete(_deletes, "");
                     }
                 }
             }