فهرست منبع

Merge commit '58a255ed591d21a952006ca142feb8769305b804' into frank

Frank van den Bos 1 سال پیش
والد
کامیت
8c1f81bc64

+ 10 - 0
InABox.Core/BaseObject.cs

@@ -65,6 +65,16 @@ namespace InABox.Core
                     OnPropertyChanged(n, b, a);
             };
             DatabaseSchema.InitializeObject(this);
+            
+            CheckSequence();
+        }
+
+        private void CheckSequence()
+        {
+            if (this is ISequenceable seq && seq.Sequence <= 0)
+            {
+                seq.Sequence = CoreUtils.GenerateSequence();
+            }
         }
 
         #region Observing Flags

+ 1 - 1
InABox.Core/Classes/Document/EntityDocument.cs

@@ -54,6 +54,6 @@ namespace InABox.Core
 
         public EntityDocumentAnnotationType Type { get; set; }
 
-        public string Data { get; set; }
+        public string Data { get; set; } = "";
     }
 }

+ 6 - 5
InABox.Core/Configuration/GlobalConfiguration.cs

@@ -13,11 +13,11 @@ namespace InABox.Configuration
     [UserTracking(false)]
     public class GlobalSettings : Entity, IPersistent, IRemotable, ILicense<CoreLicense>
     {
-        public string Section { get; set; }
+        public string Section { get; set; } = "";
 
-        public string Key { get; set; }
+        public string Key { get; set; } = "";
 
-        public string Contents { get; set; }
+        public string Contents { get; set; } = "";
     }
 
     public interface IGlobalConfiguration
@@ -41,7 +41,7 @@ namespace InABox.Configuration
 
         private GlobalSettings GetSettings()
         {
-            GlobalSettings result = null;
+            GlobalSettings? result = null;
             if (ClientFactory.ClientType != null)
             {
                 var client = new Client<GlobalSettings>();
@@ -52,7 +52,8 @@ namespace InABox.Configuration
         }
 
         object IGlobalConfiguration.Load(bool useCache) => Load(useCache);
-        
+
+
         public override T Load(bool useCache = true)
         {
             if (useCache)

+ 6 - 3
InABox.Core/CoreFilterDefinition.cs

@@ -5,15 +5,18 @@ using System.Collections.Generic;
 
 namespace InABox.Core
 {
-    public class CoreFilterDefinition : BaseObject
+    public class CoreFilterDefinition : BaseObject, ISequenceable
     {
         [EditorSequence(1)]
         [TextBoxEditor]
-        public string Name { get; set; }
+        public string Name { get; set; } = "";
 
         [EditorSequence(2)]
         [FilterEditor]
-        public string Filter { get; set; }
+        public string Filter { get; set; } = "";
+
+        [NullEditor]
+        public long Sequence { get; set; }
 
         public Filter<T>? AsFilter<T>()
         {

+ 1 - 17
InABox.Core/Entity.cs

@@ -176,12 +176,6 @@ namespace InABox.Core
         //[NullEditor]
         //public List<EntityHistory> History { get; set; }
 
-        protected override void Init()
-        {
-            base.Init();
-            //History = new List<EntityHistory>();            
-            CheckSequence();
-        }
 
         //public Entity() : base()
         //{
@@ -220,15 +214,6 @@ namespace InABox.Core
             return null;
         }
 
-        private void CheckSequence()
-        {
-            if (this is ISequenceable seq && seq.Sequence <= 0)
-            {
-                seq.Sequence = CoreUtils.GenerateSequence();
-            }
-        }
-
-
         protected override void SetChanged(string name, object? before, object? after)
         {
             base.SetChanged(name, before, after);
@@ -341,7 +326,7 @@ namespace InABox.Core
     public interface IAutoIncrement<T, TType>
     {
         Expression<Func<T, TType>> AutoIncrementField();
-        Filter<T> AutoIncrementFilter();
+        Filter<T>? AutoIncrementFilter();
     }
 
     public interface INumericAutoIncrement<T> : IAutoIncrement<T, int>
@@ -433,7 +418,6 @@ namespace InABox.Core
             if (!_cache.ContainsKey(typeof(T)))
             {
                 var ctor = typeof(T).GetConstructors().First();
-                var activator = typeof(EntityFactory).GetMethod("GetActivator").MakeGenericMethod(typeof(T));
                 _cache[typeof(T)] = GetActivator<T>(ctor);
             }
 

+ 2 - 2
InABox.Core/Profiler.cs

@@ -65,7 +65,7 @@ namespace InABox.Core
         {
             if (_logOnDispose)
                 Log();
-            _stopwatch.Stop();
+            _stopwatch?.Stop();
             _stopwatch = null;
         }
 
@@ -73,7 +73,7 @@ namespace InABox.Core
         {
             if (_logOnDispose)
                 Log(count);
-            _stopwatch.Stop();
+            _stopwatch?.Stop();
             _stopwatch = null;
         }
     }

+ 2 - 2
InABox.Core/Serialization.cs

@@ -126,7 +126,7 @@ namespace InABox.Core
                 var serializer = JsonSerializer.Create(settings);
                 return obj.ToObject<T>();
             }
-            catch (Exception e)
+            catch (Exception)
             {
                 if (strict)
                 {
@@ -174,7 +174,7 @@ namespace InABox.Core
                     ret = JsonConvert.DeserializeObject<T>(json, settings);
                 }
             }
-            catch (Exception e)
+            catch (Exception)
             {
                 if (strict)
                 {

+ 22 - 21
InABox.Database/Stores/Store.cs

@@ -422,10 +422,13 @@ namespace InABox.Database
                 var prefix = autoinc.AutoIncrementPrefix() ?? "";
                 
                 var prop = CoreUtils.GetPropertyFromExpression<T, string>(autoinc.AutoIncrementField());
-                var bRequired = false;
-                foreach (var entity in entities)
-                    bRequired = bRequired || string.IsNullOrWhiteSpace(prop.GetValue(entity) as string);
-                if (bRequired)
+
+                var requiredEntities = entities.Where(x =>
+                {
+                    return (prop.GetValue(x) as string).IsNullOrWhiteSpace() && (x.ID == Guid.Empty || x.HasOriginalValue(prop.Name));
+                }).ToList();
+
+                if (requiredEntities.Count > 0)
                 {
                     
                     var filter = new Filter<T>(prop.Name).IsGreaterThanOrEqualTo(String.Format("{0}0",prefix))
@@ -451,12 +454,11 @@ namespace InABox.Database
                         int.TryParse(id, out newvalue);
                     }
                     
-                    foreach (var entity in entities)
-                        if (string.IsNullOrWhiteSpace(prop.GetValue(entity) as string))
-                        {
-                            newvalue++;
-                            prop.SetValue(entity, prefix + string.Format(autoinc.AutoIncrementFormat(), newvalue));
-                        }
+                    foreach (var entity in requiredEntities)
+                    {
+                        newvalue++;
+                        prop.SetValue(entity, prefix + string.Format(autoinc.AutoIncrementFormat(), newvalue));
+                    }
 
                     return true;
                 }
@@ -472,11 +474,13 @@ namespace InABox.Database
             if (entities.First() is INumericAutoIncrement<T> autoinc)
             {
                 var prop = CoreUtils.GetPropertyFromExpression(autoinc.AutoIncrementField());
-                
-                var bRequired = false;
-                foreach (var entity in entities)
-                    bRequired = bRequired || prop.GetValue(entity).Equals(0);
-                if (bRequired)
+
+                var requiredEntities = entities.Where(x =>
+                {
+                    return object.Equals(prop.GetValue(x), 0) && (x.ID == Guid.Empty || x.HasOriginalValue(prop.Name));
+                }).ToList();
+
+                if (requiredEntities.Count > 0)
                 {
                     
                     var row = Provider.Query(
@@ -487,13 +491,10 @@ namespace InABox.Database
                     ).Rows.FirstOrDefault();
                     int newvalue = row != null ? row.Get<int>(prop.Name) : 0;
 
-                    foreach (var entity in entities)
+                    foreach (var entity in requiredEntities)
                     {
-                        if (prop.GetValue(entity).Equals(0))
-                        {
-                            newvalue++;
-                            prop.SetValue(entity, newvalue);
-                        }
+                        newvalue++;
+                        prop.SetValue(entity, newvalue);
                     }
                     return true;
                 }

+ 19 - 2
inabox.wpf/DynamicGrid/DynamicGrid.cs

@@ -409,6 +409,7 @@ namespace InABox.DynamicGrid
             
             DataGrid.AllowDraggingRows = false;
             DataGrid.Drop += DataGrid_Drop;
+            DataGrid.DragOver += DataGrid_DragOver;
             DataGrid.RowDragDropTemplate = TemplateGenerator.CreateDataTemplate(() =>
             {
                 var border = new Border();
@@ -3413,7 +3414,12 @@ namespace InABox.DynamicGrid
         {
             Logger.Send(LogType.Information,"","OnDragEnd");
         }
-        
+
+        private void DataGrid_DragOver(object sender, DragEventArgs e)
+        {
+            HandleDragOver(sender, e);
+        }
+
         private void DataGrid_Drop(object sender, DragEventArgs e)
         {
             Logger.Send(LogType.Information,"","DataGrid_Drop");
@@ -3450,9 +3456,20 @@ namespace InABox.DynamicGrid
 
                     OnDragEnd(data.Entity, table, e);
                     DoChanged();
-
                 }
             }
+            else
+            {
+                HandleDragDrop(sender, e);
+            }
+        }
+
+        protected virtual void HandleDragDrop(object sender, DragEventArgs e)
+        {
+        }
+
+        protected virtual void HandleDragOver(object sender, DragEventArgs e)
+        {
         }
 
         protected DragDropEffects DragTable(Type entity, CoreTable table)

+ 4 - 1
inabox.wpf/DynamicGrid/DynamicGridFilterGrid.cs

@@ -58,7 +58,7 @@ namespace InABox.DynamicGrid
                 result.LoadColumns(typeof(CoreFilterDefinition));
             else
                 foreach (var column in columns.Items)
-                    result.Columns.Add(new CoreColumn { ColumnName = column.ToString(), DataType = column.Expression.Type });
+                    result.Columns.Add(new CoreColumn { ColumnName = column.Property, DataType = column.Expression.Type });
             result.LoadRows(Filters);
             action.Invoke(result, null);
         }
@@ -66,7 +66,10 @@ namespace InABox.DynamicGrid
         public override void SaveItem(CoreFilterDefinition item)
         {
             if (!Filters.Contains(item))
+            {
                 Filters.Add(item);
+            }
+            Filters.Sort((x, y) => x.Sequence.CompareTo(y.Sequence));
         }
     }
 }

+ 9 - 9
inabox.wpf/InABox.Wpf.csproj

@@ -131,16 +131,16 @@
         <PackageReference Include="FastReport.Net.Pro" Version="2023.2.23" />
         <PackageReference Include="GhostScript.NetCore" Version="1.0.1" />
         <PackageReference Include="Microsoft.CodeAnalysis.Common" Version="4.0.1" />
-        <PackageReference Include="Syncfusion.Grid.WPF" Version="20.2.0.46" />
-        <PackageReference Include="Syncfusion.Pdf.Wpf" Version="20.2.0.46" />
-        <PackageReference Include="Syncfusion.PdfViewer.WPF" Version="20.2.0.46" />
-        <PackageReference Include="Syncfusion.SfGrid.WPF" Version="20.2.0.46" />
-        <PackageReference Include="Syncfusion.SfImageEditor.WPF" Version="20.2.0.46" />
-        <PackageReference Include="Syncfusion.SfInput.WPF" Version="20.2.0.46" />
-        <PackageReference Include="Syncfusion.SfRichTextBoxAdv.WPF" Version="20.2.0.46" />
-        <PackageReference Include="Syncfusion.SfSpreadsheet.WPF" Version="20.2.0.46" />
+        <PackageReference Include="Syncfusion.Grid.WPF" Version="23.2.6" />
+        <PackageReference Include="Syncfusion.Pdf.Wpf" Version="23.2.6" />
+        <PackageReference Include="Syncfusion.PdfViewer.WPF" Version="23.2.6" />
+        <PackageReference Include="Syncfusion.SfGrid.WPF" Version="23.2.6" />
+        <PackageReference Include="Syncfusion.SfImageEditor.WPF" Version="23.2.6" />
+        <PackageReference Include="Syncfusion.SfInput.WPF" Version="23.2.6" />
+        <PackageReference Include="Syncfusion.SfRichTextBoxAdv.WPF" Version="23.2.6" />
+        <PackageReference Include="Syncfusion.SfSpreadsheet.WPF" Version="23.2.6" />
         <PackageReference Include="Syncfusion.Tools.WPF.Classic" Version="19.4.0.56" />
-        <PackageReference Include="Syncfusion.XlsIO.Wpf" Version="20.2.0.46" />
+        <PackageReference Include="Syncfusion.XlsIO.Wpf" Version="23.2.6" />
         <PackageReference Include="System.Collections.Immutable" Version="7.0.0" />
     </ItemGroup>