Parcourir la source

Stability fixes

Frank van den Bos il y a 1 an
Parent
commit
70d5680619

+ 2 - 1
InABox.Mobile/InABox.Mobile.Shared/Components/MobileButton/MobileButton.xaml

@@ -58,7 +58,8 @@
                                 TypeScale = "{TemplateBinding TypeScale}"
                                 HorizontalTextAlignment = "Center"
                                 TextColor="{TemplateBinding TextColor}"
-                                IsVisible="{TemplateBinding Text, Converter={StaticResource StringToBooleanConverter}}"                   
+                                IsVisible="{TemplateBinding Text, Converter={StaticResource StringToBooleanConverter}}" 
+                                LineHeight="1"
                                 >
                                 <material:MaterialLabel.Triggers>
                                     <DataTrigger TargetType="material:MaterialLabel" Binding="{TemplateBinding IsEnabled}" Value="False">

+ 1 - 1
InABox.Mobile/InABox.Mobile.Shared/Components/MobileList/MobileList.xaml

@@ -29,7 +29,7 @@
                     <CollectionView.EmptyView>
                         <ui:MaterialLabel 
                             x:Name="_emptylist"
-                            Text="No Data Avalable" 
+                            Text="No Data Available" 
                             VerticalOptions="CenterAndExpand" 
                             VerticalTextAlignment="Center"
                             HorizontalOptions="CenterAndExpand"

+ 5 - 4
InABox.Mobile/InABox.Mobile.Shared/DataModels/CoreRepository.cs

@@ -136,10 +136,11 @@ namespace InABox.Mobile
 
         protected Filter<TEntity> EffectiveFilter()
         {
-            return new Filters<TEntity>()
-                .Add(BaseFilter())
-                .Add(SelectedFilter)
-                .Combine();
+            var filters = new Filters<TEntity>();
+            filters.Add(BaseFilter?.Invoke());
+            filters.Add(SelectedFilter);
+            var result = filters.Combine();
+            return result;
         }
         
         protected Columns<TOtherEntity> GetColumns<TOtherItem, TOtherEntity>()

+ 22 - 15
InABox.Mobile/InABox.Mobile.Shared/DataModels/Specifics/EntityDocumentUtils.cs

@@ -1,29 +1,36 @@
 using System;
+using System.Linq;
 using InABox.Clients;
 using InABox.Core;
+using JetBrains.Annotations;
 
 namespace InABox.Mobile
 {
     public static class EntityDocumentUtils
     {
+        [CanBeNull]
         public static T SaveDocument<T>(MobileDocument image, Func<T> shell, string auditmessage) where T : IEntityDocumentShell
         {
-            T result = default(T);
-            Document doc = new Document()
+            T result = shell();
+            if (result != null)
             {
-                FileName = image.FileName,
-                Data = image.Data,
-                CRC = CoreUtils.CalculateCRC(image.Data),
-                TimeStamp = DateTime.Now
-            };
-            new Client<Document>().Save(doc, auditmessage);
-                
-            result = shell();
-            result.DocumentID = doc.ID;
-            result.FileName = doc.FileName;
-            result.Thumbnail = MobileUtils.ImageTools.CreateThumbnail(doc.Data, 128, 128);
-            result.Save(auditmessage);
-        
+                Document doc = new Document()
+                {
+                    FileName = image.FileName,
+                    Data = image.Data,
+                    CRC = CoreUtils.CalculateCRC(image.Data),
+                    TimeStamp = DateTime.Now
+                };
+                new Client<Document>().Save(doc, auditmessage);
+
+
+                result.DocumentID = doc.ID;
+                result.FileName = doc.FileName;
+                if ((!image.IsPDF()) && result.Thumbnail?.Any() != true)
+                    result.Thumbnail = MobileUtils.ImageTools.CreateThumbnail(doc.Data, 256, 256);
+                result.Save(auditmessage);
+            }
+
             return result;
         }
     }

+ 3 - 1
InABox.Mobile/InABox.Mobile.Shared/MobileDocument.cs

@@ -74,7 +74,7 @@ namespace InABox.Mobile
                 BinaryReader br = new BinaryReader(stream);
                 data = br.ReadBytes((int)stream.Length);
             }
-            return new MobileDocument(file.OriginalFilename,data);
+            return new MobileDocument(file.OriginalFilename ?? Path.GetFileName(file.Path),data);
             
         }
     }
@@ -121,6 +121,8 @@ namespace InABox.Mobile
             Data = data;
         }
 
+        public bool IsPDF() => FileName.ToUpper().EndsWith(".PDF");
+
         public static async Task<MobileDocument> From<T>() 
             where T : MobileDocumentSource, new()
         {