Bläddra i källkod

Fixed Digital Form Report Print Functionality

frogsoftware 1 år sedan
förälder
incheckning
adfd7ae7b2

+ 16 - 1
InABox.Core/DigitalForms/DigitalFormDocumentFactory.cs

@@ -11,6 +11,7 @@ namespace InABox.Core
     public interface IDigitalFormDocumentHandler
     {
         void LoadDocument(Guid id, Action<byte[]> callback);
+        byte[] LoadDocument(Guid id);
         Guid SaveDocument(byte[] data);
         void Run();
         void Stop();
@@ -26,6 +27,20 @@ namespace InABox.Core
         protected abstract bool IsConnected { get; }
         
         private static Action<bool>? _status;
+
+        public byte[] LoadDocument(Guid id)
+        {
+            var fullpath = Path.Combine(CachePath, FileName(id));
+            if (File.Exists(fullpath))
+                return File.ReadAllBytes(fullpath);
+
+                var result = new Client<Document>().Query(
+                    new Filter<Document>(x => x.FileName).IsEqualTo(FileName(id)),
+                    null,
+                    null
+                ).Rows.FirstOrDefault()?.Get<Document,byte[]>(c=>c.Data);
+                return result;
+        }
         
         public void LoadDocument(Guid id, Action<byte[]> callback)
         {
@@ -131,7 +146,7 @@ namespace InABox.Core
         public static void Stop() => _handler?.Stop();
         
         public static void LoadDocument(Guid id, Action<byte[]> callback) => _handler?.LoadDocument(id, callback);
-
+        public static byte[]? LoadDocument(Guid id) => _handler?.LoadDocument(id);
         public static Guid SaveDocument(byte[] data) => _handler?.SaveDocument(data) ?? Guid.Empty;
         
     }

+ 12 - 0
InABox.Core/DigitalForms/Layouts/Fields/DFLayoutEmbeddedImage/DFLayoutEmbeddedImageProperties.cs

@@ -20,6 +20,18 @@ namespace InABox.Core
 
             if (value is string str)
             {
+                try
+                {
+                    var tuple = Serialization.Deserialize<Tuple<Guid, byte[]>>(str, true);
+                    if ((tuple != null) && (tuple.Item1 != Guid.Empty))
+                        return DigitalFormDocumentFactory.LoadDocument(tuple.Item1);
+                    return null;
+                }
+                catch
+                {
+                    
+                }
+                
                 if (Guid.TryParse(str, out var id))
                 {
                     return Array.Empty<byte>();

+ 12 - 1
InABox.Core/DigitalForms/Layouts/Fields/DFLayoutLookupField/DFLayoutLookupFieldProperties.cs

@@ -58,7 +58,18 @@ namespace InABox.Core
 
         public override object? ParseValue(object? value)
         {
-            return value?.ToString();
+            try
+            {
+                var val = Serialization.Deserialize<DFLayoutLookupValue>(value?.ToString(),true);
+                return val?.ID ?? Guid.Empty;
+            }
+            catch
+            {
+                if (Guid.TryParse(value?.ToString() ?? "", out Guid result))
+                    return result;
+                return Guid.Empty;
+            }
+            
         }
 
         public override IEnumerable<CoreColumn> GetAdditionalColumns()

+ 1 - 1
InABox.Core/DigitalForms/Layouts/Fields/DFLayoutLookupField/DFLayoutLookupValue.cs

@@ -2,7 +2,7 @@ using System;
 using System.Collections.Generic;
 using InABox.Core;
 
-namespace PRS.Mobile
+namespace InABox.Core
 {
     public class DFLayoutLookupValue
     {

+ 0 - 2
inabox.wpf/DigitalForms/Designer/Controls/Fields/DFEmbeddedImageControl.cs

@@ -12,8 +12,6 @@ using System.Diagnostics.CodeAnalysis;
 using System.IO;
 using System.Linq;
 using Microsoft.Win32;
-using NPOI.OpenXmlFormats.Dml;
-using PRS.Mobile;
 using Syncfusion.UI.Xaml.ImageEditor;
 
 namespace InABox.DynamicGrid

+ 0 - 4
inabox.wpf/DigitalForms/Designer/Controls/Fields/DFLookupControl.cs

@@ -1,14 +1,10 @@
 using InABox.Clients;
 using InABox.Core;
-using NPOI.SS.Formula.Functions;
 using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 using System.Windows;
 using System.Windows.Controls;
-using PRS.Mobile;
 using ComboItemType = System.Tuple<string, System.Collections.Generic.Dictionary<string, object?>>;
 
 namespace InABox.DynamicGrid

+ 0 - 2
inabox.wpf/DigitalForms/WpfDigitalFormDocumentHandler.cs

@@ -1,7 +1,5 @@
 using System;
-using InABox.Clients;
 using InABox.Core;
-using PRS.Mobile;
 
 namespace InABox.DynamicGrid;