Sfoglia il codice sorgente

Prototype Scans Module

Frank van den Bos 1 anno fa
parent
commit
849f8eff71

+ 12 - 6
prs.classes/Entities/Scan/Scan.cs

@@ -7,24 +7,30 @@ namespace Comal.Classes
 {
     public class Scan : Entity, IRemotable, IPersistent, ILicense<DocumentScannerLicense>
     {
-        [CheckBoxEditor]
-        public bool Processed { get; set; }
-
+        [EditorSequence(1)]
         public DocumentLink Document { get; set; }
 
+        [EditorSequence(2)]
         public ScanTagLink Tag { get; set; }
         
+        [EditorSequence(3)]
         public EmployeeLink Employee { get; set; }
+        
+        [CheckBoxEditor]
+        [EditorSequence(4)]
+        public bool Processed { get; set; }
+
+        [NullEditor]
+        public byte[]? Thumbnail { get; set; }
 
         protected override void Init()
         {
             base.Init();
-
-            Processed = false;
-
+            
             Document = new DocumentLink();
             Tag = new ScanTagLink();
             Employee = new EmployeeLink(() => this);
+            Processed = false;
         }
     }
 }

+ 15 - 0
prs.mobile.new/PRS.Mobile/Data Models/Lists/Scan/ScanModel.cs

@@ -0,0 +1,15 @@
+using System;
+using Comal.Classes;
+using InABox.Core;
+using InABox.Mobile;
+using Syncfusion.SfDataGrid.XForms;
+
+namespace PRS.Mobile
+{
+    public class ScanModel : CoreRepository<ScanModel, ScanShell, Scan>
+    {
+        public ScanModel(IModelHost host, Func<Filter<Scan>> baseFilter) : base(host, baseFilter)
+        {
+        }
+    }
+}

+ 57 - 0
prs.mobile.new/PRS.Mobile/Data Models/Lists/Scan/ScanShell.cs

@@ -0,0 +1,57 @@
+using System;
+using InABox.Mobile;
+
+namespace PRS.Mobile
+{
+    public class ScanShell : Shell<ScanModel, Comal.Classes.Scan>, IEntityDocumentShell
+    {
+        protected override void ConfigureColumns(ShellColumns<ScanModel, Comal.Classes.Scan> columns)
+        {
+
+            columns
+                .Map(nameof(DocumentID), x => x.Document.ID)
+                .Map(nameof(FileName), x=>x.Document.FileName)
+                .Map(nameof(Thumbnail), x=>x.Thumbnail)
+                .Map(nameof(TagID), x => x.Tag.ID)
+                .Map(nameof(EmployeeID), x => x.Employee.ID);
+        }
+
+        // Actually not used here
+        public Guid ParentID
+        {
+            get; 
+            set;
+            
+        }
+        
+        public Guid DocumentID
+        {
+            get => Get<Guid>();
+            set => Set(value);
+        }
+
+        public string FileName 
+        {
+            get => Get<String>();
+            set => Set(value);
+        }    
+        
+        public byte[] Thumbnail {
+            get => Get<byte[]>();
+            set => Set(value);
+        }     
+
+        public Guid TagID
+        {
+            get => Get<Guid>();
+            set => Set(value);
+        }        
+        
+        public Guid EmployeeID
+        {
+            get => Get<Guid>();
+            set => Set(value);
+        }
+        
+    }
+}

+ 26 - 0
prs.mobile.new/PRS.Mobile/Modules/Scans/ScanModule.xaml

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<mobile:MobilePage xmlns="http://xamarin.com/schemas/2014/forms"
+             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+             xmlns:mobile="clr-namespace:InABox.Mobile;assembly=InABox.Mobile.Shared"
+             xmlns:local="clr-namespace:PRS.Mobile;assembly=PRS.Mobile"
+             x:Class="PRS.Mobile.Modules.Scans.ScanModule">
+    
+    <mobile:MobilePage.PrimaryMenu>
+        
+        <mobile:MobileMenuButton
+            Image="plus">
+            <mobile:MobileMenuButton.Items>
+                <mobile:MobileMenuItem Text="Take Photo" Clicked="TakePhoto_Clicked"/>
+                <mobile:MobileMenuItem Text="Browse Library" Clicked="BrowseLibrary_Clicked"/>
+            </mobile:MobileMenuButton.Items>
+        </mobile:MobileMenuButton>
+        
+    </mobile:MobilePage.PrimaryMenu>
+    
+    <mobile:MobilePage.PageContent>
+        <local:DocumentList
+            x:Name="_documents" />
+    </mobile:MobilePage.PageContent>
+    
+</mobile:MobilePage>

+ 56 - 0
prs.mobile.new/PRS.Mobile/Modules/Scans/ScanModule.xaml.cs

@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Comal.Classes;
+using InABox.Core;
+using InABox.Mobile;
+using Xamarin.Forms;
+using Xamarin.Forms.Xaml;
+
+namespace PRS.Mobile.Modules.Scans
+{
+    [XamlCompilation(XamlCompilationOptions.Compile)]
+    public partial class ScanModule
+    {
+        private ScanModel _scans;
+        
+        public ScanModule()
+        {
+            _scans = new ScanModel(App.Data,
+                () => new Filter<Scan>(x => x.Employee.ID).IsEqualTo(App.Data.Me.ID)
+                    .And(x => x.Processed).IsEqualTo(false)
+            ) { FileName = "scans.data" };
+            InitializeComponent();
+            RefreshData(false, true);
+        }
+
+        private void RefreshData(bool force, bool async)
+        {
+            if (async)
+                _scans.Refresh(force, () => Device.BeginInvokeOnMainThread(RefreshScreen));
+            else
+            {
+                _scans.Refresh(force);
+                RefreshScreen();
+            }
+        }
+
+        private void RefreshScreen()
+        {
+            _documents.ItemsSource = null;
+            _documents.ItemsSource = _scans;
+        }
+
+        private async void TakePhoto_Clicked(object sender, EventArgs e)
+        {
+            await _documents.AddImage<MobileDocumentCameraSource,ScanShell>();
+        }
+
+        private async void BrowseLibrary_Clicked(object sender, EventArgs e)
+        {
+            await _documents.AddImage<MobileDocumentLibrarySource, ScanShell>();
+        }
+    }
+}