Просмотр исходного кода

Throwing exception when database is locked.

Kenric Nugteren 1 год назад
Родитель
Сommit
a1d11e01c4

+ 5 - 0
InABox.Database/DbFactory.cs

@@ -12,6 +12,11 @@ public class DatabaseMetadata : BaseObject, IGlobalConfigurationSettings
     public Guid DatabaseID { get; set; } = Guid.NewGuid();
 }
 
+public class DbLockedException : Exception
+{
+    public DbLockedException(): base("Database is read-only due to PRS license expiry.") { }
+}
+
 public static class DbFactory
 {
     public static Dictionary<string, ScriptDocument> LoadedScripts = new();

+ 1 - 1
inabox.database.sqlite/SQLiteProvider.cs

@@ -2805,7 +2805,7 @@ namespace InABox.Database.SQLite
                 if (T.IsAssignableTo(typeof(License)) || T.IsAssignableTo(typeof(UserTracking)))
                     return true;
                 DbFactory.LogReadOnly();
-                return false;
+                throw new DbLockedException();
             }
             return true;
         }

+ 1 - 4
inabox.wpf/DynamicGrid/Editors/CodePopupEditor/CodePopupEditorControl.cs

@@ -271,10 +271,7 @@ namespace InABox.DynamicGrid
             foreach (var key in OtherColumns.Where(x => !cols.Contains(x.Key)))
                 columns.Add(key.Key);
             var sort = LookupFactory.DefineSort(_type);
-            var filter = Activator.CreateInstance(typeof(Filter<>).MakeGenericType(_type));
-            CoreUtils.SetPropertyValue(filter, "Expression", CoreUtils.GetMemberExpression(_type, column));
-            CoreUtils.SetPropertyValue(filter, "Operator", Operator.IsEqualTo);
-            CoreUtils.SetPropertyValue(filter, "Value", value);
+            var filter = Filter.Create(_type, column).IsEqualTo(value);
 
             var lookup = client.Query(filter, columns, sort);
             var display = new Dictionary<string,object?>();