瀏覽代碼

Merge remote-tracking branch 'origin/kenric' into frank

frogsoftware 1 年之前
父節點
當前提交
adb7111963

+ 1 - 1
prs.desktop/MainWindow.xaml.cs

@@ -1403,7 +1403,7 @@ public partial class MainWindow : IPanelHostControl
         DbFactory.Stores = CoreUtils.TypeList(
             new[]
             {
-                typeof(DocumentStore).Assembly,
+                typeof(Store<>).Assembly,
                 typeof(EquipmentStore).Assembly
             },
             myType =>

+ 7 - 6
prs.desktop/Panels/Jobs/JobRequisitionItemGrid.cs

@@ -86,14 +86,9 @@ internal class JobRequisitionItemGrid : DynamicDataGrid<JobRequisitionItem>
                 Sequence = oldItem.Sequence
             };
             newItem.Job.ID = requisition.Job.ID;
-            newItem.Job.Synchronise(requisition.Job);
             newItem.Product.ID = oldItem.Product.ID;
-            newItem.Product.Synchronise(oldItem.Product);
             newItem.Style.ID = oldItem.Style.ID;
-            newItem.Style.Synchronise(oldItem.Style);
-            newItem.Dimensions.CopyFrom(oldItem.Dimensions);
             newItem.Supplier.ID = oldItem.Supplier.ID;
-            newItem.Supplier.Synchronise(oldItem.Supplier);
             requiItems.Add(newItem);
         }
 
@@ -103,7 +98,13 @@ internal class JobRequisitionItemGrid : DynamicDataGrid<JobRequisitionItem>
             if (t == typeof(JobRequisitionItem))
             {
                 var table = new CoreTable();
-                table.LoadColumns(typeof(JobRequisitionItem));
+
+                table.LoadColumns(new Columns<JobRequisitionItem>().Default(
+                    ColumnType.IncludeOptional,
+                    ColumnType.IncludeEditable,
+                    ColumnType.IncludeAggregates,
+                    ColumnType.IncludeForeignKeys,
+                    ColumnType.IncludeFormulae));
                 table.LoadRows(requiItems);
                 return table;
             }

+ 2 - 0
prs.shared/Database Update Scripts/DatabaseUpdateScripts.cs

@@ -13,6 +13,7 @@ using System.Diagnostics.CodeAnalysis;
 using System.Reflection;
 using System.Text.RegularExpressions;
 using FastReport.Utils;
+using PRS.Shared.Database_Update_Scripts;
 
 namespace PRS.Shared;
 
@@ -41,5 +42,6 @@ public static class DatabaseUpdateScripts
         DataUpdater.RegisterUpdateScript<Update_7_48_RequisitionActualQuantity>();
         DataUpdater.RegisterUpdateScript<Update_7_52>();
         DataUpdater.RegisterUpdateScript<Update_7_54>();
+        DataUpdater.RegisterUpdateScript<Update_7_55>();
     }
 }

+ 1 - 6
prs.shared/Database Update Scripts/Update_7_54.cs

@@ -1,11 +1,6 @@
+using InABox.Core;
 using Comal.Classes;
-using InABox.Core;
 using InABox.Database;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
 
 namespace PRS.Shared;
 

+ 44 - 0
prs.shared/Database Update Scripts/Update_7_55.cs

@@ -0,0 +1,44 @@
+using InABox.Core;
+using InABox.Database;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace PRS.Shared.Database_Update_Scripts;
+
+/// <summary>
+/// Update all the documents to use external storage.
+/// </summary>
+internal class Update_7_55 : DatabaseUpdateScript
+{
+    public override VersionNumber Version => new(7, 55);
+
+    public override bool Update()
+    {
+        var store = DbFactory.FindStore<Document>(Guid.Empty, "", Platform.Server, CoreUtils.GetVersion());
+        int i = 0;
+        int numStep = 100;
+        while (true)
+        {
+            var documents = DbFactory.Provider.Query<Document>(
+                new Filter<Document>(x => x.Data).IsNotEqualTo(null)
+                    .And(x => x.Data).IsNotEqualTo(Array.Empty<byte>()),
+                new Columns<Document>(x => x.ID).Add(x => x.Data),
+                top: numStep).ToList<Document>();
+            if(documents.Count == 0)
+            {
+                return true;
+            }
+            store.Save(documents, "");
+
+            i += numStep;
+
+            if (i / numStep % 10 == 0)
+            {
+                Logger.Send(LogType.Information, "", $"Converted {i} documents");
+            }
+        }
+    }
+}

+ 1 - 1
prs.stores/EntityDocuments/EntityDocumentStore.cs

@@ -33,7 +33,7 @@ namespace PRSStores
             if (entity.Thumbnail?.Any() == true)
                 return;
             
-            CoreTable table = Provider.Query<Document>(new Filter<Document>(x => x.ID).IsEqualTo(entity.DocumentLink.ID),
+            CoreTable table = FindSubStore<Document>().Query(new Filter<Document>(x => x.ID).IsEqualTo(entity.DocumentLink.ID),
                 new Columns<Document>(x => x.Data, x => x.FileName));
 
             if (table.Rows.Count == 0)